Exemplo n.º 1
0
        public void AddDocument(Canvas canvas)
        {
            NuGenTreeNode treeNode = new NuGenTreeNode(canvas.ParentTabPage.Text, true, true);

            treeNode.Tag = canvas;
            _documents.Nodes.Add(treeNode);
        }
        /*
         * DoDrop
         */

        /// <summary>
        /// Invokes service specific nodes merge operation.
        /// </summary>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="selectedNodes"/> is <see langword="null"/>.</exception>
        public override void DoDrop(NuGenTreeNode targetTreeNode, List <NuGenTreeNode> selectedNodes, NuGenDropPosition dropPosition)
        {
            if (selectedNodes == null)
            {
                throw new ArgumentNullException("selectedNodes");
            }

            if (
                targetTreeNode == null ||
                this.CheckSelectedContainTarget(targetTreeNode, selectedNodes) ||
                !this.CheckParent(targetTreeNode, selectedNodes)
                )
            {
                return;
            }

            switch (dropPosition)
            {
            case NuGenDropPosition.After:
            case NuGenDropPosition.Before:
            {
                this.MoveNodes(targetTreeNode, selectedNodes, dropPosition);
                break;
            }

            case NuGenDropPosition.Inside:
            {
                this.InsertNodes(targetTreeNode, this.RetrieveInsertable(selectedNodes));
                break;
            }
            }
        }
Exemplo n.º 3
0
            /*
             * Add
             */

            private void Add(TreeNode parent)
            {
                string   nodeText = Resources.Text_TreeNodeCollectionEditor_node;
                TreeNode node     = new NuGenTreeNode(nodeText + _nextNodeIndex.ToString(CultureInfo.InvariantCulture));

                node.Name = node.Text;

                if (parent == null)
                {
                    _treeView.Nodes.Add(node);
                }
                else
                {
                    parent.Nodes.Add(node);
                    parent.Expand();
                }

                _nextNodeIndex++;

                if (parent != null)
                {
                    _treeView.SelectedNode = parent;
                }
                else
                {
                    _treeView.SelectedNode = node;
                    this.SetNodeProps(node);
                }
            }
            /*
             * Add
             */

            private void Add(TreeNode parent)
            {
                TreeNode node = null;

                string nodeText = Resources.Text_TreeNodeCollectionEditor_node;

                if (parent == null)
                {
                    int num1;
                    this.NextNode = (num1 = this.NextNode) + 1;
                    int num2 = num1;
                    node = new NuGenTreeNode(nodeText + num2.ToString(CultureInfo.InvariantCulture));
                    _treeView.Nodes.Add(node);
                    node.Name = node.Text;
                }
                else
                {
                    int num3;
                    this.NextNode = (num3 = this.NextNode) + 1;
                    int num4 = num3;
                    node = new NuGenTreeNode(nodeText + num4.ToString(CultureInfo.InvariantCulture));
                    parent.Nodes.Add(node);
                    node.Name = node.Text;
                    parent.Expand();
                }
                if (parent != null)
                {
                    _treeView.SelectedNode = parent;
                }
                else
                {
                    _treeView.SelectedNode = node;
                    this.SetNodeProps(node);
                }
            }
Exemplo n.º 5
0
        /// <summary>
        /// </summary>
        /// <param name="treeNodeToCheck">Can be <see langword="null"/>.</param>
        /// <returns></returns>
        public bool Contains(NuGenTreeNode treeNodeToCheck)
        {
            NuGenContainsItemRequestedEventArgs eventArgs = new NuGenContainsItemRequestedEventArgs(treeNodeToCheck);

            this.OnContainsNodeRequested(eventArgs);
            return(eventArgs.ContainsNode);
        }
Exemplo n.º 6
0
        /// <summary>
        /// </summary>
        /// <param name="treeNodeToAdd"></param>
        /// <returns></returns>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="treeNodeToAdd"/> is <see langword="null"/>.
        /// </exception>
        public int AddNode(NuGenTreeNode treeNodeToAdd)
        {
            NuGenAddTreeNodeEventArgs eventArgs = new NuGenAddTreeNodeEventArgs(treeNodeToAdd);

            this.OnNodeAdded(eventArgs);
            return(eventArgs.TreeNodeIndex);
        }
Exemplo n.º 7
0
        public void ConstructorTest()
        {
            _treeNode = new NuGenTreeNode();

            Assert.AreEqual(-1, _treeNode.ImageIndex);
            Assert.AreEqual(-1, _treeNode.SelectedImageIndex);
            Assert.AreEqual(-1, _treeNode.ExpandedImageIndex);
            Assert.AreEqual("", _treeNode.Text);
            Assert.IsTrue(_treeNode.HasCheckBox);
            Assert.IsFalse(_treeNode.Checked);

            bool hasCheckBox = false;
            bool isChecked   = true;

            _treeNode = new NuGenTreeNode(
                _nodeText,
                hasCheckBox,
                isChecked,
                _imageIndex,
                _expandedImageIndex
                );

            Assert.AreEqual(_nodeText, _treeNode.Text);
            Assert.AreEqual(_imageIndex, _treeNode.ImageIndex);
            Assert.AreEqual(_imageIndex, _treeNode.SelectedImageIndex);
            Assert.AreEqual(_expandedImageIndex, _treeNode.ExpandedImageIndex);
            Assert.AreEqual(_imageIndex, _treeNode.DefaultImageIndex);
            Assert.IsFalse(_treeNode.HasCheckBox);
            Assert.IsTrue(_treeNode.Checked);
        }
