Пример #1
0
        public static TreeNode SearchTreeNode(TreeNode treeNode, Asn1Node node)
        {
            TreeNode treeNode1 = (TreeNode)null;

            if (node == null)
            {
                return(treeNode1);
            }
            if (((Asn1TreeNode)treeNode).ANode == node)
            {
                return(treeNode);
            }
            for (int index = 0; index < treeNode.Nodes.Count; ++index)
            {
                if (((Asn1TreeNode)treeNode.Nodes[index]).ANode == node)
                {
                    treeNode1 = treeNode.Nodes[index];
                    break;
                }
                treeNode1 = Asn1TreeNode.SearchTreeNode(treeNode.Nodes[index], node);
                if (treeNode1 != null)
                {
                    break;
                }
            }
            return(treeNode1);
        }
Пример #2
0
		/// <summary>
		/// Following node.Adn1Node to add subnodes. It is special for paste a node tree.
		/// </summary>
		/// <param name="node">node.</param>
		/// <param name="mask">mask.</param>
		/// <param name="treeView">hosting TreeView control.</param>
		public static void AddSubNode(Asn1TreeNode node, uint mask, TreeView treeView)
		{
			for (int i=0; i<node.ANode.ChildNodeCount; i++)
			{
				Asn1TreeNode tNode = new Asn1TreeNode();
				tNode.asn1Node = node.ANode.GetChildNode(i);
				tNode.Text = tNode.ANode.GetLabel(mask);
				node.Nodes.Add(tNode);
				node.Expand();
				if (treeView != null)
					treeView.SelectedNode = node;
				AddSubNode(tNode, mask, treeView);
			}
		}
Пример #3
0
 /// <summary>
 /// Following node.Adn1Node to add subnodes. It is special for paste a node tree.
 /// </summary>
 /// <param name="node">node.</param>
 /// <param name="mask">mask.</param>
 /// <param name="treeView">hosting TreeView control.</param>
 public static void AddSubNode(Asn1TreeNode node, uint mask, TreeView treeView)
 {
     for (int i = 0; i < node.ANode.ChildNodeCount; i++)
     {
         Asn1TreeNode tNode = new Asn1TreeNode();
         tNode.asn1Node = node.ANode.GetChildNode(i);
         tNode.Text     = tNode.ANode.GetLabel(mask);
         node.Nodes.Add(tNode);
         node.Expand();
         if (treeView != null)
         {
             treeView.SelectedNode = node;
         }
         AddSubNode(tNode, mask, treeView);
     }
 }
Пример #4
0
 public static void AddSubNode(Asn1TreeNode node, uint mask, TreeView treeView)
 {
     for (int index = 0; (long)index < node.ANode.ChildNodeCount; ++index)
     {
         Asn1TreeNode node1 = new Asn1TreeNode();
         node1.asn1Node = node.ANode.GetChildNode(index);
         node1.Text     = node1.ANode.GetLabel(mask);
         node.Nodes.Add((TreeNode)node1);
         node.Expand();
         if (treeView != null)
         {
             treeView.SelectedNode = (TreeNode)node;
         }
         Asn1TreeNode.AddSubNode(node1, mask, treeView);
     }
 }
Пример #5
0
 private void BuildChildTreeNode(Asn1TreeNode tNode, uint mask)
 {
     int i;
     SetNodeImgIndex(tNode);
     Asn1TreeNode tmpNode;
     for (i=0; i<tNode.ANode.ChildNodeCount; i++)
     {
         tmpNode = new Asn1TreeNode(tNode.ANode.GetChildNode(i), mask);
         tNode.Nodes.Add(tmpNode);
         BuildChildTreeNode(tmpNode, mask);
     }
 }
