void SetTreeNodeServerMenu(TreeView tree, TreeViewItem item) { TreeNodeServer treenodeserver = (TreeNodeServer)tree.SelectedItem; ContextMenu cm = new ContextMenu(); MenuItem menu_link = new MenuItem(); menu_link.Header = "连接"; menu_link.Click += delegate(object obj, RoutedEventArgs earg) { SetTreeNodeDatabase(treenodeserver); }; cm.Items.Add(menu_link); if (treenodeserver.childer.Count > 0) { menu_link.IsEnabled = false; } MenuItem menu_unlink = new MenuItem(); menu_unlink.Header = "断开"; menu_unlink.Click += delegate(object obj, RoutedEventArgs earg) { treenodeserver.childer.Clear(); }; cm.Items.Add(menu_unlink); cm.Items.Add(new Separator()); MenuItem menu_del = new MenuItem(); menu_del.Header = "删除"; menu_del.Click += delegate(object obj, RoutedEventArgs earg) { MessageBoxResult mbr = SystemError.ConfrimOKCancel("确定删除此服务器实例吗?"); if (mbr == MessageBoxResult.OK) { if (ConfigJson.DelLink(treenodeserver.id)) { DelTreeNodeServer(treenodeserver.id); SystemError.Information("删除成功"); } } }; cm.Items.Add(menu_del); item.ContextMenu = cm; }