Exemple #1
0
        /// <summary>
        /// Eine vorher Exportierte Xml Datei wieder in ein TreeView importieren
        /// </summary>
        /// <param name="path">Der Quellpfad der Xml Datei</param>
        /// <param name="treeView">Ein TreeView in dem der Inhalt der Xml Datei wieder angezeigt werden soll</param>
        /// <exception cref="FileNotFoundException">gibt an das die Datei nicht gefunden werden konnte</exception>
        public void XmlToTreeView(String path, TreeView treeView) {
            xmlDocument = new XmlDocument();
            
            xmlDocument.Load(path);
            treeView.Nodes.Clear();
            ElementList = new ArrayList();

            TreeNode treeNode;
            treeNode = new TreeNode("skin");
            treeView.Nodes.Add(treeNode);

            rootNode = treeNode.GetHashCode();
            sElementList element = new sElementList(rootNode, 0, treeNode, xmlDocument.DocumentElement/*.ParentNode*/);
            ElementList.Add(element);
            

            XmlRekursivImport(treeNode.Nodes, xmlDocument.DocumentElement.ChildNodes);
        }
Exemple #2
0
        /// <summary>
        /// Checks if the TreeNode supplied is disabled or not.
        /// Note that passing in null as the TreeNode will result in false being returned.
        /// Note that being disabled means that BackColor and ForeColor has changed to give the TreeNode the appearance of being disabled.
        ///		A whole TreeView can be disabled without the particular TreeNode supplied to this function returning true (as in being disabled).
        /// </summary>
        /// <param name="tn">TreeNode that should be checked if it is disabled or not.</param>
        /// <returns>True if supplied TreeNode is disabled or false otherwise.</returns>
        public bool IsTreeNodeDisabled(TreeNode tn)
        {
            bool bRetVal = false;

            if(tn != null)
            {
                if(htDisabledTreeNodes != null)
                {
                    if(htDisabledTreeNodes.Contains(tn.GetHashCode()))
                    {
                        bRetVal = true;
                    }
                }
            }

            return bRetVal;
        }
Exemple #3
0
        /// <summary>
        /// Get the MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Disabled MWTreeNodeWrapper Hashtable.
        /// </summary>
        /// <param name="tn">TreeNode for which to return an MWTreeNodeWrapper.</param>
        /// <returns>The MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Disabled MWTreeNodeWrapper Hashtable or null otherwise.</returns>
        public MWTreeNodeWrapper GetDisabledMWTreeNodeWrapper(TreeNode tn)
        {
            MWTreeNodeWrapper mwtnw = null;

            if(IsTreeNodeDisabled(tn))
            {
                mwtnw = htDisabledTreeNodes[tn.GetHashCode()] as MWTreeNodeWrapper;
            }

            return mwtnw;
        }