Пример #6
0
 public void SetNodeImgIndex(Asn1TreeNode node)
 {
     int tag = node.ANode.Tag;
     int tagClass = (tag & Asn1TagClasses.CLASS_MASK);
     if (tagClass == Asn1TagClasses.CONTEXT_SPECIFIC ||
         tagClass == Asn1TagClasses.APPLICATION ||
         tagClass == Asn1TagClasses.PRIVATE)
     {
         SetNodeImgIndex(node, ImgIndex.CONTEXT_SPECIFIC);
     }
     else
     {
         switch (tag & Asn1Tag.TAG_MASK)
         {
             case Asn1Tag.BOOLEAN:
                 SetNodeImgIndex(node, ImgIndex.BOOLEAN);
                 break;
             case Asn1Tag.INTEGER:
                 SetNodeImgIndex(node, ImgIndex.INTEGER);
                 break;
             case Asn1Tag.BIT_STRING:
                 SetNodeImgIndex(node, ImgIndex.BIT_STRING);
                 break;
             case Asn1Tag.OCTET_STRING:
                 SetNodeImgIndex(node, ImgIndex.OCTET_STRING);
                 break;
             case Asn1Tag.TAG_NULL:
                 SetNodeImgIndex(node, ImgIndex.TAG_NULL);
                 break;
             case Asn1Tag.OBJECT_IDENTIFIER:
                 SetNodeImgIndex(node, ImgIndex.OBJECT_IDENTIFIER);
                 break;
             case Asn1Tag.RELATIVE_OID:
                 SetNodeImgIndex(node, ImgIndex.RELATIVE_OID);
                 break;
             case Asn1Tag.OBJECT_DESCRIPTOR:
                 SetNodeImgIndex(node, ImgIndex.OBJECT_DESCRIPTOR);
                 break;
             case Asn1Tag.EXTERNAL:
                 SetNodeImgIndex(node, ImgIndex.EXTERNAL);
                 break;
             case Asn1Tag.REAL:
                 SetNodeImgIndex(node, ImgIndex.REAL);
                 break;
             case Asn1Tag.ENUMERATED:
                 SetNodeImgIndex(node, ImgIndex.ENUMERATED);
                 break;
             case Asn1Tag.UTF8_STRING:
                 SetNodeImgIndex(node, ImgIndex.UTF8_STRING);
                 break;
             case Asn1Tag.SEQUENCE:
                 SetNodeImgIndex(node, ImgIndex.SEQUENCE);
                 break;
             case Asn1Tag.SET:
                 SetNodeImgIndex(node, ImgIndex.SET);
                 break;
             case Asn1Tag.NUMERIC_STRING:
                 SetNodeImgIndex(node, ImgIndex.NUMERIC_STRING);
                 break;
             case Asn1Tag.PRINTABLE_STRING:
                 SetNodeImgIndex(node, ImgIndex.PRINTABLE_STRING);
                 break;
             case Asn1Tag.T61_STRING:
                 SetNodeImgIndex(node, ImgIndex.T61_STRING);
                 break;
             case Asn1Tag.VIDEOTEXT_STRING:
                 SetNodeImgIndex(node, ImgIndex.VIDEOTEXT_STRING);
                 break;
             case Asn1Tag.IA5_STRING:
                 SetNodeImgIndex(node, ImgIndex.IA5_STRING);
                 break;
             case Asn1Tag.UTC_TIME:
                 SetNodeImgIndex(node, ImgIndex.UTC_TIME);
                 break;
             case Asn1Tag.GENERALIZED_TIME:
                 SetNodeImgIndex(node, ImgIndex.GENERALIZED_TIME);
                 break;
             case Asn1Tag.GRAPHIC_STRING:
                 SetNodeImgIndex(node, ImgIndex.GRAPHIC_STRING);
                 break;
             case Asn1Tag.VISIBLE_STRING:
                 SetNodeImgIndex(node, ImgIndex.VISIBLE_STRING);
                 break;
             case Asn1Tag.GENERAL_STRING:
                 SetNodeImgIndex(node, ImgIndex.GENERAL_STRING);
                 break;
             case Asn1Tag.UNIVERSAL_STRING:
                 SetNodeImgIndex(node, ImgIndex.UNIVERSAL_STRING);
                 break;
             case Asn1Tag.BMPSTRING:
                 SetNodeImgIndex(node, ImgIndex.BMPSTRING);
                 break;
             default:
                 SetNodeImgIndex(node, ImgIndex.CONTEXT_SPECIFIC);
                 break;
         };
     }
 }
