Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="nodes"></param>
        /// <returns></returns>
        protected TreeNode GetNode(StructCategory cat, TreeNodeCollection nodes)
        {
            // Create new node
            TreeNode node = new TreeNode(cat.name, cat.iconIdx, cat.iconIdx);

            node.Tag = cat.idnum;
            for (int i = 0; i < nodes.Count; i++)
            {
                if ((int)nodes[i].Tag == cat.idnum)
                {
                    return(nodes[i]);
                }
            }

            //nodes.Insert(0,node);
            int j = 0;

            // find nearest below node
            for (int i = 0; i < nodes.Count; i++)
            {
                if ((int)nodes[i].Tag < (int)cat.idnum)
                {
                    j++;
                }
            }
            nodes.Insert(j, node);
            return(node);
        }
Exemplo n.º 2
0
        private void categoryTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            MultiSelectorController.create(); //will show if created, create and show if not.
            StructCategory cat = StructCategoryTree.theInstance[(int)categoryTree.SelectedNode.Tag];

            OnNodeSelected(cat, 0);
        }
Exemplo n.º 3
0
        private void BuildCategories()
        {
            IEnumerator ie = StructCategoryTree.theInstance.Categories.GetEnumerator();

            while (ie.MoveNext())
            {
                StructCategory cat = (StructCategory)ie.Current;
                GetNode(cat);
            }
        }
Exemplo n.º 4
0
        private void makeRoot(XmlDocument e)
        {
            String fn = Path.Combine(BaseDir, "icons.bmp");

            StructCategory.ImageBaseInt(fn);
            StructCategory cat = new StructCategory(0, "Uncategorized", 0);

            //! StructCategory cat = new StructCategory(0, "未分類", 0);
            idTbl.Add(cat.idnum, cat);
            nameTbl.Add(cat.name, cat);
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <returns></returns>
 public TreeNode GetNode(StructCategory cat)
 {
     if (cat.HasParent())
     {
         TreeNode p = GetNode(cat.Parent);
         return(GetNode(cat, p.Nodes));
     }
     else
     {
         return(GetNode(cat, categoryTree.Nodes));
     }
 }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nd"></param>
        /// <param name="level"></param>
        protected void parseTree(XmlNode nd, int level)
        {
            XmlNodeList xnl = nd.ChildNodes;

            foreach (XmlNode cn in xnl)
            {
                if (cn.Name.Equals("category"))
                {
                    StructCategory cat = new StructCategory(cn);
                    idTbl.Add(cat.idnum, cat);
                    nameTbl.Add(cat.name, cat);
                    parseTree(cn, level + 1);
                }
            }
        }
Exemplo n.º 7
0
        // callback from StructureCategoryWindow
        internal void OnNodeSelected(StructCategory cat, int option)
        {
            typeBox.Items.Clear();
            typeBox.Text = "";
            typeList.Items.Clear();
            typeMap.Clear();
            SetCategoryEntries(cat, typeMap);

            if (typeBox.Items.Count > 0)
            {
                typeBox.SelectedIndex  = 0;
                typeList.SelectedIndex = 0;
            }
            else
            {
                current = dummy;
            }

            UpdateContribution();
        }
Exemplo n.º 8
0
 // give <structure> tag, which contains <category> as children.
 /// <summary>
 ///
 /// </summary>
 /// <param name="node"></param>
 /// <param name="idContrib"></param>
 public StructCategories(XmlNode node, string idContrib)
 {
     foreach (XmlNode cn in node)
     {
         if (cn.Name.Equals("category"))
         {
             XmlAttribute   a   = cn.Attributes["byid"];
             StructCategory cat = null;
             if (a != null)
             {
                 cat = StructCategoryTree.theInstance[int.Parse(a.Value, NumberStyles.HexNumber)];
             }
             else
             {
                 a = cn.Attributes["byname"];
                 if (a != null)
                 {
                     cat = StructCategoryTree.theInstance[a.Value];
                 }
             }
             if (cat == null)
             {
                 cat = StructCategory.Root;
             }
             if (!array.Contains(cat.idnum))
             {
                 array.Add(cat.idnum);
             }
             a = cn.Attributes["hide"];
             if (a == null || !a.Value.Equals("true"))
             {
                 cat.Entries.Add(idContrib);
             }
         }
     }
 }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="worktable"></param>
        protected void SetCategoryEntries(StructCategory cat, Hashtable worktable)
        {
            int n = cat.Entries.Count;

            for (int i = 0; i < n; i++)
            {
                GenericStructureContribution contrib
                    = (GenericStructureContribution)PluginManager.GetContribution((string)cat.Entries[i]);
                string key = contrib.Name;
                if (!worktable.ContainsKey(key))
                {
                    typeBox.Items.Add(contrib);
                    typeList.Items.Add(contrib);
                    worktable.Add(key, new ArrayList());
                }
                designMap = (ArrayList)worktable[key];
                designMap.Add(contrib);
            }
            n = cat.Subcategories.Count;
            for (int i = 0; i < n; i++)
            {
                SetCategoryEntries(cat.Subcategories[i], typeMap);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 public StructCategories(StructCategory cat)
 {
     this.Add(cat);
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <returns></returns>
 public bool Contains(StructCategory cat)
 {
     return(array.Contains(cat.idnum));
 }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <returns></returns>
 public int Add(StructCategory cat)
 {
     return(array.Add(cat.idnum));
 }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <returns></returns>
        public StructCategory getParent(StructCategory cat)
        {
            int pid = cat.idnum >> 8;

            return(this[pid]);
        }