示例#1
0
        public void LoadData(LimnorContextMenuCollection type)
        {
            _menus = type;
            //
            List <MenuItemDataProperty> ps = _menus.PrimaryProperties;

            if (ps != null && ps.Count > 0)
            {
                foreach (MenuItemDataProperty p in ps)
                {
                    lstP.Items.Add(p);
                }
            }
            List <MenuItemDataProperty> sps = _menus.SecondaryProperties;

            if (sps != null && sps.Count > 0)
            {
                foreach (MenuItemDataProperty p in sps)
                {
                    lstS.Items.Add(p);
                }
            }
            SortedDictionary <string, IProperty> all         = _menus.GetAllProperties();
            SortedDictionary <string, TreeNode>  customNodes = new SortedDictionary <string, TreeNode>();

            foreach (KeyValuePair <string, IProperty> kv in all)
            {
                PropertyPointer pi = kv.Value as PropertyPointer;
                if (pi != null)
                {
                    treeViewAll.Nodes.Add(new TreeNodeProperty(false, pi));
                }
                else
                {
                    PropertyClass pc = kv.Value as PropertyClass;
                    if (pc != null)
                    {
                        //use 0 as the scope method Id because property selection does not method scope
                        TreeNodeCustomProperty tnc = new TreeNodeCustomProperty(treeViewAll, pc.IsStatic, pc, 0);
                        customNodes.Add(tnc.Text, tnc);
                    }
                }
            }
            int i = 0;

            foreach (KeyValuePair <string, TreeNode> kv in customNodes)
            {
                treeViewAll.Nodes.Insert(i++, kv.Value);
            }
            //
        }
示例#2
0
 private void treeViewAll_AfterSelect(object sender, TreeViewEventArgs e)
 {
     btOK.Enabled = false;
     if (e.Node != null)
     {
         TreeNodeProperty tnp = e.Node as TreeNodeProperty;
         if (tnp != null)
         {
             btOK.Enabled = !tnp.Property.IsReadOnly;
         }
         else
         {
             TreeNodeCustomProperty tncp = e.Node as TreeNodeCustomProperty;
             if (tncp != null)
             {
                 btOK.Enabled = tncp.Property.CanWrite;
             }
         }
     }
 }