Exemple #4
0
        /// <summary>
        /// Change the ForeColor of a TreeNode.
        /// This method handles selected as well as unselected TreeNodes.
        /// </summary>
        /// <param name="tn">TreeNode to change the ForeColor of.</param>
        /// <param name="cForeColor">Color to change the supplied TreeNode's ForeColor to.</param>
        public void ChangeForeColor(TreeNode tn, Color cForeColor)
        {
            if(tn != null)
            {
                if(this.IsTreeNodeSelected(tn))
                {
                    MWTreeNodeWrapper mwtnw = this.SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper;

                    if(mwtnw != null)
                    {
                        mwtnw.ForeColor = cForeColor;

                        if(	!this.Enabled && !this.UseExtendedDisabledColors ||
                            this.Enabled && (this.Focused || !this.HideSelection) ||
                            this.Enabled && !this.Focused && this.HideSelection)
                        {
                            mwtnw.Node.ForeColor = cForeColor;
                        }
                    }
                }
                else
                {
                    if(!this.Enabled)
                    {
                        MWTreeNodeWrapper mwtnw = GetDisabledMWTreeNodeWrapper(tn);

                        if(mwtnw != null)
                        {
                            mwtnw.Enable();

                            htDisabledTreeNodes.Remove(tn.GetHashCode());
                        }

                        tn.ForeColor = cForeColor;

                        DisableNode(tn);
                    }
                    else
                    {
                        tn.ForeColor = cForeColor;
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Remove a TreeNode to the SelNodes property.
        /// </summary>
        /// <param name="tn">TreeNode to remove from the SelNodes property.</param>
        /// <param name="bTriggerEvents">True if calling this method should raise the OnBeforeSelNodesRemove and OnAfterSelNodesRemove events or false otherwise.</param>
        /// <returns>True if the TreeNode is actually removed or false otherwise.</returns>
        private bool SelNodesRemove(TreeNode tn, bool bTriggerEvents)
        {
            bool bRetVal = false;

            if(this.IsTreeNodeSelected(tn))
            {
                MWCancelEventArgs e = new MWCancelEventArgs(this.SelNodes, tn);

                if(bTriggerEvents)
                {
                    OnBeforeSelNodesRemove(e);
                }

                if(!e.Cancel)
                {
                    MWTreeNodeWrapper.Deselect(this.SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper);

                    this.SelNodes.Remove(tn.GetHashCode());

                    if(bTriggerEvents)
                    {
                        OnAfterSelNodesRemove(new MWControlSuite.MWPropertyEventArgs(tn));
                    }

                    bRetVal = true;
                }
            }

            return bRetVal;
        }
Exemple #6
0
        /// <summary>
        /// Enable TreeNode supplied.
        /// </summary>
        /// <param name="tn">TreeNode to enable.</param>
        private void EnableNode(TreeNode tn)
        {
            MWTreeNodeWrapper mwtnw = GetDisabledMWTreeNodeWrapper(tn);

            if(mwtnw != null)
            {
                EnableNode(mwtnw);

                htDisabledTreeNodes.Remove(tn.GetHashCode());
            }
        }
Exemple #7
0
        /// <summary>
        /// Delete the supplied TreeNode from the SelNodes property, the CheckedNodes property and/or the SelNode property.
        /// </summary>
        /// <param name="tn">TreeNode to delete.</param>
        private void DeleteNode(TreeNode tn)
        {
            foreach(TreeNode tnChild in tn.Nodes)
            {
                DeleteNode(tnChild);
            }

            if(tn != null)
            {
                if(IsTreeNodeSelected(tn))
                {
                    if(this.SelNodes != null)
                    {
                        this.SelNodes.Remove(tn.GetHashCode());
                    }
                }

                if(IsTreeNodeChecked(tn))
                {
                    if(this.CheckedNodes != null)
                    {
                        this.CheckedNodes.Remove(tn.GetHashCode());
                    }
                }

                if(this.SelNode != null && this.SelNode == tn)
                {
                    this.SelNode = null;
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Remove a TreeNode to the CheckedNodes property.
        /// </summary>
        /// <param name="tn">TreeNode to remove from the CheckedNodes property.</param>
        /// <param name="bTriggerEvents">True if calling this method should raise the OnBeforeCheckedNodesAdd and OnAfterCheckedNodesAdd events or false otherwise.</param>
        /// <returns>True if the TreeNode is actually removed or false otherwise.</returns>
        private bool CheckedNodesRemove(TreeNode tn, bool bTriggerEvents)
        {
            bool bRetVal = false;

            if(this.IsTreeNodeChecked(tn))
            {
                MWCancelEventArgs e = new MWCancelEventArgs(this.CheckedNodes, tn);

                if(bTriggerEvents)
                {
                    OnBeforeCheckedNodesRemove(e);
                }

                if(!e.Cancel)
                {
                    this.CheckedNodes.Remove(tn.GetHashCode());

                    if(bTriggerEvents)
                    {
                        OnAfterCheckedNodesRemove(new MWControlSuite.MWPropertyEventArgs(tn));
                    }

                    bRetVal = true;
                }
            }

            return bRetVal;
        }
Exemple #9
0
        /// <summary>
        /// Function used to update the background color of the selected node in the treeview
        /// </summary>
        public bool HighlightPickedGeometryNode(TreeNode ViewNode, GeometryNode node)
        {
            if (ViewNode == null)
                return false;

            if (ViewNode.Text == "GeometryNode")
            {
                int key = ViewNode.GetHashCode();
                List<PropertyValue> pvlist = (List<PropertyValue>)PropertyValueTable[key];
                foreach (PropertyValue pv in pvlist)
                {
                    if (pv.Property == "ID" && pv.Value == node.ID.ToString())
                    {
                        ViewNode.BackColor = System.Drawing.Color.Blue;
                        return true;
                    }
                }
            }

            foreach (TreeNode ChildNode in ViewNode.Nodes)
            {
                if (HighlightPickedGeometryNode(ChildNode, node))
                    return true;
            }
            return false;
        }
Exemple #10
0
        /// <summary>
        /// Recursive Function for drawing the SceneGraph tree structure.
        /// </summary>
        private Pair EvenInorderTraverseTree(TreeNode Head, int depth, int[] index, Graphics formgraphics, Pen mypen, SolidBrush myBrush, float NodeWidth, float NodeHeight, float WidthBetweenNodes, float HeightBetweenNodes, float XOffset, float YOffset, bool textEnabled)
        {
            int max;
            // Determing the x-coordinate (index[depth]) at the current depth by examining the x-coordinate values at [depth-1] and [depth+1]
            if (depth > 0)
            {
                max = index[depth - 1] - 1;
            }
            else
            {
                max = index[depth];
            }
            max = (max < index[depth]) ? index[depth] : max;
            max = (max < index[depth + 1]) ? index[depth + 1] : max;
            index[depth] = max + 1;


            // High and low variables are used to store the extremities of the subtree starting from the current node.
            int high, low;
            if (Head.Nodes.Count > 0)
            {
                low = 10000; high = -1;
            }
            else
            {
                low = index[depth]; high = index[depth];
            }
            Pair[] retval = new Pair[Head.Nodes.Count];
            int counter = 0;
            foreach (TreeNode child in Head.Nodes)
            {
                retval[counter] = EvenInorderTraverseTree(child, depth + 1, index, formgraphics, mypen, myBrush, NodeWidth, NodeHeight, WidthBetweenNodes, HeightBetweenNodes, XOffset, YOffset, textEnabled);
                if (retval[counter].end > high)
                    high = retval[counter].end;
                if (retval[counter].start < low)
                    low = retval[counter].start;
                counter++;
            }

            // update the index[depth] (current x-coordinate)
            index[depth] = (high + low) / 2;
            mypen.Color = System.Drawing.Color.Black;

            for (int i = 0; i < counter; i++)
                formgraphics.DrawLine(mypen, new PointF(((high + low) / 2 * WidthBetweenNodes) + XOffset + NodeWidth / 2, (depth * HeightBetweenNodes) + YOffset + NodeHeight), new PointF(((retval[i].start + retval[i].end) / 2 * WidthBetweenNodes) + XOffset + NodeWidth / 2, ((depth + 1) * HeightBetweenNodes) + YOffset));

            // highlighting the node, if it is the currentselected node
            if (Head == CurrentSelectedTreeNode)
            {
                myBrush.Color = System.Drawing.Color.Black;
                formgraphics.FillRectangle(myBrush, ((high + low) / 2 * WidthBetweenNodes) + XOffset, (depth * HeightBetweenNodes) + YOffset, NodeWidth, NodeHeight);
            }

            // Coloring the nodes based on the node types
            myBrush.Color = SGNodeDefaultColor;
            for (int i = 0; i < SGNodeNames.Length; i++)
            {
                if (Head.Text.StartsWith(SGNodeNames[i]))
                {
                    myBrush.Color = SGNodeColors[i];
                    break;
                }
            }

            // if the node is either invisible (red) or currently selected node (blue) then use similar coloring of the geometry nodes even for the corresponding graphical display nodes
            if (Head.BackColor == System.Drawing.Color.Red || Head.BackColor == System.Drawing.Color.Blue)
            {
                myBrush.Color = Head.BackColor;
            }

            formgraphics.FillEllipse(myBrush, ((high + low) / 2 * WidthBetweenNodes) + XOffset, (depth * HeightBetweenNodes) + YOffset, NodeWidth, NodeHeight);

            // writing the string  "NodeName(NodeID)" on the graphical display node
            if (textEnabled)
            {
                string nodeString = "";
                int key = Head.GetHashCode();
                string nodeName = "", nodeID = null;
                List<PropertyValue> pvlist = (List<PropertyValue>)PropertyValueTable[key];
                foreach (PropertyValue pv in pvlist)
                {
                    if (pv.Property == "Name")
                    {
                        nodeName = pv.Value;
                    }
                    if (pv.Property == "ID")
                    {
                        nodeID = pv.Value;
                    }
                }
                nodeString = nodeName;
                if (nodeID != null)
                    nodeString += "(" + nodeID + ")";
                if (nodeString != "")
                {
                    float FontSize = 8.0f;
                    Font stringFont = new Font(FontFamily.GenericSansSerif, FontSize);
                    SizeF stringSize = formgraphics.MeasureString(nodeString, stringFont);
                    while (stringSize.Width > WidthBetweenNodes / 2 + NodeWidth / 2)
                    {
                        FontSize -= 0.5f;
                        stringFont = new Font(FontFamily.GenericSansSerif, FontSize);
                        stringSize = formgraphics.MeasureString(nodeString, stringFont);
                    }
                    float XPosition = ((high + low) / 2 * WidthBetweenNodes) + XOffset + (NodeWidth / 2.0f) - (stringSize.Width / 2.0f);
                    float YPosition = (depth * HeightBetweenNodes) + YOffset + (NodeHeight / 2.0f) - (stringSize.Height / 2.0f);
                    myBrush.Color = System.Drawing.Color.Black;
                    formgraphics.FillRectangle(myBrush, new RectangleF(XPosition - 1, YPosition - 1, stringSize.Width + 2, stringSize.Height + 2));
                    myBrush.Color = System.Drawing.Color.White;
                    formgraphics.DrawString(nodeString, stringFont, myBrush, new PointF(XPosition, YPosition));
                }
            }
            else
            {
                // ******** workaround *********
                // store the x and y coordinates of a graphical display node in the corresponding TreeNode name property
                // this information is used when a mouse click event is triggered on the panel displaying the structure, the entire TreeView is searched using this stored info and it is matched against the clicked mouse coordinates.
                Head.Name = "" + (((high + low) / 2 * WidthBetweenNodes) + XOffset) + "," + ((depth * HeightBetweenNodes) + YOffset);
            }
            return new Pair(low, high);
        }
Exemple #11
0
 public void EncapsulationCwTree()
 {
     foreach (KeyValuePair<string, IList<BinInformation>> pair in base.m_anaCWFile.CWFileInfo.CellBinInfoDic)
     {
         TreeNode child = this.m_MeasurementNode.ChildNode(pair.Key);
         if (child == null)
         {
             child = new TreeNode(pair.Key);
             this.m_MeasurementNode.AddChildNodeToParent(this.m_MeasurementNode.RootNode, child);
         }
         TreeNode node2 = new TreeNode(base.m_anaCWFile.CWFileInfo.FileName);
         MeasurementView.IDCreator++;
         node2.Tag = MeasurementView.IDCreator;
         string text = base.m_anaCWFile.CWFileInfo.FileName + node2.GetHashCode();
         base.m_anaCWFile.CWFileInfo.FileNameIdentifier = text;
         node2.Name = text;
         this.m_MeasurementNode.AddChildNodeToParent(child, node2);
         CWFileInformation item = new CWFileInformation();
         item.FileNameIdentifier = text;
         item.FileName = base.m_anaCWFile.CWFileInfo.FileName;
         item.BinInfoHeader = base.m_anaCWFile.CWFileInfo.BinInfoHeader;
         item.CellBinInfoDic.Add(pair.Key, pair.Value);
         item.CellInfo = base.m_anaCWFile.CWFileInfo.CellInfo;
         item.AntennaPara = base.m_anaCWFile.CWFileInfo.AntennaPara;
         this.m_cwFileInfoList.Add(item);
         base.m_AddedTreeNodes.Add(node2);
     }
 }
Exemple #12
0
        /// <summary>
        /// Preserves the nodes color.
        /// </summary>
        /// <param name="tn">Node to check.</param>
		private void PreserveNodeColors(TreeNode tn)
		{
			if (tn == null)
				return;

			if (!htblSelectedNodesOrigColors.ContainsKey(tn.GetHashCode()))
			{
				htblSelectedNodesOrigColors.Add(tn.GetHashCode(), new Color[] { tn.BackColor, tn.ForeColor });
			}
		}
Exemple #13
0
        //生成文件方法
        private void fileGenerate()
        {
            DoubleClickButton button1 = new DoubleClickButton();

            button1.ImageList    = this.imageList1;
            button1.ImageIndex   = 1;
            button1.Size         = new System.Drawing.Size(88, 77);
            button1.DoubleClick += new System.EventHandler(fileClicked);
            button1.Location     = new System.Drawing.Point(3, 3);
            button1.TabIndex     = 0;
            String btText = "";

            //button1.Tag = btText;
            button1.Name = "file" + fileIndex;
            button1.Text = "新建文件" + fileIndex;
            fileIndex++;
            button1.Font                              = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            button1.TextAlign                         = System.Drawing.ContentAlignment.BottomCenter;
            button1.TextImageRelation                 = System.Windows.Forms.TextImageRelation.ImageAboveText;
            button1.Margin                            = new System.Windows.Forms.Padding(7);
            button1.UseVisualStyleBackColor           = true;
            button1.FlatStyle                         = System.Windows.Forms.FlatStyle.Flat;
            button1.FlatAppearance.BorderColor        = System.Drawing.Color.White;
            button1.FlatStyle                         = FlatStyle.Flat;    //样式
            button1.ForeColor                         = Color.Transparent; //前景
            button1.BackColor                         = Color.Transparent; //去背景
            button1.FlatAppearance.BorderSize         = 0;                 //去边线
            button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
            button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
            //button1.ForeColor = System.Drawing.Color.Transparent;
            button1.ForeColor        = System.Drawing.Color.Black;
            button1.Padding          = new System.Windows.Forms.Padding(0);
            button1.ContextMenuStrip = this.文件右键菜单;
            System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode(button1.Text);
            //treeNode2.ContextMenuStrip = this.文件右键菜单;
            //treeNode2.Tag = button1;
            button1.Tag                  = treeNode2;
            treeNode2.Tag                = btText;
            treeNode2.ImageIndex         = 2;
            treeNode2.SelectedImageIndex = 2;
            //foreach (TreeNode nodes in treeView1.Nodes)
            //{
            //    if (nodes.Name == "root")       //判断符合条件的节点

            //    {
            //        nodes.Nodes.Add(treeNode2);
            //    }


            //}
            pathForNow.Nodes.Add(treeNode2);



            //this.treeView1.Nodes.Add(treeNode2);
            Hashtable folderForNow = (Hashtable)pathForNow.Tag;

            folderForNow.Add(button1.Name, button1);
            this.flowLayoutPanel1.Controls.Add(button1);


            for (int i = 2; i < 128; i++)
            {
                if (listView1.Items[i].SubItems[1].Text.Equals("0"))
                {
                    fat[i] = treeNode2.GetHashCode() - 1;
                    listView1.Items[i].SubItems[1].Text = "255";
                    break;
                }
            }
            treeView1.ExpandAll();
        }
Exemple #14
0
        //生成文件夹方法
        private void folderGenerate()
        {
            treeView1.LabelEdit = false;//不可编辑
            DoubleClickButton button1 = new DoubleClickButton();

            button1.Name = "folder" + folderIndex;
            button1.Text = "新建文件夹" + folderIndex;
            folderIndex++;
            button1.ImageList = this.imageList1;
            button1.ImageKey  = "64x64.png";
            //button1.Image = global::test4.Properties.Resources.folder;
            button1.Location = new System.Drawing.Point(3, 3);
            //button1.Name = "button1";
            button1.Size = new System.Drawing.Size(88, 77);
            //button1.Size = new System.Drawing.Size(78, 77);
            button1.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            //button1.Size = new System.Drawing.Size(59, 68);
            //button1.Size = new System.Drawing.Size(103, 120);
            button1.TabIndex = 0;
            //button1.Text = "新建文件夹";
            button1.TextAlign         = System.Drawing.ContentAlignment.BottomCenter;
            button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            //button1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            button1.UseVisualStyleBackColor = true;
            button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            button1.FlatAppearance.BorderColor = System.Drawing.Color.White;
            button1.FlatStyle = FlatStyle.Flat;            //样式
            button1.BackColor = Color.Transparent;         //去背景
            button1.FlatAppearance.BorderSize         = 0; //去边线
            button1.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
            button1.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
            button1.ForeColor        = System.Drawing.Color.Black;
            button1.Padding          = new System.Windows.Forms.Padding(0);
            button1.ContextMenuStrip = this.文件右键菜单;
            System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode(button1.Text);
            treeNode2.ImageIndex         = 0;
            treeNode2.SelectedImageIndex = 0;
            //treeNode2.ContextMenuStrip = this.文件右键菜单;
            //treeNode2.Tag = button1;
            button1.Tag = treeNode2;
            //button1.Tag = treeNode2;
            Hashtable folderContains = new Hashtable();

            treeNode2.Tag = folderContains;



            //this.button5.ImageKey = "64x64.png";
            //this.button5.ImageList = this.imageList1;
            //this.button5.Location = new System.Drawing.Point(3, 3);
            //this.button5.Name = "button5";
            //this.button5.Size = new System.Drawing.Size(59, 68);
            //this.button5.TabIndex = 0;
            //this.button5.Text = "button5";
            //this.button5.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            //this.button5.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            //this.button5.UseVisualStyleBackColor = true;



            //DoubleClickButton button2 = new DoubleClickButton();
            //button2.Name = "folder11" ;
            //button2.Text = "新建文件夹11";
            //DoubleClickButton button3 = new DoubleClickButton();
            //button3.Name = "folder111";
            //button3.Text = "新建文件夹111";
            //folderContains.Add(1, button2);
            //folderContains.Add(2, button3);



            //button1.Tag = folderContains;
            //foreach (TreeNode nodes in treeView1.Nodes)
            //{
            //    if (nodes.Name == "root")       //判断符合条件的节点
            //    {
            //        nodes.Nodes.Add(treeNode2);
            //    }

            //}
            pathForNow.Nodes.Add(treeNode2);


            button1.DoubleClick += new System.EventHandler(folderClicked);
            //fileList.Add(button1);
            //mainHash.Add(button1.Name, button1);
            Hashtable folderForNow = (Hashtable)pathForNow.Tag;

            folderForNow.Add(button1.Name, button1);
            this.flowLayoutPanel1.Controls.Add(button1);



            for (int i = 2; i < 128; i++)
            {
                if (listView1.Items[i].SubItems[1].Text.Equals("0"))
                {
                    fat[i] = treeNode2.GetHashCode();
                    listView1.Items[i].SubItems[1].Text = "255";
                    break;
                }
            }
            //this.treeView1.treeNode1.Nodes.add
            treeView1.ExpandAll();
        }
Exemple #15
0
        private void CatListRecurse(XmlTextReader aReader, Object aRootNode)
        {
            String inner = aReader.ReadInnerXml();

              NameTable nt = new NameTable();
              XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
              XmlParserContext ctxt = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
              XmlTextReader reader2 = new XmlTextReader(inner, XmlNodeType.Element, ctxt);

              TreeNode node;

              while (reader2.Read()) {
            if (reader2.NodeType == XmlNodeType.Element) {
              switch (reader2.LocalName) {
              case "panel":
            // Tree node with children. Retrieve label and id. Label is
            // used for visual presentation, id is hashed against node
            // and is used as a key when looking for which panel to
            // load.
            String[] values = new String[2] {"", ""};
            String[] names = new String[2] {"label", "id"};
            for (int i = 0; i < names.Length; ++i) {
              if (reader2.MoveToAttribute(names[i]) &&
                reader2.ReadAttributeValue())
                values[i] = reader2.Value;
              reader2.MoveToElement();
            }

            node = new TreeNode(values[0], 0, 0);
            if (aRootNode is TreeView) {
              TreeView rootView = aRootNode as TreeView;
              rootView.Nodes.Add(node);
            }
            else if (aRootNode is TreeNode) {
              TreeNode rootNode = aRootNode as TreeNode;
              rootNode.Nodes.Add(node);
            }

            mNodes.Add(node.GetHashCode(), values[1]);
            CatListRecurse(reader2, node);
            break;
              }
            }
              }
        }
Exemple #16
0
        private void XmlRekursivImport(TreeNodeCollection elem, XmlNodeList xmlNodeList) {
            TreeNode treeNode;
            foreach (XmlNode myXmlNode in xmlNodeList) {
                //if (myXmlNode.Attributes != null)
                {
                    if (myXmlNode.Name == "output" || myXmlNode.Name == "colors" || myXmlNode.Name == "fonts" || myXmlNode.Name == "windowstyle")
                        continue;

                    if(myXmlNode.Name == "#whitespace")
                        continue;

                    String name = myXmlNode.Name;

                    if (myXmlNode.Attributes != null && myXmlNode.Attributes["name"] != null)
                        name += " - " + myXmlNode.Attributes["name"].Value;

                    String ext = XmlElementStringLookup(myXmlNode.Name);
                    if (ext.Length > 0)
                    {
                        if (myXmlNode.Attributes != null && myXmlNode.Attributes[ext] != null)
                            name += " : " + myXmlNode.Attributes[ext].Value;
                        else
                            name += " " + myXmlNode.Value;
                    }
                    treeNode = new TreeNode(name/*Attributes["value"].Value*/);

                    if (myXmlNode.ChildNodes.Count > 0)
                    {
                        XmlRekursivImport(treeNode.Nodes, myXmlNode.ChildNodes);
                    }
                    elem.Add(treeNode);
                    sElementList element = new sElementList(treeNode.GetHashCode(), treeNode.Parent.GetHashCode(), treeNode, myXmlNode);
                    ElementList.Add(element);
                }
            }
        }
Exemple #17
0
		/// <summary>
		/// (Un)selects the specified node.
		/// </summary>
		/// <param name="tn">Node to (un)select.</param>
		/// <param name="select">True to select node, false to unselect node.</param>
		/// <param name="tva">Specifies the action that caused the selection change.</param>
		/// <returns>True if node was selected, false if not.</returns>
		private bool SelectNode(TreeNode tn, bool select, TreeViewAction tva)
		{
			bool blnSelected = false;

			if (tn == null)
				return false;

			if (select)
			{
				// Only try to select node if it was not already selected																		
				if (!IsNodeSelected(tn))
				{
					// Check if node selection is cancelled
					TreeViewCancelEventArgs tvcea = new TreeViewCancelEventArgs(tn, false, tva);
					base.OnBeforeSelect(tvcea);
					if (tvcea.Cancel)
					{
						// This node selection was cancelled!						
						return false;
					}

					PreserveNodeColors(tn);

					tn.BackColor = SelectionBackColor; // GKM moved from above
					tn.ForeColor = BackColor; // GKM moved from above									

					htblSelectedNodes.Add(tn.GetHashCode(), tn);
					blnSelected = true;
					blnSelectionChanged = true;

					base.OnAfterSelect(new TreeViewEventArgs(tn, tva));
				}

				tnMostRecentSelectedNode = tn;
			}
			else
			{
				// Only unselect node if it was selected
				if (IsNodeSelected(tn))
				{
					OnBeforeDeselect(tn);

					Color[] originalColors = (Color[])this.htblSelectedNodesOrigColors[tn.GetHashCode()];
					if (originalColors != null)
					{
						htblSelectedNodes.Remove(tn.GetHashCode());
						blnSelectionChanged = true;
						htblSelectedNodesOrigColors.Remove(tn.GetHashCode());

						// GKM - Restore original node colors
						tn.BackColor = originalColors[0]; // GKM - was BackColor;
						tn.ForeColor = originalColors[1]; // GKM - was ForeColor;
					}

					OnAfterDeselect(tn);
				}
			}

			return blnSelected;
		}
Exemple #18
0
    /// <summary>
    /// Checks if the TreeNode supplied is selected or not.
    /// Note that passing in null as the TreeNode will result in false being returned.
    /// </summary>
    /// <param name="tn">TreeNode that should be checked if it is selected or not.</param>
    /// <returns>True if supplied TreeNode is selected or false otherwise.</returns>
    public bool IsTreeNodeSelected(TreeNode tn)
    {
      bool bRetVal = false;

      if (tn != null)
      {
        if (MultiSelect == TreeViewMultiSelect.NoMulti)
        {
          if (SelectedNode == tn)
          {
            bRetVal = true;
          }
        }
        else
        {
          if (SelNodes != null)
          {
            if (SelNodes.Contains(tn.GetHashCode()))
            {
              bRetVal = true;
            }
          }
        }
      }

      return bRetVal;
    }
Exemple #19
0
        /// <summary>
        /// Deactivate TreeNode supplied.
        /// Deactivating means removing higlighting ('lowlighting').
        /// </summary>
        /// <param name="tn">TreeNode that should be deactivated.</param>
        private void DeactivateSelNode(TreeNode tn)
        {
            if(tn != null)
            {
                MWTreeNodeWrapper mwtnw = this.SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper;

                if(mwtnw != null)
                {
                    DeactivateSelNode(mwtnw);
                }
            }
        }
Exemple #20
0
    /// <summary>
    /// Select TreeNode supplied.
    /// Note that all selected TreeNodes can be found in the SelNodes property and the most recently selected TreeNode can be found in the SelNode property.
    /// </summary>
    /// <param name="tn">TreeNode to select.</param>
    /// <param name="bChangeSelNode">True if the SelNode property should be changed when selecting the TreeNode.</param>
    /// <returns>True if the SelNode property was changed to the TreeNode supplied (even if the SelNode property was already set to the TreeNode supplied before this method was called).</returns>
    public bool SelectNode(TreeNode tn, bool bChangeSelNode)
    {
      bool bRetVal = false;

      if (tn != null)
      {
        switch (MultiSelect)
        {
          case TreeViewMultiSelect.NoMulti:
            if (SelNodes.Count > 1)
            {
              ClearSelNodes();
            }

            SelectedNode = tn;

            SelNodeInt = SelectedNode;
            break;

          case TreeViewMultiSelect.Multi:
            if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
            {
              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.MultiSameBranchAndLevel:
            if (SelNodes != null && SelNodes.Count > 0)
            {
              TreeNode tnGrandParentSelNodes = null;
              int iLevel = 0;

              foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
              {
                tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node);
                iLevel = GetTreeNodeLevel(mwtnw.Node);
                break;
              }

              if (GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes && GetTreeNodeLevel(tn) == iLevel)
              {
                if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
                {
                  SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                  HighlightNode(tn);
                }
              }
              else if (IsSelectNodeRegExSatisfied(tn.Text))
              {
                ClearSelNodes();

                SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                HighlightNode(tn);
              }
            }
            else if (IsSelectNodeRegExSatisfied(tn.Text))
            {
              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.MultiSameBranch:
            if (SelNodes != null && SelNodes.Count > 0)
            {
              TreeNode tnGrandParentSelNodes = null;

              foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
              {
                tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node);
                break;
              }

              if (GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes)
              {
                if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
                {
                  SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                  HighlightNode(tn);
                }
              }
              else if (IsSelectNodeRegExSatisfied(tn.Text))
              {
                ClearSelNodes();

                SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                HighlightNode(tn);
              }
            }
            else if (IsSelectNodeRegExSatisfied(tn.Text))
            {
              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.MultiSameLevel:
            if (SelNodes != null && SelNodes.Count > 0)
            {
              int iLevel = 0;

              foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
              {
                iLevel = GetTreeNodeLevel(mwtnw.Node);
                break;
              }

              if (GetTreeNodeLevel(tn) == iLevel)
              {
                if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
                {
                  SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                  HighlightNode(tn);
                }
              }
              else if (IsSelectNodeRegExSatisfied(tn.Text))
              {
                ClearSelNodes();

                SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                HighlightNode(tn);
              }
            }
            else if (IsSelectNodeRegExSatisfied(tn.Text))
            {
              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.MultiPathToParents:
          case TreeViewMultiSelect.MultiPathToParent:
            if (SelNodes != null && SelNodes.Count > 0)
            {
              TreeNode tnGrandParentSelNodes = null;

              foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
              {
                tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node);
                break;
              }

              if (GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes ||
                  MultiSelect == TreeViewMultiSelect.MultiPathToParents)
              {
                if (!IsTreeNodeSelected(tn))
                {
                  int iTNLevel = GetTreeNodeLevel(tn);
                  TreeNode tnTNGrandParent = GetTreeNodeGrandParent(tn);

                  int iMaxLevel = 0;
                  foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
                  {
                    iMaxLevel = Math.Max(iMaxLevel, GetTreeNodeLevel(mwtnw.Node));
                  }

                  if (iMaxLevel < iTNLevel)
                  {
                    if (MultiSelect == TreeViewMultiSelect.MultiPathToParent)
                    {
                      ClearSelNodes();
                    }
                    else if (MultiSelect == TreeViewMultiSelect.MultiPathToParents)
                    {
                      DeselectBranch(tnTNGrandParent, true, false);
                    }
                  }
                  else
                  {
                    foreach (TreeNode tnRoot in Nodes)
                    {
                      if (GetTreeNodeGrandParent(tn) == tnRoot)
                      {
                        ArrayList al = new ArrayList();

                        foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
                        {
                          if (tnRoot == GetTreeNodeGrandParent(mwtnw.Node))
                          {
                            int iLevel = GetTreeNodeLevel(mwtnw.Node);

                            if (iLevel > iTNLevel)
                            {
                              al.Add(mwtnw.Node);
                            }
                          }
                        }

                        for (int i = 0; i < al.Count; i++)
                        {
                          DeselectNode(al[i] as TreeNode, false);
                        }
                      }
                    }
                  }

                  if (IsSelectNodeRegExSatisfied(tn.Text))
                  {
                    SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                    HighlightNode(tn);

                    TreeNode tnTemp = tn;
                    while (tnTemp.Parent != null)
                    {
                      if (!IsTreeNodeSelected(tnTemp.Parent))
                      {
                        SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                      }

                      HighlightNode(tnTemp.Parent);

                      tnTemp = tnTemp.Parent;
                    }
                  }
                }
                else
                {
                  TreeNode tnTemp = tn;
                  while (tnTemp.Parent != null)
                  {
                    if (IsSelectNodeRegExSatisfied(tn.Text))
                    {
                      if (!IsTreeNodeSelected(tnTemp.Parent))
                      {
                        SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                      }

                      HighlightNode(tnTemp.Parent);
                    }

                    tnTemp = tnTemp.Parent;
                  }
                }
              }
              else if (IsSelectNodeRegExSatisfied(tn.Text))
              {
                ClearSelNodes();

                SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

                HighlightNode(tn);

                TreeNode tnTemp = tn;
                while (tnTemp.Parent != null)
                {
                  if (!IsTreeNodeSelected(tnTemp.Parent))
                  {
                    SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                  }

                  HighlightNode(tnTemp.Parent);

                  tnTemp = tnTemp.Parent;
                }
              }
            }
            else if (IsSelectNodeRegExSatisfied(tn.Text))
            {
              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);

              TreeNode tnTemp = tn;
              while (tnTemp.Parent != null)
              {
                if (!IsTreeNodeSelected(tnTemp.Parent))
                {
                  SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                }

                HighlightNode(tnTemp.Parent);

                tnTemp = tnTemp.Parent;
              }
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.SinglePathToParent:
            if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
            {
              ClearSelNodes();

              if (SelNodes == null)
              {
                SelNodes = new Hashtable();
              }

              SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));

              HighlightNode(tn);

              TreeNode tnTemp = tn;
              while (tnTemp.Parent != null)
              {
                if (!IsTreeNodeSelected(tnTemp.Parent))
                {
                  SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                }

                HighlightNode(tnTemp.Parent);

                tnTemp = tnTemp.Parent;
              }
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          case TreeViewMultiSelect.SinglePathToParents:
            if (SelNodes != null && SelNodes.Count > 0)
            {
              GetTreeNodeLevel(tn);
              GetTreeNodeGrandParent(tn);

              foreach (TreeNode tnRoot in Nodes)
              {
                if (GetTreeNodeGrandParent(tn) == tnRoot)
                {
                  if (IsSelectNodeRegExSatisfied(tn.Text))
                  {
                    ClearSelBranch(tnRoot);

                    if (!IsTreeNodeSelected(tn))
                    {
                      SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
                    }

                    HighlightNode(tn);

                    TreeNode tnTemp = tn;
                    while (tnTemp.Parent != null)
                    {
                      if (!IsTreeNodeSelected(tnTemp.Parent))
                      {
                        SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                      }

                      HighlightNode(tnTemp.Parent);

                      tnTemp = tnTemp.Parent;
                    }
                  }

                  break;
                }
              }
            }
            else
            {
              if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
              {
                ClearSelNodes();

                if (SelNodes == null)
                {
                  SelNodes = new Hashtable();
                }

                if (!IsTreeNodeSelected(tn))
                {
                  SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
                }

                HighlightNode(tn);

                TreeNode tnTemp = tn;
                while (tnTemp.Parent != null)
                {
                  if (!IsTreeNodeSelected(tnTemp.Parent))
                  {
                    SelNodes.Add(tnTemp.Parent.GetHashCode(), new MWTreeNodeWrapper(tnTemp.Parent));
                  }

                  HighlightNode(tnTemp.Parent);

                  tnTemp = tnTemp.Parent;
                }
              }
            }

            if (bChangeSelNode)
            {
              ChangeSelNode(tn);
            }
            break;

          default:
            //Execution should never end up here!
            break;
        }

        if (SelNode == tn)
        {
          bRetVal = true;
        }
      }

      return bRetVal;
    }
Exemple #21
0
        /// <summary>
        /// Disable TreeNode supplied.
        /// </summary>
        /// <param name="tn">TreeNode to disable.</param>
        private void DisableNode(TreeNode tn)
        {
            if(this.UseExtendedDisabledColors)
            {
                htDisabledTreeNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn, this.DisabledTreeNodeBackColor, this.DisabledTreeNodeForeColor));
            }
            else
            {
                if(IsTreeNodeSelected(tn))
                {
                    MWTreeNodeWrapper mwtnw = GetSelectedMWTreeNodeWrapper(tn);

                    if(mwtnw != null)
                    {
                        if(this.HideSelection)
                        {
                            htDisabledTreeNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn, mwtnw.BackColor, mwtnw.ForeColor));
                        }
                        else
                        {
                            htDisabledTreeNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn, SystemColors.Control, SystemColors.ControlDark));
                        }
                    }
                }
                else if(IsPlainColoredTreeNode(tn))
                {
                    htDisabledTreeNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn, this.DisabledTreeNodeBackColor, this.DisabledTreeNodeForeColor));
                }
            }
        }
Exemple #22
0
    /// <summary>
    /// Deselect TreeNode supplied.
    /// Note that all selected TreeNodes can be found in the SelNodes property and the most recently selected TreeNode can be found in the SelNode property.
    /// </summary>
    /// <param name="tn">TreeNode to deselect.</param>
    /// <param name="bChangeSelNode">True if the SelNode property should be changed when deselecting the TreeNode.</param>
    /// <returns>True if the TreeNode supplied was successfully removed from the SelNodes property.</returns>
    public bool DeselectNode(TreeNode tn, bool bChangeSelNode)
    {
      bool bRetVal = false;

      bool bDeselectNode = false;

      if (tn != null && SelNodes.Count > 0 && IsTreeNodeSelected(tn))
      {
        if (MultiSelect == TreeViewMultiSelect.MultiPathToParent ||
            MultiSelect == TreeViewMultiSelect.MultiPathToParents ||
            MultiSelect == TreeViewMultiSelect.SinglePathToParent ||
            MultiSelect == TreeViewMultiSelect.SinglePathToParents)
        {
          if (tn.Nodes.Count == 0 || !IsAnyChildTreeNodeSelected(tn))
          {
            bDeselectNode = true;
          }
        }
        else
        {
          bDeselectNode = true;
        }
      }

      if (!AllowNoSelNode && SelNodes.Count == 1)
      {
        bDeselectNode = false;
      }

      if (bDeselectNode)
      {
        MWTreeNodeWrapper.Deselect(SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper);
        SelNodes.Remove(tn.GetHashCode());

        LowlightNode(tn);

        if (!IsTreeNodeSelected(tn))
        {
          bRetVal = true;
        }
      }

      if (bChangeSelNode)
      {
        if (SelNode != null)
        {
          bRetVal = true;
        }

        SelNodeInt = null;
      }

      return bRetVal;
    }
