Beispiel #1
0
        private void handleDrop(DragEventArgs e)
        {
            O2Thread.mtaThread(
                () =>
            {
                string itemDroped = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
                if (itemDroped != "")
                {
                    if (File.Exists(itemDroped))
                    {
                        addFile(itemDroped, true, tbViewFilter.Text);
                    }
                    else
                    {
                        if (cbOnDropClearLoadedFiles.Checked)
                        {
                            clearMappings();
                        }
                        addFolder(itemDroped, tbViewFilter.Text);
                    }

                    hideDropHelpInfo();
                }
            });
        }
Beispiel #2
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            if (hasButtonBeenDown && isDraggin == false && (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                if (Vertex.Get(@"BaseEdge:\To:") != null)
                {
                    isDraggin = true;

                    IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                    dndVertex.AddEdge(null, Vertex.Get(@"BaseEdge:"));

                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);

                    isDraggin = false;
                }
            }
        }
        public void handleDrop(DragEventArgs e)
        {
            var fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (false == string.IsNullOrEmpty(fileOrFolder))
            {
                if (File.Exists(fileOrFolder))
                {
                    addAssemblyFile(fileOrFolder, true);
                }
                if (Directory.Exists(fileOrFolder))
                {
                    var assembliesToAdd = Files.getFilesFromDir_returnFullPath(fileOrFolder, new List <string> {
                        "*.dll", "*.exe"
                    }, true);
                    if (assembliesToAdd.Count > 0)
                    {
                        foreach (var file in assembliesToAdd)
                        {
                            addAssemblyFile(file, false);
                        }
                        refreshViews();
                    }
                }
            }
        }
Beispiel #4
0
        public static TextBox add_DropArea(this IStep step, int left, int top, int width, int height, Action <string> onDroppedFile)
        {
            var colorWhenNotReadyToDrop = Color.LightCoral;
            var colorWhenReadyToDrop    = Color.LightGreen;
            var dropArea = new TextBox();

            dropArea.Multiline = true;
            dropArea.BackColor = colorWhenNotReadyToDrop;
            dropArea.Left      = left;
            dropArea.Top       = top;
            dropArea.Width     = width;
            dropArea.Height    = height;
            dropArea.AllowDrop = true;

            dropArea.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;

            dropArea.DragDrop += (sender, e) =>
            {
                var fileOrDirectory = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
                dropArea.set_Text(fileOrDirectory);
                onDroppedFile(fileOrDirectory);
            };
            dropArea.DragEnter += (sender, e) =>
            {
                e.Effect           = DragDropEffects.Copy;
                dropArea.BackColor = colorWhenReadyToDrop;
            };
            dropArea.DragLeave += (sender, e) => dropArea.BackColor = colorWhenNotReadyToDrop;

            step.add_Control(dropArea);

            return(dropArea);
        }
 private void tvDirectory_DragDrop(object sender, DragEventArgs e)
 {
     if (_onTreeViewDrop != null)
     {
         _onTreeViewDrop(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
     }
     if (_ProcessDroppedObjects)
     {
         string fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
         if (File.Exists(fileOrFolder) && Path.GetDirectoryName(fileOrFolder) != getCurrentDirectory())
         {
             var fileName = "";
             if (Path.GetDirectoryName(fileOrFolder) + '\\' == DI.config.O2TempDir)
             {
                 fileName = Files.MoveFile(fileOrFolder, getCurrentDirectory());
             }
             else
             {
                 fileName = Files.Copy(fileOrFolder, getCurrentDirectory());
             }
             if (fileName != "")
             {
                 _onDirectoryDoubleClick(fileName);
             }
         }
         else if (Directory.Exists(fileOrFolder) && fileOrFolder != getCurrentDirectory())
         {
             Files.copyFolder(fileOrFolder, getCurrentDirectory());
         }
     }
 }
Beispiel #6
0
        private void tvAssemblyBrowser_DragDrop(object sender, DragEventArgs e)
        {
            string file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (file != "")
            {
                loadAssembly(file);
            }
        }
Beispiel #7
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            var    headersPresenter   = UIWpf.FindVisualChild <DataGridColumnHeadersPresenter>(this);
            double headerActualHeight = headersPresenter.ActualHeight;

            if (mousePos.Y <= headerActualHeight) // if header
            {
                e.Handled = false;
                return;
            }

            if (hasButtonBeenDown && isDraggin == false &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                RestoreSelectedVertexes();

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);

                    e.Handled = true;
                }

                isDraggin = false;
            }

            // e.Handled = true;
        }
Beispiel #8
0
        public void handleDataGridViewDrop(DragEventArgs e)
        {
            var variableName = (string)Dnd.tryToGetObjectFromDroppedObject(e, typeof(string));

            if (variableName != null)
            {
                addVariableToParametersDataGridView(variableName);
            }
        }
        private void processDroppedFileorFolder(DragEventArgs e)
        {
            string fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (!processFolder(fileOrFolder, cbOnFolderDropSearchRecursively.Checked))
            {
                processFile(fileOrFolder);
            }
        }
Beispiel #10
0
        private void tryToLoadFileInMainDocumentArea(DragEventArgs e) // todo:to implement tryToLoadFileInMainDocumentArea
        {
            string file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (File.Exists(file))
            {
                O2Messages.fileOrFolderSelected(file);
            }
        }
Beispiel #11
0
        public static IStep add_SelectFile(this List <IStep> steps, string stepTitle, string defaultFolder, int top, int textBoxLeft, int textBoxWidth, Action <string> setResult, Action <TextBox, Button> callbackWithControls)
        {
            // textbox
            var textBox = new TextBox();

            textBox.TextChanged += (sender, e) => setResult(textBox.Text);
            textBox.Text         = defaultFolder;
            if (top > -1)
            {
                textBox.Top = top;
            }
            if (textBoxLeft > -1)
            {
                textBox.Left = textBoxLeft;
            }
            textBox.Width      = (textBoxWidth > -1) ? textBoxWidth : 90;
            textBox.Anchor     = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            textBox.AllowDrop  = true;
            textBox.DragDrop  += (sender, e) => textBox.set_Text(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
            textBox.DragEnter += (sender, e) => e.Effect = DragDropEffects.Copy;

            // button
            var button = new Button();

            if (top > -1)
            {
                button.Top = top;
            }
            button.Top   -= 2;
            button.Text   = "Select File";
            button.Width += 20;
            button.Left   = textBox.Width + textBox.Left + 2;
            button.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            button.Click += (sender, e) =>
            {
                var openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = defaultFolder;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    textBox.Text = openFileDialog.FileName;
                    openFileDialog.Dispose();
                }
            };

            // panel
            var step = steps.add_Panel("stepTitle");

            //var panel = new FlowLayoutPanel();
            //panel.Dock = DockStyle.Fill;// AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            step.add_Control(textBox);
            step.add_Control(button);
            callbackWithControls(textBox, button);
            //var newStep = new TemplateStep(panel, 10, stepTitle);
            //steps.Add(newStep);
            return(step);
        }
        private void lbFilesToSearchCallbackOn_DragDrop(object sender, DragEventArgs e)
        {
            var file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (File.Exists(file))
            {
                lbFilesToSearchCallbackOn.Items.Add(file);
            }
        }
 public void InitializeComponent()
 {
     tvWizards            = this.add_TreeView();
     tvWizards.AllowDrop  = true;
     tvWizards.DragEnter += (sender, e) => Dnd.setEffect(e);
     tvWizards.DragDrop  += (sender, e) => loadAssembly(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
     this.Width           = 500;
     this.Height          = 500;
 }
        private void lvChangedRules_DragDrop(object sender, DragEventArgs e)
        {
            var droppedData = Dnd.tryToGetObjectFromDroppedObject(e);

            if (droppedData is List <IO2Rule> )
            {
                addRulesToChangedRulesList((List <IO2Rule>)droppedData);
            }
        }
Beispiel #15
0
        ///// DRAG AND DROP



        private void dndDrop(object sender, DragEventArgs e)
        {
            IVertex v = GetEdgeByLocation(e.GetPosition(this));

            if (v != null)
            {
                Dnd.DoFormDrop(null, Vertex.Get(@"BaseEdge:\To:"), v.Get("To:"), e);
            }

            e.Handled = true;
        }
        private void tvDirectoriesAndFiles_DragDrop(object sender, DragEventArgs e)
        {
            Assembly assembly = (Assembly)Dnd.tryToGetObjectFromDroppedObject(e, typeof(Assembly));

            if (assembly != null)
            {
                loadAssembly(assembly);
            }
            else
            {
                loadAssembly(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
            }
        }
Beispiel #17
0
 private void handleDrop(DragEventArgs e)
 {
     O2Thread.mtaThread(
         () =>
     {
         this.invokeOnThread(() => lbLoadDroppedFiles.Visible = true);
         if (!loadFiles((List <string>)Dnd.tryToGetObjectFromDroppedObject(e, typeof(List <string>))))
         {
             loadFile((string)Dnd.tryToGetObjectFromDroppedObject(e, typeof(string)));
         }
         this.invokeOnThread(() => lbLoadDroppedFiles.Visible = false);
     });
 }
        private void processDragAndDropFile(DragEventArgs e)
        {
            var droppedObject = (DotNetWrappers.Filters.FilteredSignature)Dnd.tryToGetObjectFromDroppedObject(e, typeof(DotNetWrappers.Filters.FilteredSignature));

            if (droppedObject != null)
            {
                tbTextSearch.Text = (droppedObject.sSignature);
            }
            else
            {
                loadSourceCodeFile(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
            }
        }
Beispiel #19
0
        private void dndDrop(object sender, DragEventArgs e)
        {
            IVertex v = GetEdgeByLocation(e.GetPosition(this));

            if (v == null && GeneralUtil.CompareStrings(MinusZero.Instance.Root.Get(@"User\CurrentUser:\Settings:\AllowBlankAreaDragAndDrop:").Value, "OnlyEnd"))
            {
                v = Vertex.Get("BaseEdge:");
            }

            if (v != null)
            {
                Dnd.DoDrop(null, v.Get("To:"), e);
            }
        }
Beispiel #20
0
        private void lbLoadedFiles_DragDrop(object sender, DragEventArgs e)
        {
            var droppedFile = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (Directory.Exists(droppedFile))
            {
                foreach (var file in Files.getFilesFromDir_returnFullPath(droppedFile))
                {
                    loadWebInspectScanFile(file);
                }
            }
            else
            {
                loadWebInspectScanFile(droppedFile);
            }
        }
        private void tvDirectory_DragEnter(object sender, DragEventArgs e)
        {
            string fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e, false /*downloadIfHttp */);

            if (File.Exists(fileOrFolder))
            {
                if (Path.GetDirectoryName(fileOrFolder) == getCurrentDirectory())
                {
                    return;
                }
            }
            else if (fileOrFolder == getCurrentDirectory())
            {
                return;
            }
            e.Effect = DragDropEffects.Copy;
        }
Beispiel #22
0
        public static IStep add_SelectFolder(this List <IStep> steps, string stepTitle, string defaultFolder, Action <string> setResult)
        {
            // textbox
            var textBox = new TextBox();

            textBox.TextChanged += (sender, e) =>
            {
                setResult(textBox.Text);
                PublicDI.log.info("in TextChanged");
            };
            textBox.Text       = defaultFolder;
            textBox.Width      = 400;
            textBox.Anchor     = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
            textBox.AllowDrop  = true;
            textBox.DragDrop  += (sender, e) => textBox.set_Text(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e));
            textBox.DragEnter += (sender, e) => e.Effect = DragDropEffects.Copy;

            // button
            var button = new Button();

            button.Text   = "Select Folder";
            button.Width += 20;
            button.Click += (sender, e) =>
            {
                var folderBrowserDialog = new FolderBrowserDialog();
                folderBrowserDialog.SelectedPath = defaultFolder;
                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    textBox.Text = folderBrowserDialog.SelectedPath;
                    folderBrowserDialog.Dispose();
                }
            };

            // panel
            var panel = new FlowLayoutPanel();

            panel.Dock = DockStyle.Fill;// AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

            panel.Controls.Add(textBox);
            panel.Controls.Add(button);

            var newStep = new TemplateStep(panel, 10, stepTitle);

            steps.Add(newStep);
            return(newStep);
        }
