private void TreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { Point point = e.GetPosition(TreeView_Item); RemoteTreeViewItem element = TreeView_Item.GetElementFromPoint <RemoteTreeViewItem>(point); if (element != null) { if (element.IsHeaderEdit == false && element.RemoteType != RemoteType.dir) { RemoteItems.OpenRemote((RemoteTreeViewItem)TreeView_Item.SelectedItem, DbItemSetting.OPEN_DEFAULT); } } } catch (Exception ex) { MainWindow.ShowMessageDialog("错误", ex.Message); } }
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); } }