Exemple #23
0
        /// <summary>
        /// Add a TreeNode to the SelNodes property.
        /// </summary>
        /// <param name="tn">TreeNode to add to the SelNodes property.</param>
        /// <param name="bTriggerEvents">True if calling this method should raise the OnBeforeSelNodesAdd and OnAfterSelNodesAdd events or false otherwise.</param>
        /// <returns>True if the TreeNode is actually added or false otherwise.</returns>
        private bool SelNodesAdd(TreeNode tn, bool bTriggerEvents)
        {
            bool bRetVal = false;

            if(!this.IsTreeNodeSelected(tn))
            {
                MWCancelEventArgs e = new MWCancelEventArgs(this.SelNodes, tn);

                if(bTriggerEvents)
                {
                    OnBeforeSelNodesAdd(e);
                }

                if(!e.Cancel)
                {
                    this.SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn, this.UseExtendedSelectionColors, this.SelectedTreeNodeBackColor, this.SelectedTreeNodeForeColor));

                    if(!bActive)
                    {
                        DeactivateSelNode(tn);
                    }

                    if(bTriggerEvents)
                    {
                        OnAfterSelNodesAdd(new MWControlSuite.MWPropertyEventArgs(tn));
                    }

                    bRetVal = true;
                }
            }

            return bRetVal;
        }
