Example #1
0
 private void OnAddGroupClick(object sender, EventArgs e)
 {
     try
     {
         DlgAddGroup adg = new DlgAddGroup();
         if (adg.ShowDialog() == DialogResult.OK)
         {
             BaseNode bn = (BaseNode)this.SelectedNode;
             GroupNode gn = new GroupNode(adg.GroupName);
             bn.Nodes.Add(gn);
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex);
     }
 }
Example #2
0
        public void InitialNodes()
        {
            //set images
            imageListIcon.ColorDepth = ColorDepth.Depth32Bit;//不然图片会失真,周围会有黑线
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_USERS));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_USER));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_ADDUSER));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_KEYS));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_DELETE));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_WEBBROWSER));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_OPERATIONCONFIG));
            imageListIcon.Images.Add(ImageCtrl.GetIconFromResx(TreeConstants.IMAGE_REFRESH));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_ROOT));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TreeConstants.ICON_XML));

            this.ImageList = imageListIcon;  

            //set nodes
            base.Nodes.Clear();

            //build Root node
            BaseNode Root = new BaseNode("所有帐号");
            base.Nodes.Add(Root);

            //build Groups node
            string[] groups = ConfigCtrl.GetGroups();
            foreach (string group in groups)
            {
                GroupNode gn = new GroupNode(group);
                Root.Nodes.Add(gn);

                //build Accounts node
                Collection<AccountInfo> accounts = ConfigCtrl.GetAccounts(group);
                if (accounts != null)
                {
                    gn.Text = gn.Text + "(" + accounts.Count + ")";
                    foreach (AccountInfo account in accounts)
                    {
                        AccountNode sn = new AccountNode(account);
                        gn.Nodes.Add(sn);
                    }
                }
            }
            
            if (Root.Nodes.Count > 0)
            {
                Root.Expand();
            }
        }