private void NewRemoteItem(RemoteTreeViewItem selectItem, RemoteType type, string name = null) { if (name == null) { if (type == RemoteType.dir) { name = "新建目录"; } if (type == RemoteType.rdp) { name = "新建RDP连接"; } if (type == RemoteType.ssh) { name = "新建SSH连接"; } if (type == RemoteType.telnet) { name = "新建Telnet连接"; } } var treeViewItem = RemoteItems.Insert(type, selectItem, name); treeViewItem.UpdateLayout(); treeViewItem.HeaderEdit(Home_Tree_EditHeaderClosing); }
private void MenuItem_Click(object sender, RoutedEventArgs e) { try { MenuItem menuItem = sender as MenuItem; if (menuItem == null) { return; } RemoteTreeViewItem selectItem = (RemoteTreeViewItem)TreeView_Item.SelectedItem; RemoteTreeViewItem treeViewItem; switch (menuItem.Header.ToString()) { case "新建目录": treeViewItem = RemoteItems.Insert(RemoteType.dir, selectItem, "新建目录");; if (treeViewItem.IsVisible) { treeViewItem.Loaded += (treeItemsender, treeIteme) => treeViewItem.HeaderEdit(Home_Tree_EditHeaderClosing); } break; case "RDP连接": treeViewItem = RemoteItems.Insert(RemoteType.rdp, selectItem, "新建RDP连接"); if (treeViewItem.IsVisible) { treeViewItem.Loaded += (treeItemsender, treeIteme) => treeViewItem.HeaderEdit(Home_Tree_EditHeaderClosing); } break; case "SSH连接": treeViewItem = RemoteItems.Insert(RemoteType.ssh, selectItem, "新建SSH连接"); if (treeViewItem.IsVisible) { treeViewItem.Loaded += (treeItemsender, treeIteme) => treeViewItem.HeaderEdit(Home_Tree_EditHeaderClosing); } break; case "Telnet连接": treeViewItem = RemoteItems.Insert(RemoteType.telnet, selectItem, "新建Telnet连接"); if (treeViewItem.IsVisible) { treeViewItem.Loaded += (treeItemsender, treeIteme) => treeViewItem.HeaderEdit(Home_Tree_EditHeaderClosing); } break; case "删除": RemoteItems.Delete(selectItem); break; case "打开": RemoteItems.OpenRemote(selectItem, DbItemSetting.OPEN_TAB); break; case "打开(后台)": RemoteItems.OpenRemote(selectItem, DbItemSetting.OPEN_TAB_BACKSTAGE); break; case "打开(外部)": RemoteItems.OpenRemote(selectItem, DbItemSetting.OPEN_WINDOW); break; case "重命名": selectItem.HeaderEdit(Home_Tree_EditHeaderClosing); break; } } catch (Exception ex) { MainWindow.ShowMessageDialog("错误", ex.Message); } }