Exemple #1
0
        /// <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;
            }
        }
Exemple #2
0
        private void SledDocumentEditorFileDragDropped(object sender, FileDragDropEventArgs e)
        {
            foreach (var path in e.Paths)
            {
                try
                {
                    var attrs = File.GetAttributes(path);
                    if ((attrs & FileAttributes.Directory) == FileAttributes.Directory)
                        continue;

                    ISledDocument sd;
                    Open(new Uri(path), out sd);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }