Exemple #1
0
        private void WireUpEvents()
        {
            tree.MouseDoubleClick += (s, e) =>
            {
                ContextNode = tree.GetNodeAt(e.X, e.Y) as TestSuiteTreeNode;
                if (ContextNode.TestType == "TestCase")
                {
                    Delegate eventDelegate = (Delegate)RunCommand.GetType().GetField("Execute", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(RunCommand);
                    eventDelegate.Method.Invoke(eventDelegate.Target, null);
                }
            };

            tree.MouseDown += (s, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    ContextNode = tree.GetNodeAt(e.X, e.Y) as TestSuiteTreeNode;
                }
            };

            tree.AfterSelect += (s, e) =>
            {
                if (_propertiesDialog != null)
                {
                    if (_propertiesDialog.Pinned)
                    {
                        _propertiesDialog.DisplayProperties((TestSuiteTreeNode)e.Node);
                    }
                    else
                    {
                        _propertiesDialog.Close();
                    }
                }
            };

            tree.DragDrop += (s, e) =>
            {
                if (IsValidFileDrop(e.Data))
                {
                    FileDrop?.Invoke((string[])e.Data.GetData(DataFormats.FileDrop));
                }
            };

            tree.DragEnter += (s, e) =>
            {
                e.Effect = IsValidFileDrop(e.Data)
                    ? DragDropEffects.Copy
                    : DragDropEffects.None;
            };

            treeMenu.Collapse += (s, e) => ContextNode = null;
        }
        private void WireUpEvents()
        {
            tree.MouseDoubleClick += (s, e) =>
            {
                ContextNode = tree.GetNodeAt(e.X, e.Y) as TestSuiteTreeNode;
                if (ContextNode.TestType == "TestCase")
                {
                    Delegate eventDelegate = (Delegate)RunCommand.GetType().GetField("Execute", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(RunCommand);
                    eventDelegate.Method.Invoke(eventDelegate.Target, null);
                }
            };

            tree.MouseDown += (s, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    ContextNode = tree.GetNodeAt(e.X, e.Y) as TestSuiteTreeNode;
                }
            };

            tree.AfterSelect += (s, e) =>
            {
                if (_propertiesDialog != null)
                {
                    if (_propertiesDialog.Pinned)
                    {
                        _propertiesDialog.DisplayProperties((TestSuiteTreeNode)e.Node);
                    }
                    else
                    {
                        _propertiesDialog.Close();
                    }
                }
            };

            tree.DragDrop += (s, e) =>
            {
                if (IsValidFileDrop(e.Data))
                {
                    FileDrop?.Invoke((string[])e.Data.GetData(DataFormats.FileDrop));
                }
            };

            tree.DragEnter += (s, e) =>
            {
                e.Effect = IsValidFileDrop(e.Data)
                    ? DragDropEffects.Copy
                    : DragDropEffects.None;
            };

            treeMenu.Popup += (s, e) =>
            {
                TestSuiteTreeNode targetNode = ContextNode ?? (TestSuiteTreeNode)tree.SelectedNode;
                TestSuiteTreeNode theoryNode = targetNode?.GetTheoryNode();


                runMenuItem.DefaultItem = runMenuItem.Enabled && targetNode != null && targetNode.Included &&
                                          (targetNode.Test.RunState == RunState.Runnable || targetNode.Test.RunState == RunState.Explicit);

                showCheckBoxesMenuItem.Checked = tree.CheckBoxes;

                //failedAssumptionsMenuItem.Visible =
                failedAssumptionsMenuItem.Enabled = theoryNode != null;
                failedAssumptionsMenuItem.Checked = theoryNode?.ShowFailedAssumptions ?? false;

                propertiesMenuItem.Enabled = targetNode != null;
            };

            treeMenu.Collapse += (s, e) => ContextNode = null;
        }