private void OnDeleteClick(object sender, EventArgs e) { try { if (MessageBox.Show("确认要删除么?", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.OK) { AccountNode un = this.SelectedNode as AccountNode; AccountInfo account = null; if (un != null) { account = un.Account; } if (account != null) { GroupNode gn = (GroupNode)un.Parent; string ret = ConfigCtrl.DeleteAccount(gn.GroupName, account); if (ret != Constants.STATUS_SUCCESS) { MessageBox.Show(ret, Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } gn.Nodes.Remove(un); gn.Text = gn.GroupName + "(" + gn.Nodes.Count + ")"; } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
private void OnEditAccountClick(object sender, EventArgs e) { try { AccountNode un = this.SelectedNode as AccountNode; if (un != null) { GroupNode gn = un.Parent as GroupNode; if (gn != null) { DlgAddAccount adu = new DlgAddAccount(); adu.GroupName = gn.GroupName; adu.OldEmail = un.Account.Email; adu.Account = un.Account; if (adu.ShowDialog() == DialogResult.OK) { un.Text = adu.Account.UserName; un.Account = adu.Account; OnAfterSelect(null, null); } } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
private void OnAfterSelect(object sender, TreeViewEventArgs e) { try { if (this.SelectedNode is GroupNode) { GroupNode bn = this.SelectedNode as GroupNode; if (bn != null) { GroupEventArgs ge = new GroupEventArgs(); ge.Group = bn.GroupName; ge.Accounts = new Collection <AccountInfo>(); foreach (AccountNode accountnode in bn.Nodes) { ge.Accounts.Add(accountnode.Account); } OnGroupNodeSelected(ge); } } else if (this.SelectedNode is AccountNode) { AccountNode an = this.SelectedNode as AccountNode; AccountEventArgs ae = new AccountEventArgs(); if (an != null) { ae.Account = an.Account; } else { ae.Account = null; } OnAccountNodeSelected(ae); } else if (this.SelectedNode is BaseNode) { BaseNode bn = this.SelectedNode as BaseNode; if (bn != null) { RootNodeEventArgs re = new RootNodeEventArgs(); re.Groups = new string[bn.Nodes.Count]; for (int ix = 0; ix < bn.Nodes.Count; ix++) { GroupNode gn = bn.Nodes[ix] as GroupNode; if (gn != null) { re.Groups[ix] = gn.GroupName; } } OnRootNodeSelected(re); } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
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(); } }
private void OnOpenInBrowserClick(object sender, EventArgs e) { try { AccountNode un = this.SelectedNode as AccountNode; if (un != null) { AccountEventArgs te = new AccountEventArgs(); te.Account = un.Account; OnOpenInBrowser(te); } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
private void OnOpenOperationConfigClick(object sender, EventArgs e) { try { AccountNode an = this.SelectedNode as AccountNode; if (an != null) { AccountEventArgs te = new AccountEventArgs(); GroupNode gn = an.Parent as GroupNode; te.Group = gn.GroupName; te.Account = an.Account; OnOpenOperationConfig(te); } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
private void OnAddAccountClick(object sender, EventArgs e) { try { GroupNode gn = this.SelectedNode as GroupNode; if (gn != null) { DlgAddAccount adu = new DlgAddAccount(); adu.GroupName = gn.GroupName; if (adu.ShowDialog() == DialogResult.OK) { AccountNode un = new AccountNode(adu.Account); gn.Nodes.Add(un); gn.Text = gn.GroupName + "(" + gn.Nodes.Count + ")"; } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
private void OnAddAccountClick(object sender, EventArgs e) { try { GroupNode gn = this.SelectedNode as GroupNode; if (gn != null) { DlgAddAccount adu = new DlgAddAccount(); adu.GroupName = gn.GroupName; if (adu.ShowDialog() == DialogResult.OK) { AccountNode un = new AccountNode(adu.Account); gn.Nodes.Add(un); gn.Text = gn.GroupName + "(" + gn.Nodes.Count + ")"; } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TreeConstants.EXCEPTION_MODULE, ex); } }
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(); } }