private void SetDirButton_Click(object sender, RoutedEventArgs e) { var index = PathBox.SelectedIndex; if (index == -1) { return; } var fbd = new System.Windows.Forms.FolderBrowserDialog(); var result = fbd.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return; } string dir = fbd.SelectedPath; if (!Directory.Exists(dir)) { return; } Items[index].Path = dir; PathBox.Focus(); }
void SelectPath(object sender, RoutedEventArgs e) { dynamic ai; if (isFullBox) { ai = (Addin)DataContext; } else { ai = (GlobalAddin)DataContext; } if (!String.IsNullOrWhiteSpace(ai.Path)) { initialFolder = Path.GetDirectoryName(ai.Path); } var ofd = new OpenFileDialog { DereferenceLinks = true, Filter = "Add-ins (*.xlam;*.xla;*.xll)|*.xlam;*.xla;*.xll|Excel Files (*.xls*)|*.xls*|All files (*.*)|*.*", FilterIndex = index, InitialDirectory = initialFolder, Title = "Select file" }; if (ofd.ShowDialog(this) == false) { return; } index = ofd.FilterIndex; ai.Path = ofd.FileName; if (isFullBox) { if (Path.GetExtension(ai.Path).Equals(".XLL", StringComparison.OrdinalIgnoreCase)) { ai.Arch = Configuration.Instance.LocalSettings.ExcelArch.ToString(); } else { ai.Arch = Addin.ANY; } ArchBox.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateTarget(); } PathBox.GetBindingExpression(TextBox.TextProperty).UpdateTarget(); PathBox.Focus(); }
private void Save_Click(object sender, RoutedEventArgs e) { PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items)); if (PathType == PathType.User) { PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items)); } else { BatchMode.UseBatchModeAsAdmin(Items); } DisabledItems.SaveDisabledItems(PathType, Items); PathBox.Focus(); }
private async void GetFile() { try { if (string.IsNullOrEmpty(state.FilePath.Trim())) { PathBox.Focus(); throw new Exception("请输入路径"); } await Task.Run(() => { state.IsEnabled = false; GetFileList(state.FilePath); }); } catch (Exception ex) { ShowMessage(ex.Message); } finally { state.IsEnabled = true; } }
private void SetItemFocus(int index) { PathBox.SelectedIndex = index; PathBox.ScrollIntoView(Items[index]); PathBox.Focus(); }