private void base_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { System.Diagnostics.Debug.WriteLine("DragOver fired"); if (e.Data.GetDataPresent(typeof(DraggedNodeData).FullName, false) == true) { DraggedNodeData nodeData = (DraggedNodeData)e.Data.GetData(typeof(DraggedNodeData).FullName, false); if (nodeData.DraggedTreeEditorId == InstanceId) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.Copy; } } else if (e.Data.GetDataPresent(typeof(string)) == true) { string draggedText = (string)e.Data.GetData(typeof(string)); if (draggedText != null) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } else { e.Effect = DragDropEffects.None; } }
private void base_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TreeNode destinationNode = this.GetNodeAt(this.PointToClient(new System.Drawing.Point(e.X, e.Y))); string destinationNoteId = (string)destinationNode.Tag; bool isNoDropDone = false; if (e.Data.GetDataPresent(typeof(DraggedNodeData).FullName, false) == true) { DraggedNodeData nodeData = (DraggedNodeData)e.Data.GetData(typeof(DraggedNodeData).FullName, false); if (nodeData.DraggedTreeEditorId == InstanceId) { try { m_NotepadXDocument.MoveNoteById(nodeData.DraggedNodeId, destinationNoteId); } catch (ArgumentException moveException) { if (moveException.ParamName != "InvalidSourceId") { MessageBox.Show("Can not move this note because this note is a parent of the note where you want to move it"); } } } else { m_NotepadXDocument.CopyNoteByContent(nodeData.DraggedNodeXml, destinationNoteId); } } else if (e.Data.GetDataPresent(typeof(string)) == true) { string draggedText = (string)e.Data.GetData(typeof(string)); if (draggedText != null) { if (MessageBox.Show("Do you wish to create new note?", "Create Note", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { AddNewChildNoteForTreeNode(destinationNoteId, draggedText, ContentFormats.FORMAT_DEFAULT); } } else { isNoDropDone = true; }; //ignore the drag drop for null texts } else { isNoDropDone = true; }; //ignore the drag drop for other formats if (isNoDropDone == false) { destinationNode = RefreshTreeFromCatNoteDocument(destinationNoteId); SelectTreeNode(destinationNode); } }