Exemplo n.º 8
0
        public void ConstructorTest()
        {
            this.treeNode = new NuGenTreeNode();

            Assert.AreEqual(-1, this.treeNode.ImageIndex);
            Assert.AreEqual(-1, this.treeNode.SelectedImageIndex);
            Assert.AreEqual(-1, this.treeNode.ExpandedImageIndex);
            Assert.AreEqual("", this.treeNode.Text);
            Assert.IsTrue(this.treeNode.HasCheckBox);
            Assert.IsFalse(this.treeNode.Checked);

            string nodeText = "Node Text";

            int imageIndex         = 1;
            int expandedImageIndex = 2;

            bool hasCheckBox = false;
            bool isChecked   = true;

            this.treeNode = new NuGenTreeNode(
                nodeText,
                hasCheckBox,
                isChecked,
                imageIndex,
                expandedImageIndex
                );

            Assert.AreEqual(nodeText, this.treeNode.Text);
            Assert.AreEqual(imageIndex, this.treeNode.ImageIndex);
            Assert.AreEqual(imageIndex, this.treeNode.SelectedImageIndex);
            Assert.AreEqual(expandedImageIndex, this.treeNode.ExpandedImageIndex);
            Assert.AreEqual(imageIndex, this.treeNode.DefaultImageIndex);
            Assert.IsFalse(this.treeNode.HasCheckBox);
            Assert.IsTrue(this.treeNode.Checked);
        }
Exemplo n.º 9
0
		public void ConstructorTest()
		{
			_treeNode = new NuGenTreeNode();

			Assert.AreEqual(-1, _treeNode.ImageIndex);
			Assert.AreEqual(-1, _treeNode.SelectedImageIndex);
			Assert.AreEqual(-1, _treeNode.ExpandedImageIndex);
			Assert.AreEqual("", _treeNode.Text);
			Assert.IsTrue(_treeNode.HasCheckBox);
			Assert.IsFalse(_treeNode.Checked);

			bool hasCheckBox = false;
			bool isChecked = true;

			_treeNode = new NuGenTreeNode(
				_nodeText,
				hasCheckBox,
				isChecked,
				_imageIndex,
				_expandedImageIndex
			);

			Assert.AreEqual(_nodeText, _treeNode.Text);
			Assert.AreEqual(_imageIndex, _treeNode.ImageIndex);
			Assert.AreEqual(_imageIndex, _treeNode.SelectedImageIndex);
			Assert.AreEqual(_expandedImageIndex, _treeNode.ExpandedImageIndex);
			Assert.AreEqual(_imageIndex, _treeNode.DefaultImageIndex);
			Assert.IsFalse(_treeNode.HasCheckBox);
			Assert.IsTrue(_treeNode.Checked);
		}
Exemplo n.º 10
0
		public void ConstructorTest()
		{
			this.treeNode = new NuGenTreeNode();

			Assert.AreEqual(-1, this.treeNode.ImageIndex);
			Assert.AreEqual(-1, this.treeNode.SelectedImageIndex);
			Assert.AreEqual(-1, this.treeNode.ExpandedImageIndex);
			Assert.AreEqual("", this.treeNode.Text);
			Assert.IsTrue(this.treeNode.HasCheckBox);
			Assert.IsFalse(this.treeNode.Checked);

			string nodeText = "Node Text";
			
			int imageIndex = 1;
			int expandedImageIndex = 2;

			bool hasCheckBox = false;
			bool isChecked = true;

			this.treeNode = new NuGenTreeNode(
				nodeText,
				hasCheckBox,
				isChecked,
				imageIndex,
				expandedImageIndex
			);

			Assert.AreEqual(nodeText, this.treeNode.Text);
			Assert.AreEqual(imageIndex, this.treeNode.ImageIndex);
			Assert.AreEqual(imageIndex, this.treeNode.SelectedImageIndex);
			Assert.AreEqual(expandedImageIndex, this.treeNode.ExpandedImageIndex);
			Assert.AreEqual(imageIndex, this.treeNode.DefaultImageIndex);
			Assert.IsFalse(this.treeNode.HasCheckBox);
			Assert.IsTrue(this.treeNode.Checked);
		}
