ATML1671Translator.forms.ATMLSignalMappingForm.mappedSignals_DragDrop C# (CSharp) Method

mappedSignals_DragDrop() private method

private mappedSignals_DragDrop ( object sender, DragEventArgs e ) : void
sender object
e DragEventArgs
return void
        private void mappedSignals_DragDrop(object sender, DragEventArgs e)
        {
            var dscreen = new Point(e.X, e.Y);
            Point dclient = mappedSignals.PointToClient(dscreen);
            DataGridView.HitTestInfo hit = mappedSignals.HitTest(dclient.X, dclient.Y);
            if (hit.Type == DataGridViewHitTestType.Cell)
            {
                DataGridViewCell cell = mappedSignals.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
                var oldText = cell.Value as string;
                var bean = mappedSignals.Rows[hit.RowIndex].DataBoundItem as SourceSignalMapBean;
                if (bean != null)
                {
                    string data = e.Data.GetData(DataFormats.Text).ToString();
                    string[] parts = data.Split( '|' );
                    bean.targetType = parts[0];
                    bean.targetName = parts[1];
                    mappedSignals.InvalidateRow(hit.RowIndex);
                    mappedSignals.Update();
                    cell.Style.ForeColor = bean.targetName.Equals(oldText) ? Color.Black : Color.Blue;
            //                    cell = mappedSignals.Rows[hit.RowIndex].Cells[hit.ColumnIndex-1];
            //                    cell.Style.ForeColor = bean.targetName.Equals(oldText) ? Color.Black : Color.Blue;
                    TreeNode node = signalModelLibrary.SelectedNode;
                    if (node != null)
                    {
                        foreach (TreeNode child in node.Nodes)
                        {
                            string text = child.Text.ToLower().Replace( "-"," " ).Replace( "_", " " );
                            foreach (DataGridViewRow row in mappedSignalAttributes.Rows)
                            {
                                string source = row.Cells[2].Value as string;
                                if (source != null)
                                {
                                    if (text.Equals( source.ToLower().Replace( "-", " " ).Replace( "_", " " ) ))
                                        row.Cells[7].Value = child.Text;
                                }
                            }

                        }
                    }

                }
            }
        }