Exemple #24
0
    /// <summary>
    /// Clear all TreeNodes in the SelNodes property and deselect them, except for the TreeNodes in the range between, and including, the
    ///		two TreeNodes supplied.
    /// </summary>
    /// <param name="tnFrom">First TreeNode in range of TreeNodes that should not be deselected.</param>
    /// <param name="tnTo">Last TreeNode in range of TreeNodes that should not be deselected.</param>
    /// <param name="bOnlyVisible">True if only visible TreeNodes should be considered to be part of the range or false if both visible and non-visible TreeNodes should be considered to be part of the range.</param>
    public void ClearSelNodes(TreeNode tnFrom, TreeNode tnTo, bool bOnlyVisible)
    {
      if (tnFrom == tnTo)
      {
        if (tnFrom != null)
        {
          ClearSelNodes(tnFrom);
        }
        else
        {
          ClearSelNodes();
        }
      }
      else if (SelNodes != null)
      {
        if (tnTo == null)
        {
          tnTo = Nodes[Nodes.Count - 1];

          if (bOnlyVisible)
          {
            while (tnTo.NextVisibleNode != null)
            {
              tnTo = tnTo.NextVisibleNode;
            }
          }
          else
          {
            while (tnTo.NextNode != null)
            {
              tnTo = tnTo.NextNode;
            }
          }
        }

        Hashtable ht = new Hashtable();

        TreeNode tn = tnFrom;

        while (tn != null && tn != tnTo)
        {
          ht.Add(tn.GetHashCode(), tn);

          tn = bOnlyVisible ? tn.NextVisibleNode : tn.NextNode;
        }

        ht.Add(tnTo.GetHashCode(), tnTo);

        int iMax = SelNodes.Count;

        for (int i = 0; i < iMax; i++)
        {
          foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
          {
            if (!ht.Contains(mwtnw.Node.GetHashCode()))
            {
              MWTreeNodeWrapper.Deselect(mwtnw);
              LowlightNode(mwtnw.Node);
              SelNodes.Remove(mwtnw.Node.GetHashCode());

              break;
            }
          }
        }
      }
    }