Exemplo n.º 11
0
        /*
         * AddFolder
         */

        /// <summary>
        /// </summary>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="folderNodeToAdd"/> is <see langword="null"/>.
        /// </exception>
        public void AddFolder(NuGenFolderTreeNode folderNodeToAdd)
        {
            if (folderNodeToAdd == null)
            {
                throw new ArgumentNullException("folderNodeToAdd");
            }

            NuGenTreeNode selectedNode = (NuGenTreeNode)this.SelectedNode;

            if (selectedNode != null && selectedNode.Parent != null)
            {
                if (
                    selectedNode.Parent is NuGenTaskTreeNodeBase &&
                    ((NuGenTaskTreeNodeBase)selectedNode.Parent).IsRemovable
                    )
                {
                    selectedNode.Parent.Nodes.AddNode(folderNodeToAdd);
                }
                else
                {
                    this.Nodes.AddNode(folderNodeToAdd);
                }
            }
            else
            {
                this.Nodes.AddNode(folderNodeToAdd);
            }

            this.SelectedNode = folderNodeToAdd;
            this.OnFolderAdded(EventArgs.Empty);
            this.OnEventToBeDelayed(new NuGenTaskAddedEventArgs(folderNodeToAdd.Text));
        }
Exemplo n.º 12
0
        public void SetUp()
        {
            this.dragService = new NuGenTreeViewDragDropService();
            this.treeView    = new NuGenTreeView();
            this.treeNode    = new NuGenTreeNode();

            this.treeView.Nodes.Add(this.treeNode);
        }
		public void SetUp()
		{
			this.dragService = new NuGenTreeViewDragDropService();
			this.treeView = new NuGenTreeView();
			this.treeNode = new NuGenTreeNode();

			this.treeView.Nodes.Add(this.treeNode);
		}
Exemplo n.º 14
0
        public void ContainsTest()
        {
            NuGenTreeNode treeNodeToCheck = new NuGenTreeNode();

            this.treeNode.Nodes.AddNode(treeNodeToCheck);
            Assert.IsTrue(this.treeNode.Nodes.Contains(treeNodeToCheck));
            Assert.IsFalse(this.treeNode.Nodes.Contains(null));
        }
			public TreeNodeCollectionHandler(NuGenTreeNode treeNode)
			{
				if (treeNode == null)
				{
					Assert.Fail("treeNode cannot be null.");
				}

				this.treeNode = treeNode;
			}
Exemplo n.º 16
0
            public TreeNodeCollectionHandler(NuGenTreeNode treeNode)
            {
                if (treeNode == null)
                {
                    Assert.Fail("treeNode cannot be null.");
                }

                this.treeNode = treeNode;
            }
Exemplo n.º 17
0
        private void _samplesTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.SuspendLayout();

            NuGenTreeNode treeNode = e.Node as NuGenTreeNode;

            if (treeNode != null)
            {
                SampleDescriptor sampleDescriptor = treeNode.Tag as SampleDescriptor;

                if (sampleDescriptor != null)
                {
                    _runButton.Enabled      = sampleDescriptor.ExeIsAvailable;
                    _csSampleButton.Enabled = sampleDescriptor.CsProjectIsAvailable;
                    _vbSampleButton.Enabled = sampleDescriptor.VbProjectIsAvailable;
                    _browseButton.Enabled   = sampleDescriptor.SamplePath != null;

                    _exePath       = sampleDescriptor.ExePath;
                    _csProjectPath = sampleDescriptor.CsProjectPath;
                    _vbProjectPath = sampleDescriptor.VbProjectPath;
                    _samplePath    = sampleDescriptor.SamplePath;

                    if (sampleDescriptor.DescriptionIsAvailable)
                    {
                        using (StreamReader sr = new StreamReader(sampleDescriptor.DescriptionPath))
                        {
                            try
                            {
                                _descriptionTextBox.Text = sr.ReadToEnd();
                            }
                            catch (IOException)
                            {
                                _descriptionTextBox.Text = "";
                            }
                            catch (OutOfMemoryException)
                            {
                                _descriptionTextBox.Text = "";
                            }
                        }
                    }

                    if (sampleDescriptor.ImageIsAvailable)
                    {
                        if (_imagePictureBox.Image != null)
                        {
                            _imagePictureBox.Image.Dispose();
                            _imagePictureBox.Image = null;
                        }

                        _imagePictureBox.Image = Image.FromFile(sampleDescriptor.ImagePath);
                    }
                }
            }

            this.ResumeLayout();
        }
Exemplo n.º 18
0
        public void DeleteTaskTest()
        {
            NuGenTreeNode treeNode = new NuGenTreeNode();

            this._TaskTreeView.Nodes.AddNode(treeNode);
            Assert.AreEqual(this._InitialCount + 1, this._TaskTreeView.Nodes.Count);

            this._TaskTreeView.DeleteTask(treeNode);
            Assert.AreEqual(this._InitialCount, this._TaskTreeView.Nodes.Count);
        }
		public void FirstNodeInvalidExceptionTest()
		{
			TreeNode firstNode = new TreeNode();
			NuGenTreeNode secondNode = new NuGenTreeNode();

			(this.treeNode as TreeNode).Nodes.Add(firstNode);
			this.treeNode.Nodes.AddNode(secondNode);

			Assert.IsNotNull(this.treeNode.FirstNode);
		}