Beispiel #23
0
 private void processDragAndDropFile(DragEventArgs e)
 {
     O2Thread.mtaThread(() =>
     {
         var droppedObject = (FilteredSignature)Dnd.tryToGetObjectFromDroppedObject(e, typeof(FilteredSignature));
         if (droppedObject != null)
         {
             tbTextSearch.set_Text(droppedObject.sSignature);
         }
         else
         {
             var fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
             if (fileOrFolder.fileExists())
             {
                 loadSourceCodeFile(fileOrFolder);
             }
         }
     });
 }
Beispiel #24
0
        private void tvCurrentFilters_DragDrop(object sender, DragEventArgs e)
        {
            TreeNodeCollection tnTargetTreeNodeCollection = tvSearchFilters.Nodes;
            TreeNode           tnDraggedTarget            = O2Forms.getTreeNodeAtDroppedOverPoint(tvSearchFilters, e.X, e.Y);

            if (tnDraggedTarget != null)
            {
                tnTargetTreeNodeCollection = tnDraggedTarget.Nodes;
                // DI.log.error("tnDraggedTarget: {0}", tnDraggedTarget.Text);
            }

            var sDroppedData = (String)Dnd.getGetObjectFromDroppedData(e, "String");

            if (sDroppedData != null)
            {
                if (tnDraggedTarget != null)
                {
                    tvSearchFilters.SelectedNode = tvSearchFilters.Nodes.Insert(tnDraggedTarget.Index - 1, sDroppedData);
                }
                else
                {
                    tnTargetTreeNodeCollection.Add(sDroppedData);
                }

                //             tvCurrentFilters.ExpandAll();
            }
            else
            {
                var tnDroppedData = (TreeNode)Dnd.getGetObjectFromDroppedData(e, "TreeNode");
                if (tnDroppedData != null)
                {
                    if (tvSearchFilters.SelectedNode != tnDroppedData && tnDraggedTarget != null)
                    {
                        tvSearchFilters.Nodes.Remove(tnDroppedData);
                        tvSearchFilters.Nodes.Insert(tnDraggedTarget.Index + 1, tnDroppedData);
                        tvSearchFilters.SelectedNode = tnDroppedData;
                    }
                }
            }
            tvSearchFilters.ExpandAll();
            loadTreeViewWithSearchResults();
        }