Exemple #25
0
        /// <summary>
        /// Change the SelectedImageIndex of the supplied TreeNode.
        /// </summary>
        /// <param name="tn">TreeNode to change the SelectedImageIndex of.</param>
        /// <param name="iImageIndex">SelectedImageIndex to change to.</param>
        public static void ChangeTreeNodeSelectedImageIndex(TreeNode tn, int iSelectedImageIndex)
        {
            if(tn != null)
            {
                if((tn.TreeView as MWTreeView).IsTreeNodeSelected(tn))
                {
                    MWTreeNodeWrapper mwtnw = (tn.TreeView as MWTreeView).SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper;

                    mwtnw.SelectedImageIndex = iSelectedImageIndex;

                    tn.ImageIndex = iSelectedImageIndex;
                    tn.SelectedImageIndex = iSelectedImageIndex;
                }
                else
                {
                    tn.SelectedImageIndex = iSelectedImageIndex;
                }
            }
        }
Exemple #26
0
    /// <summary>
    /// Check the TreeNode supplied (set the Checked property to true).
    /// </summary>
    /// <param name="tn">TreeNode to check (set the Checked property to true).</param>
    /// <param name="bUpdate">True if the TreeNode's Checked property should be updated or false otherwise.</param>
    /// <returns>True if the TreeNodes was checked (Checked property set to true) or false otherwise.</returns>
    public bool CheckNode(TreeNode tn, bool bUpdate)
    {
      bool bRetVal = false;

      bool bOldChecked = tn.Checked;

      if (AllowMultiCheck)
      {
        if (IsTreeNodeChecked(tn))
        {
          if (!tn.Checked && bUpdate)
          {
            tn.Checked = true;
          }
        }
        else
        {
          if (!tn.Checked)
          {
            if (bUpdate)
            {
              tn.Checked = true;
            }

            if (!IsTreeNodeChecked(tn) && IsCheckNodeRegExSatisfied(tn.Text))
            {
              CheckedNodes.Add(tn.GetHashCode(), tn);
            }
          }
        }
      }
      else
      {
        ClearCheckedNodes();

        if (bUpdate)
        {
          tn.Checked = true;
        }

        if (!IsTreeNodeChecked(tn) && IsCheckNodeRegExSatisfied(tn.Text))
        {
          CheckedNodes.Add(tn.GetHashCode(), tn);
        }
      }

      if (bOldChecked != tn.Checked)
      {
        bRetVal = true;
      }

      return bRetVal;
    }