Exemplo n.º 20
0
        public void FirstNodeTest()
        {
            NuGenTreeNode firstNode  = new NuGenTreeNode();
            NuGenTreeNode secondNode = new NuGenTreeNode();

            this.treeNode.Nodes.AddNode(firstNode);
            this.treeNode.Nodes.AddNode(secondNode);

            Assert.AreEqual(firstNode, this.treeNode.FirstNode);
        }
		public void FirstNodeTest()
		{
			NuGenTreeNode firstNode = new NuGenTreeNode();
			NuGenTreeNode secondNode = new NuGenTreeNode();

			this.treeNode.Nodes.AddNode(firstNode);
			this.treeNode.Nodes.AddNode(secondNode);

			Assert.AreEqual(firstNode, this.treeNode.FirstNode);
		}
Exemplo n.º 22
0
        public void FirstNodeInvalidExceptionTest()
        {
            TreeNode      firstNode  = new TreeNode();
            NuGenTreeNode secondNode = new NuGenTreeNode();

            (this.treeNode as TreeNode).Nodes.Add(firstNode);
            this.treeNode.Nodes.AddNode(secondNode);

            Assert.IsNotNull(this.treeNode.FirstNode);
        }
Exemplo n.º 23
0
        /// <summary>
        /// </summary>
        /// <param name="serviceProvider"><para>Requires:</para>
        ///     <para><see cref="ISampleFolder"/></para></param>
        /// <param name="treeView"></param>
        /// <param name="folderImageIndex"></param>
        /// <param name="expandedFolderImageIndex"></param>
        /// <param name="sampleImageIndex"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="serviceProvider"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="treeView"/> is <see langword="null"/>.</para>
        /// </exception>
        public void PopulateSampleTree(
            INuGenServiceProvider serviceProvider
            , NuGenTreeView treeView
            , int folderImageIndex
            , int expandedFolderImageIndex
            , int sampleImageIndex
            )
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            if (treeView == null)
            {
                throw new ArgumentNullException("treeView");
            }

            ISampleFolderDescriptor sampleFolder = serviceProvider.GetService <ISampleFolderDescriptor>();

            Debug.Assert(sampleFolder != null, "sampleFolder != null");

            DirectoryInfo sampleDirInfo = new DirectoryInfo(sampleFolder.Path);

            Debug.Write("Scanning \"");
            Debug.Write(sampleDirInfo.FullName);
            Debug.WriteLine("\" folder...");

            if (!sampleDirInfo.Exists)
            {
                Trace.Write("Sample directory does not exist.");
                return;
            }

            DirectoryInfo[] samples = sampleDirInfo.GetDirectories();
            Debug.WriteLine("Getting the list of sub-directories...");
            Debug.WriteLineIf(samples != null, "samples.Length = " + samples.Length.ToString());

            if (samples != null)
            {
                Debug.WriteLine("Looping through the sub-directories...");

                foreach (DirectoryInfo dirInfo in samples)
                {
                    NuGenTreeNode treeNode = new NuGenTreeNode(dirInfo.Name, folderImageIndex, expandedFolderImageIndex);
                    treeView.Nodes.Add(treeNode);

                    Debug.Write("Examining \"");
                    Debug.Write(dirInfo.FullName);
                    Debug.WriteLine("\" sub-directory...");

                    this.BuildSampleTreeNode(sampleFolder, dirInfo, treeNode, folderImageIndex, expandedFolderImageIndex, sampleImageIndex);
                }
            }
        }
Exemplo n.º 24
0
        public void IndexerTest()
        {
            NuGenTreeNode childNode  = new NuGenTreeNode();
            NuGenTreeNode childNode2 = new NuGenTreeNode();

            this.treeNode.Nodes.AddNode(childNode);
            this.treeNode.Nodes.AddNode(childNode2);

            Assert.AreEqual(childNode, this.treeNode.Nodes[0]);
            Assert.AreEqual(childNode2, this.treeNode.Nodes[1]);
        }
Exemplo n.º 25
0
        public void RemoveSelectedNodeTest()
        {
            NuGenTreeNode node = new NuGenTreeNode();

            this.selectionService.AddSelectedNode(node, Keys.None, MouseButtons.Left);
            this.selectionService.RemoveSelectedNode(node);

            Assert.AreEqual(0, this.selectionService.SelectedNodes.Count);

            this.selectionService.RemoveSelectedNode(null);
        }
