private void CheckBox_PrivateKey_Click(object sender, RoutedEventArgs e) { if (CheckBox_PrivateKey.IsChecked.Value) { TextBox_PrivateKey.Visibility = Visibility.Visible; TextBox_Password.IsEnabled = false; TextBox_Password.Password = null; RemoteItems.ItemRemoteLink.Password = null; if (RemoteItems.ItemRemoteLink.PrivateKey == null) { RemoteItems.ItemRemoteLink.PrivateKey = ""; } TextBox_PrivateKey.Text = RemoteItems.ItemRemoteLink.PrivateKey; } else { TextBox_PrivateKey.Visibility = Visibility.Collapsed; TextBox_Password.IsEnabled = true; RemoteItems.ItemRemoteLink.PrivateKey = null; } if (sender != null) { RemoteItems.UpdateItemRemoteLink(); } }
private void TextBox_LostFocus(object sender, RoutedEventArgs e) { if (sender == TextBox_Name) { if (string.IsNullOrEmpty(TextBox_Name.Text)) { MainWindow.ShowNoticeDialog("提示", "名称不能为空。"); TextBox_Name.Text = RemoteItems.ItemRemoteLink.Name; return; } else { RemoteItems.ItemRemoteLink.Name = TextBox_Name.Text; if (PART_RemoteTree.SelectedItem != null) { RemoteItems.UpdateItemRemoteLink(); RemoteItems.SetItemName((RemoteTreeViewItem)PART_RemoteTree.SelectedItem, RemoteItems.ItemRemoteLink.Name); return; } } } if (sender == TextBox_Password) { RemoteItems.ItemRemoteLink.Password = TextBox_Password.Password; } RemoteItems.UpdateItemRemoteLink(); }
private void Home_Tree_EditHeaderClosing(object sender, CancelEditEventArgs e) { e.Cancel = true; RemoteTreeViewItem treeItem = sender as RemoteTreeViewItem; if (treeItem == null) { return; } if (string.IsNullOrEmpty(e.NewValue)) { MainWindow.ShowNoticeDialog("提示", "名称不能为空"); return; } if (treeItem.RemoteType == RemoteType.dir) { RemoteItems.GetItemDirectory(treeItem.uuid); RemoteItems.ItemDirectory.Name = e.NewValue; RemoteItems.UpdateItemDirectory(); } else if (RemoteItems.ItemRemoteLink != null && RemoteItems.ItemRemoteLink.Id == treeItem.uuid) { RemoteItems.ItemRemoteLink.Name = e.NewValue; RemoteItems.UpdateItemRemoteLink(); TextBox_Name.Text = e.NewValue; } RemoteItems.SetItemName(treeItem, e.NewValue); }
private void Button_PrivateKey_Upload_Click(object sender, RoutedEventArgs e) { OpenFileDialog op = new OpenFileDialog(); //op.InitialDirectory=默认的打开路径 op.RestoreDirectory = true; op.Filter = "所有文件(*.*)|*.*"; op.ShowDialog(); if (!string.IsNullOrEmpty(op.FileName)) { FileInfo fileInfo = new FileInfo(op.FileName); if (fileInfo.Length <= 10000) { RemoteItems.ItemRemoteLink.PrivateKey = File.ReadAllText(op.FileName); TextBox_PrivateKey.Text = RemoteItems.ItemRemoteLink.PrivateKey; RemoteItems.UpdateItemRemoteLink(); } else { MainWindow.ShowMessageDialog("错误", "密钥文件不能大于10000个字节"); } } }
private void MyExpander_IsExpanded(object sender, RoutedEventArgs e) { RemoteItems.UpdateItemRemoteLink(); }