Пример #7
0
 public void RefreshChildTreeNode(Asn1TreeNode node, uint mask)
 {
     SetNodeImgIndex(node);
     for (int i=0; i<node.Nodes.Count; i++)
     {
         node.Nodes[i].Text = ((Asn1TreeNode)node.Nodes[i]).ANode.GetLabel(mask);
         RefreshChildTreeNode((Asn1TreeNode)node.Nodes[i], mask);
     }
 }
Пример #8
0
 public void BuildTreeView(TreeView treeView, uint mask)
 {
     treeView.Visible = false;
     try
     {
         ClearChildTreeNodes(treeView.Nodes);
         Asn1TreeNode rootTreeNode = new Asn1TreeNode(RootNode, mask);
         rootTreeNode.ImageIndex = (int)ImgIndex.ROOT;
         rootTreeNode.SelectedImageIndex = (int)ImgIndex.ROOT_SELECTED;
         BuildChildTreeNode(rootTreeNode, mask);
         treeView.Nodes.Add(rootTreeNode);
         rootTreeNode.ExpandAll();
         treeView.SelectedNode = rootTreeNode;
     }
     finally
     {
         treeView.Visible = true;
     }
 }
Пример #9
0
 private void menuItemNodePasteBeforeCurrentNode_Click(object sender, System.EventArgs e)
 {
     Asn1Node selectedNode = SelectedAsn1Node();
     Asn1Node tempNode = Asn1ClipboardData.Paste();
     int index = selectedNode.ParentNode.InsertChild(tempNode, selectedNode);
     Asn1TreeNode tNode = new Asn1TreeNode(tempNode, GenMask());
     treeView.SelectedNode.Parent.Nodes.Insert(index, tNode);
     try
     {
         if (Asn1Node.GetDescendantNodeCount(tNode.ANode) > refreshNodeCounter)
         {
             treeView.Visible = false;
             hexViewer.Connected = false;
         }
         Asn1TreeNode.AddSubNode(tNode, GenMask(), treeView);
         RefreshTree();
         if (treeView.Nodes.Count > 0)
             treeView.SelectedNode = Asn1TreeNode.SearchTreeNode(treeView.Nodes[0], tempNode);
     }
     finally
     {
         hexViewer.Connected = true;
         treeView.Visible = true;
     }
 }
Пример #10
0
 private void menuItemNewNode_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (treeView.Nodes.Count < 1)
         {
             if (FormNodeContentEditor.EditNode(this, xParser.RootNode, true, true))
             {
                 BuildTreeView(treeView, this.GenMask());
                 RefreshTree();
                 if (treeView.Nodes.Count>0)
                     treeView.SelectedNode = treeView.Nodes[0];
             }
         }
         else
         {
             Asn1Node selectedNode = SelectedAsn1Node();
             Asn1Node tempNode = new Asn1Node();
             if (FormNodeContentEditor.EditNode(this, tempNode, true, true))
             {
                 if (selectedNode.IsEmptyData || selectedNode.Data.Length < 1)
                 {
                     selectedNode.AddChild(tempNode);
                     Asn1TreeNode tNode = new Asn1TreeNode(tempNode, GenMask());
                     treeView.SelectedNode.Nodes.Add(tNode);
                 }
                 else
                 {
                     if (selectedNode.ParentNode != null)
                     {
                         selectedNode.ParentNode.AddChild(tempNode);
                         Asn1TreeNode tNode = new Asn1TreeNode(tempNode, GenMask());
                         treeView.SelectedNode.Parent.Nodes.Add(tNode);
                     }
                     else
                         MessageBox.Show("Failed to add new node.");
                 }
                 RefreshTree();
                 treeView.SelectedNode = Asn1TreeNode.SearchTreeNode(treeView.Nodes[0], tempNode);
             }
         }
         SetButton();
     }
     catch( Exception ex )
     {
         MessageBox.Show(ex.Message);
     }
 }