예제 #1
0
        private async void DeleteRemoteItem(RemoteTreeViewItem selectItem)
        {
            MainWindow mainWindow = Window.GetWindow(this) as MainWindow;

            if (mainWindow != null)
            {
                var result = await mainWindow.ShowMessageAsync("提示", $"是否要删除 “{selectItem.Header}”", MessageDialogStyle.AffirmativeAndNegative);

                if (result == MessageDialogResult.Affirmative)
                {
                    RemoteItems.Delete(selectItem);
                }
            }
        }
예제 #2
0
        private void TreeView_KeyDown(object sender, KeyEventArgs e)
        {
            RemoteTreeViewItem selectItem = TreeView_Item.SelectedItem as RemoteTreeViewItem;

            if (selectItem == null)
            {
                return;
            }

            if (e.Key == Key.F2)
            {
                selectItem.HeaderEdit(Home_Tree_EditHeaderClosing);
            }
            if (e.Key == Key.Delete)
            {
                RemoteItems.Delete(selectItem);
            }
        }
예제 #3
0
        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);
            }
        }