Exemple #27
0
        /// <summary>
        /// Clear all TreeNodes in the SelNodes property and deselect them, except for the TreeNodes in the range between, and including, the
        ///		two TreeNodes supplied.
        /// </summary>
        /// <param name="tnFrom">First TreeNode in range of TreeNodes that should not be deselected.</param>
        /// <param name="tnTo">Last TreeNode in range of TreeNodes that should not be deselected.</param>
        /// <param name="bTriggerSelNodesAddRemoveEvents">True if calling this method should make the SelNodesAdd/SelNodesRemove methods raise the OnBeforeSelNodesAdd/OnBeforeSelNodesRemove and OnAfterSelNodesAdd/OnAfterSelNodesRemove events or false otherwise.</param>
        /// <param name="bOnlyVisible">True if only visible TreeNodes should be considered to be part of the range or false if both visible and non-visible TreeNodes should be considered to be part of the range.</param>
        public void ClearSelNodes(TreeNode tnFrom, TreeNode tnTo, bool bTriggerSelNodesAddRemoveEvents, bool bOnlyVisible)
        {
            if(tnFrom == tnTo)
            {
                if(tnFrom != null)
                {
                    ClearSelNodes(tnFrom, bTriggerSelNodesAddRemoveEvents);
                }
                else
                {
                    ClearSelNodes(bTriggerSelNodesAddRemoveEvents);
                }
            }
            else if(this.SelNodes != null)
            {
                if(tnTo == null)
                {
                    tnTo = this.Nodes[this.Nodes.Count - 1];

                    if(bOnlyVisible)
                    {
                        while(tnTo.NextVisibleNode != null)
                        {
                            tnTo = tnTo.NextVisibleNode;
                        }
                    }
                    else
                    {
                        while(tnTo.NextNode != null)
                        {
                            tnTo = tnTo.NextNode;
                        }
                    }
                }

                Hashtable ht = new Hashtable();

                TreeNode tn = tnFrom;

                while(tn != null && tn != tnTo)
                {
                    ht.Add(tn.GetHashCode(), tn);

                    if(bOnlyVisible)
                    {
                        tn = tn.NextVisibleNode;
                    }
                    else
                    {
                        tn = tn.NextNode;
                    }
                }

                ht.Add(tnTo.GetHashCode(), tnTo);

                int iMax = this.SelNodes.Count;

                for(int i = 0; i < iMax; i++)
                {
                    foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values)
                    {
                        if(!ht.Contains(mwtnw.Node.GetHashCode()))
                        {
                            if(this.SelNodesRemove(mwtnw.Node, bTriggerSelNodesAddRemoveEvents))
                            {
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                this.SelNodes = new Hashtable();
            }
        }
Exemple #28
0
    /// <summary>
    /// Uncheck the TreeNode supplied (set the Checked property to false).
    /// </summary>
    /// <param name="tn">TreeNode to uncheck (set the Checked property to false).</param>
    /// <param name="bUpdate">True if the TreeNode's Checked property should be updated or false otherwise.</param>
    /// <returns>True if the TreeNodes was unchecked (Checked property set to false) or false otherwise.</returns>
    public bool UncheckNode(TreeNode tn, bool bUpdate)
    {
      bool bRetVal = false;

      bool bOldChecked = tn.Checked;

      if (IsTreeNodeChecked(tn))
      {
        if (tn.Checked)
        {
          if (bUpdate)
          {
            tn.Checked = false;
          }

          CheckedNodes.Remove(tn.GetHashCode());
        }
      }
      else
      {
        if (tn.Checked && bUpdate)
        {
          tn.Checked = false;
        }
      }

      if (bOldChecked != tn.Checked)
      {
        bRetVal = true;
      }

      return bRetVal;
    }
Exemple #29
0
        /// <summary>
        /// Get the MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Selected MWTreeNodeWrapper Hashtable.
        /// </summary>
        /// <param name="tn">TreeNode for which to return an MWTreeNodeWrapper.</param>
        /// <returns>The MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Selected MWTreeNodeWrapper Hashtable or null otherwise.</returns>
        public MWTreeNodeWrapper GetSelectedMWTreeNodeWrapper(TreeNode tn)
        {
            MWTreeNodeWrapper mwtnw = null;

            if(IsTreeNodeSelected(tn))
            {
                mwtnw = htSelNodes[tn.GetHashCode()] as MWTreeNodeWrapper;
            }

            return mwtnw;
        }
Exemple #30
0
		/// <summary>
		/// Determines whether the specified node is selected or not.
		/// </summary>
		/// <param name="tn">Node to check.</param>
		/// <returns>True if specified node is selected, false if not.</returns>
		private bool IsNodeSelected(TreeNode tn)
		{
			if (tn != null)
				return htblSelectedNodes.ContainsKey(tn.GetHashCode());
			return false;
		}
Exemple #31
0
        /// <summary>
        /// Checks if the TreeNode supplied is selected or not.
        /// Note that passing in null as the TreeNode will result in false being returned.
        /// </summary>
        /// <param name="tn">TreeNode that should be checked if it is selected or not.</param>
        /// <returns>True if supplied TreeNode is selected or false otherwise.</returns>
        public bool IsTreeNodeSelected(TreeNode tn)
        {
            bool bRetVal = false;

            if(tn != null)
            {
                if(this.SelNodes != null)
                {
                    if(this.SelNodes.Contains(tn.GetHashCode()))
                    {
                        bRetVal = true;
                    }
                }
            }

            return bRetVal;
        }
Exemple #32
0
		private void PreserveNodeColors(TreeNode tn)
		{
			if (tn == null)
				return;

			System.Diagnostics.Debug.WriteLine(tn.BackColor.ToString());

			if (htblSelectedNodesOrigColors.ContainsKey(tn.GetHashCode()))
			{
				//				Color[] color = (Color[])htblSelectedNodesOrigColors[tn.GetHashCode()];
				//				color[0]=tn.BackColor;
				//				color[1]=tn.ForeColor;
			}
			else
			{
				htblSelectedNodesOrigColors.Add(tn.GetHashCode(), new Color[] { tn.BackColor, tn.ForeColor });
			}
		}