Exemplo n.º 26
0
 /// <summary>
 /// </summary>
 /// <param name="treeNodeToRemove"></param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="treeNodeToRemove"/> is <see langword="null"/>.
 /// </exception>
 public void RemoveNode(NuGenTreeNode treeNodeToRemove)
 {
     if (treeNodeToRemove == null)
     {
         throw new ArgumentNullException("treeNodeToRemove");
     }
     else
     {
         this.OnNodeRemoved(new NuGenRemoveTreeNodeEventArgs(treeNodeToRemove));
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// </summary>
 /// <param name="indexToInsertAt"></param>
 /// <param name="treeNodeToInsert"></param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="treeNodeToInsert"/> is <see langword="null"/>.
 /// </exception>
 public void InsertNode(int indexToInsertAt, NuGenTreeNode treeNodeToInsert)
 {
     if (treeNodeToInsert == null)
     {
         throw new ArgumentNullException("treeNodeToInsert");
     }
     else
     {
         this.OnNodeInserted(new NuGenAddTreeNodeEventArgs(treeNodeToInsert, indexToInsertAt));
     }
 }
Exemplo n.º 28
0
		public void SetUp()
		{
			_treeView = new NuGenTreeView();
			_treeNode = new NuGenTreeNode("Root", false);

			_nodes = new NuGenTreeNode[] {
				new NuGenTreeNode(),
				new NuGenTreeNode(),
				new NuGenTreeNode()
			};
		}
Exemplo n.º 29
0
        public void SetUp()
        {
            _treeView = new NuGenTreeView();
            _treeNode = new NuGenTreeNode("Root", false);

            _nodes = new NuGenTreeNode[] {
                new NuGenTreeNode(),
                new NuGenTreeNode(),
                new NuGenTreeNode()
            };
        }
Exemplo n.º 30
0
        public void AddRangeTest()
        {
            NuGenTreeNode node  = new NuGenTreeNode();
            NuGenTreeNode node2 = new NuGenTreeNode();

            NuGenTreeNode[] treeNodeRange = new NuGenTreeNode[] { node, node2 };

            this.treeNode.Nodes.AddNodeRange(treeNodeRange);

            Assert.AreEqual(2, this.treeNode.Nodes.Count);
            Assert.AreEqual(node, this.treeNode.Nodes[0]);
            Assert.AreEqual(node2, this.treeNode.Nodes[1]);
        }
Exemplo n.º 31
0
        public void InsideTaskDoDropTest()
        {
            NuGenTreeNode sourceNode = this._TaskTreeView.Nodes[1];

            List <NuGenTreeNode> selectedNodes = new List <NuGenTreeNode>();

            selectedNodes.Add(sourceNode);

            this._DropService.DoDrop(this._TaskTreeView.Nodes[13], selectedNodes, NuGenDropPosition.Inside);

            Assert.AreEqual(this._InitialCount + 20, this._TaskTreeView.Nodes.Count);
            Assert.AreEqual(10, sourceNode.Nodes.Count);
        }
Exemplo n.º 32
0
		public void Constructor2Test()
		{
			NuGenTreeNode treeNode = new NuGenTreeNode(_nodeText, _nodes);
			Assert.AreEqual(3, treeNode.Nodes.Count);

			try
			{
				treeNode = new NuGenTreeNode(_nodeText, null);
				Assert.Fail();
			}
			catch (ArgumentNullException)
			{
			}
		}
Exemplo n.º 33
0
        public void MultilevelShiftSelectionTest()
        {
            Keys         pressedKeys         = Keys.Shift;
            MouseButtons pressedMouseButtons = MouseButtons.Left;

            NuGenTreeNode node  = this.treeView.Nodes[0].Nodes[2];
            NuGenTreeNode node2 = this.treeView.Nodes[1].Nodes[3];

            this.selectionService.AddSelectedNode(node, pressedKeys, pressedMouseButtons);
            this.selectionService.AddSelectedNode(node2, pressedKeys, pressedMouseButtons);

            Assert.AreEqual(1, this.selectionService.SelectedNodes.Count);
            Assert.AreEqual(node, this.selectionService.SelectedNodes[0]);
        }
Exemplo n.º 34
0
        public void SimpleControlSelectionTest()
        {
            Keys         pressedKeys         = Keys.Control;
            MouseButtons pressedMouseButtons = MouseButtons.Left;

            NuGenTreeNode node  = this.treeView.Nodes[0];
            NuGenTreeNode node2 = this.treeView.Nodes[5];

            this.selectionService.AddSelectedNode(node, pressedKeys, pressedMouseButtons);
            this.selectionService.AddSelectedNode(node2, pressedKeys, pressedMouseButtons);

            Assert.AreEqual(2, this.selectionService.SelectedNodes.Count);
            Assert.AreEqual(node, this.selectionService.SelectedNodes[0]);
            Assert.AreEqual(node2, this.selectionService.SelectedNodes[1]);
        }
Exemplo n.º 35
0
        public void Constructor3Test()
        {
            NuGenTreeNode treeNode = new NuGenTreeNode(_nodeText, _imageIndex, _expandedImageIndex, _nodes);

            Assert.AreEqual(3, treeNode.Nodes.Count);

            try
            {
                treeNode = new NuGenTreeNode(_nodeText, _imageIndex, _expandedImageIndex, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
            }
        }
Exemplo n.º 36
0
        public void NoneKeysClearsSelection()
        {
            Keys         pressedKeys         = Keys.Shift;
            MouseButtons pressedMouseButtons = MouseButtons.Left;

            this.selectionService.AddSelectedNode(this.treeView.Nodes[0], pressedKeys, pressedMouseButtons);
            this.selectionService.AddSelectedNode(this.treeView.Nodes[3], pressedKeys, pressedMouseButtons);

            NuGenTreeNode node = this.treeView.Nodes[4];

            this.selectionService.AddSelectedNode(node, Keys.None, pressedMouseButtons);

            Assert.AreEqual(1, this.selectionService.SelectedNodes.Count);
            Assert.AreEqual(node, this.selectionService.SelectedNodes[0]);
        }
        public void AfterDoDropTest()
        {
            NuGenTreeNode sourceNode = this._TaskTreeView.Nodes[1];

            List <NuGenTreeNode> selectedNodes = new List <NuGenTreeNode>();

            selectedNodes.Add(sourceNode);

            NuGenTreeNode targetNode = this._TaskTreeView.Nodes[2];

            this._DropService.DoDrop(targetNode, selectedNodes, NuGenDropPosition.After);

            Assert.AreEqual(1, targetNode.Index);
            Assert.AreEqual(3, sourceNode.Index);
        }
Exemplo n.º 38
0
        public void ParentNullInsideFolderDoDropTest()
        {
            List <NuGenTreeNode> selectedNodes = new List <NuGenTreeNode>();

            for (int i = 10; i < 13; i++)
            {
                selectedNodes.Add(this._TaskTreeView.Nodes[i]);
            }

            NuGenTreeNode targetNode = this._TaskTreeView.Nodes[1];

            this._DropService.DoDrop(targetNode, selectedNodes, NuGenDropPosition.Inside);

            Assert.AreEqual(this._InitialCount + 17, this._TaskTreeView.Nodes.Count);
            Assert.AreEqual(13, targetNode.Nodes.Count);
        }
		public void EventTest()
		{
			TreeNodeCollectionEventSink eventSink = new TreeNodeCollectionEventSink(this.treeNodeCollection);

			NuGenTreeNode toAddNode = new NuGenTreeNode();
			NuGenTreeNode toInsertNode = new NuGenTreeNode();

			eventSink.ExpectedClearRequestedCount = 1;
			eventSink.ExpectedContainsNodeRequestedCount = 2;
			eventSink.ExpectedCountRequestedCount = 1;
			eventSink.ExpectedEnumeratorRequestsCount = 1;
			eventSink.ExpectedNodeByIndexAdjustedCount = 1;
			eventSink.ExpectedNodeByIndexRequestedCount = 1;
			eventSink.ExpectedNodeAddedCount = 2;
			eventSink.ExpectedNodeRangeAddedCount = 1;
			eventSink.ExpectedNodeInsertedCount = 1;
			eventSink.ExpectedNodeRemovedCount = 2;

			eventSink.AddExpectedContainsNodeRequested(toAddNode);
			eventSink.AddExpectedContainsNodeRequested(toInsertNode);
			eventSink.AddExpectedNodeAdded(toAddNode);
			eventSink.AddExpectedNodeAdded(toInsertNode);
			eventSink.AddExpectedNodeAdded(toAddNode);
			eventSink.AddExpectedNodeRangeAdded(new NuGenTreeNode[] { toAddNode, toInsertNode });

			eventSink.AddExpectedNodeRemoved(toAddNode);
			eventSink.AddExpectedNodeRemoved(toInsertNode);

			this.treeNodeCollection.AddNode(toAddNode);
			this.treeNodeCollection.InsertNode(0, toInsertNode);
			this.treeNodeCollection.AddNode(toAddNode);
			this.treeNodeCollection.AddNodeRange(new NuGenTreeNode[] { toAddNode, toInsertNode });
			this.treeNodeCollection.RemoveNode(toAddNode);
			this.treeNodeCollection.RemoveNode(toInsertNode);
			this.treeNodeCollection.GetEnumerator();
			this.treeNodeCollection.Contains(toAddNode);
			this.treeNodeCollection.Contains(toInsertNode);

			Assert.AreEqual(0, this.treeNodeCollection.Count);
			Assert.AreEqual(null, this.treeNodeCollection[0]);
			this.treeNodeCollection[0] = null;

			this.treeNodeCollection.Clear();

			eventSink.Verify();
		}
		public static void PopulateMultilevel(NuGenTreeView treeViewToPopulate, int levelCount, int nodeCount)
		{
			if (treeViewToPopulate == null)
			{
				Assert.Fail("treeViewToPopulate cannot be null.");
			}

			for (int level = 0; level < levelCount; level++)
			{
				NuGenTreeNode treeNode = new NuGenTreeNode();
				treeViewToPopulate.Nodes.Add(treeNode);

				for (int node = 0; node < nodeCount; node++)
				{
					treeNode.Nodes.Add(new NuGenTreeNode());
				}
			}
		}
		public void CompareTest()
		{
			NuGenTreeNode mTreeNode = new NuGenTreeNode("m");
			NuGenTreeNode dTreeNode = new NuGenTreeNode("d");
			NuGenTreeNode cTreeNode = new NuGenTreeNode("c");
			NuGenTreeNode kTreeNode = new NuGenTreeNode("k");

			int mTodCompareResult = mTreeNode.Text.CompareTo(dTreeNode.Text);
			int kTomCompareResult = kTreeNode.Text.CompareTo(mTreeNode.Text);
			int dTocCompareResult = dTreeNode.Text.CompareTo(cTreeNode.Text);

			Assert.Greater(mTodCompareResult, 0);
			Assert.Less(kTomCompareResult, 0);
			Assert.Greater(dTocCompareResult, 0);

			Assert.AreEqual(mTodCompareResult, this.comparer.Compare(mTreeNode, dTreeNode));
			Assert.AreEqual(kTomCompareResult, this.comparer.Compare(kTreeNode, mTreeNode));
			Assert.AreEqual(dTocCompareResult, this.comparer.Compare(dTreeNode, cTreeNode));
		}
		public void AZSortTest()
		{
			NuGenTreeNode mTreeNode = new NuGenTreeNode("m");
			NuGenTreeNode dTreeNode = new NuGenTreeNode("d");
			NuGenTreeNode cTreeNode = new NuGenTreeNode("c");
			NuGenTreeNode kTreeNode = new NuGenTreeNode("k");

			this.treeView.Nodes.AddNode(mTreeNode);
			this.treeView.Nodes.AddNode(dTreeNode);
			this.treeView.Nodes.AddNode(cTreeNode);
			this.treeView.Nodes.AddNode(kTreeNode);

			Assert.AreEqual(mTreeNode, this.treeView.Nodes[0]);
			Assert.AreEqual(dTreeNode, this.treeView.Nodes[1]);
			Assert.AreEqual(cTreeNode, this.treeView.Nodes[2]);
			Assert.AreEqual(kTreeNode, this.treeView.Nodes[3]);

			this.sorter.Sort(this.treeView.Nodes, new NuGenAZTreeNodeComparer());

			Assert.AreEqual(cTreeNode, this.treeView.Nodes[0]);
			Assert.AreEqual(dTreeNode, this.treeView.Nodes[1]);
			Assert.AreEqual(kTreeNode, this.treeView.Nodes[2]);
			Assert.AreEqual(mTreeNode, this.treeView.Nodes[3]);
		}
			/*
			 * Add
			 */

			private void Add(TreeNode parent)
			{
				TreeNode node = null;

				string nodeText = Resources.Text_TreeNodeCollectionEditor_node;

				if (parent == null)
				{
					int num1;
					this.NextNode = (num1 = this.NextNode) + 1;
					int num2 = num1;
					node = new NuGenTreeNode(nodeText + num2.ToString(CultureInfo.InvariantCulture));
					_treeView.Nodes.Add(node);
					node.Name = node.Text;
				}
				else
				{
					int num3;
					this.NextNode = (num3 = this.NextNode) + 1;
					int num4 = num3;
					node = new NuGenTreeNode(nodeText + num4.ToString(CultureInfo.InvariantCulture));
					parent.Nodes.Add(node);
					node.Name = node.Text;
					parent.Expand();
				}
				if (parent != null)
				{
					_treeView.SelectedNode = parent;
				}
				else
				{
					_treeView.SelectedNode = node;
					this.SetNodeProps(node);
				}
			}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenIndexedTreeNodeEventArgs"/> class.
		/// </summary>
		public NuGenIndexedTreeNodeEventArgs(int treeNodeIndex, NuGenTreeNode treeNode)
		{
			this.treeNodeIndex = treeNodeIndex;
			this.treeNode = treeNode;
		}
		public void ContainsTest()
		{
			NuGenTreeNode treeNodeToCheck = new NuGenTreeNode();
			this.treeNode.Nodes.AddNode(treeNodeToCheck);
			Assert.IsTrue(this.treeNode.Nodes.Contains(treeNodeToCheck));
			Assert.IsFalse(this.treeNode.Nodes.Contains(null));
		}
		/// <summary>
		/// </summary>
		/// <param name="indexToInsertAt"></param>
		/// <param name="treeNodeToInsert"></param>
		/// <exception cref="T:System.ArgumentNullException">
		/// <paramref name="treeNodeToInsert"/> is <see langword="null"/>.
		/// </exception>
		public void InsertNode(int indexToInsertAt, NuGenTreeNode treeNodeToInsert)
		{
			if (treeNodeToInsert == null)
			{
				throw new ArgumentNullException("treeNodeToInsert");
			}
			else
			{
				this.OnNodeInserted(new NuGenAddTreeNodeEventArgs(treeNodeToInsert, indexToInsertAt));
			}
		}
		/// <summary>
		/// </summary>
		/// <param name="treeNodeToRemove"></param>
		/// <exception cref="T:System.ArgumentNullException">
		/// <paramref name="treeNodeToRemove"/> is <see langword="null"/>.
		/// </exception>
		public void RemoveNode(NuGenTreeNode treeNodeToRemove)
		{
			if (treeNodeToRemove == null)
			{
				throw new ArgumentNullException("treeNodeToRemove");
			}
			else
			{
				this.OnNodeRemoved(new NuGenRemoveTreeNodeEventArgs(treeNodeToRemove));
			}
		}
		/// <summary>
		/// </summary>
		/// <exception cref="T:System.ArgumentNullException">
		/// <paramref name="treeNodeRangeToAdd"/> is <see langword="null"/>.
		/// </exception>
		public void AddNodeRange(NuGenTreeNode[] treeNodeRangeToAdd)
		{
			this.OnNodeRangeAdded(new NuGenAddTreeNodeRangeEventArgs(treeNodeRangeToAdd));
		}
		/// <summary>
		/// </summary>
		/// <param name="treeNodeToCheck">Can be <see langword="null"/>.</param>
		/// <returns></returns>
		public bool Contains(NuGenTreeNode treeNodeToCheck)
		{
			NuGenContainsItemRequestedEventArgs eventArgs = new NuGenContainsItemRequestedEventArgs(treeNodeToCheck);
			this.OnContainsNodeRequested(eventArgs);
			return eventArgs.ContainsNode;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenAddTreeNodeEventArgs"/> class.<para/>
		/// TreeNodeIndex = 0.
		/// </summary>
		public NuGenAddTreeNodeEventArgs(NuGenTreeNode treeNodeToAdd)
			: this(treeNodeToAdd, 0)
		{
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenContainsItemRequestedEventArgs"/> class.
		/// </summary>
		public NuGenContainsItemRequestedEventArgs(NuGenTreeNode nodeToCheck)
		{
			this.nodeToCheck = nodeToCheck;
		}
		public void RemoveSelectedNodeTest()
		{
			NuGenTreeNode node = new NuGenTreeNode();
			this.selectionService.AddSelectedNode(node, Keys.None, MouseButtons.Left);
			this.selectionService.RemoveSelectedNode(node);

			Assert.AreEqual(0, this.selectionService.SelectedNodes.Count);

			this.selectionService.RemoveSelectedNode(null);
		}
		public void AddRangeTest()
		{
			NuGenTreeNode node = new NuGenTreeNode();
			NuGenTreeNode node2 = new NuGenTreeNode();

			NuGenTreeNode[] treeNodeRange = new NuGenTreeNode[] { node, node2 };

			this.treeNode.Nodes.AddNodeRange(treeNodeRange);

			Assert.AreEqual(2, this.treeNode.Nodes.Count);
			Assert.AreEqual(node, this.treeNode.Nodes[0]);
			Assert.AreEqual(node2, this.treeNode.Nodes[1]);
		}
Exemplo n.º 54
0
		public void SetUp()
		{
			this.treeView = new NuGenTreeView();
			this.treeNode = new NuGenTreeNode("Root", false);
		}
			public void AddExpectedNodeRemoved(NuGenTreeNode treeNode)
			{
				this.nodeRemoved.AddExpected(treeNode);
			}
			public void AddExpectedContainsNodeRequested(NuGenTreeNode treeNode)
			{
				this.containsNodeRequested.AddExpected(treeNode);
			}
			/*
			 * Add
			 */

			private void Add(TreeNode parent)
			{
				string nodeText = Resources.Text_TreeNodeCollectionEditor_node;
				TreeNode node = new NuGenTreeNode(nodeText + _nextNodeIndex.ToString(CultureInfo.InvariantCulture));
				node.Name = node.Text;

				if (parent == null)
				{
					_treeView.Nodes.Add(node);
				}
				else
				{
					parent.Nodes.Add(node);
					parent.Expand();
				}

				_nextNodeIndex++;

				if (parent != null)
				{
					_treeView.SelectedNode = parent;
				}
				else
				{
					_treeView.SelectedNode = node;
					this.SetNodeProps(node);
				}
			}
		/// <summary>
		/// </summary>
		/// <param name="treeNodeToAdd"></param>
		/// <returns></returns>
		/// <exception cref="T:System.ArgumentNullException">
		/// <paramref name="treeNodeToAdd"/> is <see langword="null"/>.
		/// </exception>
		public int AddNode(NuGenTreeNode treeNodeToAdd)
		{
			NuGenAddTreeNodeEventArgs eventArgs = new NuGenAddTreeNodeEventArgs(treeNodeToAdd);
			this.OnNodeAdded(eventArgs);
			return eventArgs.TreeNodeIndex;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenAddTreeNodeEventArgs"/> class.
		/// </summary>
		public NuGenAddTreeNodeEventArgs(NuGenTreeNode treeNodeToAdd, int treeNodeIndex)
		{
			_treeNodeToAdd = treeNodeToAdd;
			_treeNodeIndex = treeNodeIndex;
		}
		public void IndexerTest()
		{
			NuGenTreeNode childNode = new NuGenTreeNode();
			NuGenTreeNode childNode2 = new NuGenTreeNode();

			this.treeNode.Nodes.AddNode(childNode);
			this.treeNode.Nodes.AddNode(childNode2);

			Assert.AreEqual(childNode, this.treeNode.Nodes[0]);
			Assert.AreEqual(childNode2, this.treeNode.Nodes[1]);
		}