Beispiel #25
0
        private void dndPreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(this);
            Vector diff     = dndStartPoint - mousePos;

            if (hasButtonBeenDown &&
                !UIWpf.IsMouseOverScrollbar(sender, dndStartPoint) &&
                (e.LeftButton == MouseButtonState.Pressed) && (
                    (Math.Abs(diff.X) > Dnd.MinimumHorizontalDragDistance) ||
                    (Math.Abs(diff.Y) > Dnd.MinimumVerticalDragDistance)))
            {
                isDraggin = true;

                IVertex dndVertex = MinusZero.Instance.CreateTempVertex();

                if (Vertex.Get(@"SelectedEdges:\") != null)
                {
                    foreach (IEdge ee in Vertex.GetAll(@"SelectedEdges:\"))
                    {
                        dndVertex.AddEdge(null, ee.To);
                    }
                }
                else
                {
                    IVertex v = GetEdgeByLocation(dndStartPoint);
                    if (v != null)
                    {
                        dndVertex.AddEdge(null, v);
                    }
                }

                if (dndVertex.Count() > 0)
                {
                    DataObject dragData = new DataObject("Vertex", dndVertex);
                    dragData.SetData("DragSource", this);

                    Dnd.DoDragDrop(this, dragData);
                }

                isDraggin = false;
            }
        }
Beispiel #26
0
        private void handleDragDrop(DragEventArgs e)
        {
            var o2Finding = (O2Finding)Dnd.tryToGetObjectFromDroppedObject(e, typeof(O2Finding));

            if (o2Finding != null)
            {
                loadO2Finding(o2Finding, false);
            }
            else
            {
                var treeNode = (TreeNode)Dnd.tryToGetObjectFromDroppedObject(e, typeof(TreeNode));
                if (treeNode != null)
                {
                    if (treeNode.Tag != null && treeNode.Tag.GetType().Name == "O2Finding")
                    {
                        loadO2Finding((O2Finding)treeNode.Tag, false);
                    }
                }
            }
        }
 public static T onDrop <T>(this T control, Action <string> onDropFileOrFolder)
     where T : Control
 {
     return((T)control.invokeOnThread(() =>
     {
         control.AllowDrop = true;
         control.DragEnter += (sender, e) => Dnd.setEffect(e);
         control.DragDrop += (sender, e)
                             =>
         {
             var fileOrFolder = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
             if (fileOrFolder.valid())
             {
                 onDropFileOrFolder(fileOrFolder);
             }
         };
         return control;
     }));
     //
 }
Beispiel #28
0
        private void handleDrop(DragEventArgs e)
        {
            var droppedObject = Dnd.tryToGetObjectFromDroppedObject(e);

            if (droppedObject is List <string> )
            {
                showSignatures((List <string>)droppedObject);
            }
            else
            {
                var isFileOrDir = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);
                if (isFileOrDir != "")
                {
                    Callbacks.raiseRegistedCallbacks(_onDrop, new [] { isFileOrDir });
                }
                else
                {
                    Callbacks.raiseRegistedCallbacks(_onDrop, new [] { droppedObject });
                }
            }
        }
Beispiel #29
0
        //events
        public static T onDrop <T, T1>(this T control, Action <T1> onDrop) where T : Control
        {
            control.invokeOnThread(() =>
            {
                control.AllowDrop  = true;
                control.DragEnter += (sender, e) => Dnd.setEffect(e);
                control.DragDrop  += (sender, e) =>
                {
                    sender.showInfo();
                    e.showInfo();

                    "{0} - {1}".info(sender.typeName(), e.typeName());
                    var data = Dnd.tryToGetObjectFromDroppedObject(e, typeof(T1));
                    if (data.notNull())
                    {
                        onDrop((T1)data);
                    }
                };
            });
            return((T)control);
        }
Beispiel #30
0
        private void processDroppedObject(DragEventArgs e)
        {
            string file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e);

            if (!string.IsNullOrEmpty(file))
            {
                loadOzasmtFile(file);
            }
            else
            {
                object droppedObject = Dnd.tryToGetObjectFromDroppedObject(e);
                if (droppedObject is List <IO2Finding> )
                {
                    loadO2Findings((List <IO2Finding>)droppedObject);
                }
                else if (droppedObject is IO2Assessment)
                {
                    loadO2Assessment(((IO2Assessment)droppedObject));
                }
            }
        }