protected override void OnPasteDragDrop(PasteDragDropEventArgs e) { if (!(string.IsNullOrEmpty(e.get_Text()) || UserOptions.Instance.ConvertTabsToSpaces)) { e.set_Text(ConvertSpacesToTabs(e.get_Text())); } if ((e.get_Source() == 4) && (SchemaTree.DragRepository != null)) { RepositoryEventArgs args = new RepositoryEventArgs { Repository = SchemaTree.DragRepository }; this.RepositoryDropped(this, args); } base.OnPasteDragDrop(e); }
/// <summary> /// Occurs when a paste or drag/drop operation occurs over the control, allowing for customization of the text to be inserted. /// </summary> private void EditorPasteDragDrop(object sender, PasteDragDropEventArgs e) { var editor = sender as ActiproSoftware.SyntaxEditor.SyntaxEditor; if (editor == null) return; if (!e.DataObject.GetDataPresent(DataFormats.FileDrop)) return; var paths = e.DataObject.GetData(DataFormats.FileDrop) as string[]; if (paths == null) return; if (paths.Length <= 0) return; var args = new FileDragDropEventArgs(paths); // Must set e.Text or drag event args become none for // some reason in the ActiproSoftware SyntaxEditor code. switch (e.Source) { case PasteDragDropSource.DragEnter: { FileDragDropping.Raise(this, args); if (args.Cancel) return; e.Text = string.Empty; // This seems to have no effect. :( e.DragEventArgs.Effect = DragDropEffects.Copy; } break; case PasteDragDropSource.DragDrop: FileDragDropped.Raise(this, args); break; } }
private void EditorPasteDragDrop(object sender, PasteDragDropEventArgs e) { var editor = sender as SyntaxEditor; if (editor == null) return; // Allow file name drops from Windows Explorer if (e.DataObject.GetDataPresent(DataFormats.FileDrop)) { object files = e.DataObject.GetData(DataFormats.FileDrop); if ((files is string[]) && (((string[])files).Length > 0)) { string filename = ((string[])files)[0]; // If performing a drop of a .snippet file, see if it contains any code snippets and if so, // activate the first one that is found if ((e.Source == PasteDragDropSource.DragDrop) && (Path.GetExtension(filename).ToLower() == ".snippet")) { CodeSnippet[] codeSnippets = CodeSnippet.LoadFromXml(filename); if (codeSnippets.Length > 0) { e.Text = String.Empty; editor.IntelliPrompt.CodeSnippets.Activate(codeSnippets[0]); return; } } } } }