public override void OnApplyTemplate() { base.OnApplyTemplate(); AddPlugin.Command = new RelayCommand(() => { var ofd = new VistaOpenFileDialog(); ofd.Filter = ".NET assemblies (*.exe, *.dll)|*.exe;*.dll|All Files (*.*)|*.*"; ofd.Multiselect = true; if (ofd.ShowDialog() ?? false) { foreach (string plugin in ofd.FileNames) { try { ComponentDiscovery.LoadComponents(project.Protections, project.Packers, plugin); project.Plugins.Add(new StringItem(plugin)); } catch { MessageBox.Show("Failed to load plugin '" + plugin + "'."); } } } }); RemovePlugin.Command = new RelayCommand(() => { int selIndex = PluginPaths.SelectedIndex; Debug.Assert(selIndex != -1); string plugin = project.Plugins[selIndex].Item; ComponentDiscovery.RemoveComponents(project.Protections, project.Packers, plugin); project.Plugins.RemoveAt(selIndex); PluginPaths.SelectedIndex = selIndex >= project.Plugins.Count ? project.Plugins.Count - 1 : selIndex; }, () => PluginPaths.SelectedIndex != -1); AddProbe.Command = new RelayCommand(() => { var fbd = new VistaFolderBrowserDialog(); if (fbd.ShowDialog() ?? false) { project.ProbePaths.Add(new StringItem(fbd.SelectedPath)); } }); RemoveProbe.Command = new RelayCommand(() => { int selIndex = ProbePaths.SelectedIndex; Debug.Assert(selIndex != -1); project.ProbePaths.RemoveAt(selIndex); ProbePaths.SelectedIndex = selIndex >= project.ProbePaths.Count ? project.ProbePaths.Count - 1 : selIndex; }, () => ProbePaths.SelectedIndex != -1); }
private string SelectImageFile() { var dialog = new VistaOpenFileDialog(); dialog.Title = _xamlCreateModDialogSelectorTitle.Get(); dialog.Filter = $"{_xamlCreateModDialogSelectorFilter.Get()} {Constants.WpfSupportedFormatsFilter}"; if ((bool)dialog.ShowDialog()) { return(dialog.FileName); } return(""); }
private string SelectJsonFile() { var dialog = new VistaOpenFileDialog(); dialog.Title = Resources.AddAppRepoTestJsonSelectTitle.Get(); dialog.Filter = $"{Resources.AddAppRepoTestJsonSelectFilter.Get()} (*.json)|*.json"; if ((bool)dialog.ShowDialog() !) { return(dialog.FileName); } return(""); }
/// <summary> /// Opens up a file selection dialog allowing for the selection of an executable to associate with the profile. /// </summary> private string SelectEXEFile() { var dialog = new VistaOpenFileDialog(); dialog.Title = _xamlAddAppExecutableTitle.Get(); dialog.Filter = $"{_xamlAddAppExecutableFilter.Get()} (*.exe)|*.exe"; if ((bool)dialog.ShowDialog()) { return(dialog.FileName); } return(""); }
void btnShowLights_Click(object sender, EventArgs e) { using (var f = new VistaOpenFileDialog()) { f.InitialDirectory = Path.GetDirectoryName(ShowLightsPath); f.FileName = ShowLightsPath; f.Filter = "Rocksmith 2014 ShowLight XML Files (*_showlights.xml)|*_showlights.xml"; if (f.ShowDialog() == DialogResult.OK) { ShowLightsPath = f.FileName; PopulateRichText(); } } }
private void ImportKey() { try { this.ClearErrors(); var dialog = new VistaOpenFileDialog { Title = "Select Virgil Card", Multiselect = false, CheckFileExists = true, CheckPathExists = true, ReadOnlyChecked = true, DefaultExt = "*.vcard", Filter = "All files (*.*)|*.*|Virgil Card Files (*.vcard)|*.vcard", FilterIndex = 2 }; if (dialog.ShowDialog() == true) { var text = Encoding.UTF8.GetString(Convert.FromBase64String(File.ReadAllText(dialog.FileName))); try { var virgilCardDtos = JsonConvert.DeserializeObject <VirgilCardDto[]>(text); this.Cards.Clear(); foreach (var dto in virgilCardDtos) { this.Cards.Add(dto); } this.SelectedCard = this.Cards.First(); } catch (JsonException) { var virgilCardDto = JsonConvert.DeserializeObject <VirgilCardDto>(text); this.Cards.Clear(); this.Cards.Add(virgilCardDto); this.SelectedCard = virgilCardDto; } this.IsMultipleKeys = this.Cards.Count > 1; this.SelectedPath = Path.GetFileName(dialog.FileName); } } catch (Exception) { this.SelectedPath = ""; this.RaiseErrorMessage("Malformed on unaccessible file"); } }
/// <summary> /// Opens a open file dialog with specified owner. /// </summary> /// <param name="owner"> /// Handle to the window that owns the dialog. /// </param> /// <returns> /// true if user clicks the OK button; otherwise false. /// </returns> public bool?ShowDialog(Window owner) { if (owner == null) { throw new ArgumentNullException(nameof(owner)); } var result = openFileDialog.ShowDialog(owner); // Update settings settings.FileName = openFileDialog.FileName; settings.FileNames = openFileDialog.FileNames; return(result); }
private void ShowOpenFileDialog() { // As of .Net 3.5 SP1, WPF's Microsoft.Win32.OpenFileDialog class still uses the old style VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Filter = "All files (*.*)|*.*"; if (!VistaFileDialog.IsVistaFileDialogSupported) { MessageBox.Show(this, "Because you are not using Windows Vista or later, the regular open file dialog will be used. Please use Windows Vista to see the new dialog.", "Sample open file dialog"); } if ((bool)dialog.ShowDialog(this)) { MessageBox.Show(this, "The selected file was: " + dialog.FileName, "Sample open file dialog"); } }
private string SelectEXEFile() { var dialog = new VistaOpenFileDialog(); dialog.Title = Resources.AddAppExecutableTitle.Get(); dialog.Filter = $"{Resources.AddAppExecutableFilter.Get()} (*.exe)|*.exe"; dialog.FileName = ApplicationConfig.GetAbsoluteAppLocation(Application); if ((bool)dialog.ShowDialog() !) { return(dialog.FileName); } return(""); }
private void btnVocalsDdsPath_Click(object sender, EventArgs e) { // The Toolkit writes this artifact to: /assets/ui/lyrics/[dlcName]/lyrics_[dlcName].dds using (var f = new VistaOpenFileDialog()) { f.InitialDirectory = Path.GetDirectoryName(VocalsPath); f.FileName = ArtPath; f.Title = "Select a Custom Lyric Font DDS Texture"; f.Filter = "Custom Lyrics Font Files (*.dds)|*.dds"; if (f.ShowDialog() == DialogResult.OK) { ArtPath = f.FileName; } } }
//Change boxart private void ChangeButton_Click(object sender, RoutedEventArgs e) { VistaOpenFileDialog artBrowser = new VistaOpenFileDialog(); artBrowser.Filter = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png"; artBrowser.Title = "Browse to a new boxart image"; if (artBrowser.ShowDialog().Value == true) { File.Copy(artBrowser.FileName, BaseDirectory + @"resources\configs\" + title + @"\art.jpg", true); Uri _img = new Uri(BaseDirectory + @"resources\configs\" + title + @"\art.jpg"); CacheImage(_img); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { using (Ookii.Dialogs.WinForms.VistaFileDialog ofd = new VistaOpenFileDialog()) { string[] s1Descript = context.PropertyDescriptor.Description.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ofd.Filter = @"|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { return(ofd.FileName); } } return(value); }
private void Button_Click(object sender, RoutedEventArgs e) { var dlg = new VistaOpenFileDialog(); dlg.Filter = App.Translation.Misc.Filter_FilenameEditor; dlg.FilterIndex = 0; dlg.Multiselect = false; dlg.CheckFileExists = false; if (dlg.ShowDialog() != true) { return; } textbox.Text = Ut.MakeRelativePath(LastContext, dlg.FileName); _expression.UpdateSource(); }
private void Import(string obj) { if (openFileDialog == null) { openFileDialog = new VistaOpenFileDialog(); openFileDialog.Filter = "Json file|*.json|All files|*.*"; openFileDialog.DefaultExt = "json"; } if (openFileDialog.ShowDialog() == true) { Filename = openFileDialog.FileName; openFromFile(); } }
public string OpenFileBrowser(string filter, string windowTitle) { var dialog = new VistaOpenFileDialog() { Filter = filter, Title = windowTitle }; if (dialog.ShowDialog() ?? false) { return(dialog.FileName); } return(""); }
private void Import_Click(object sender, RoutedEventArgs e) { var openFileDialog = new VistaOpenFileDialog { Title = "Import physics data from binary format", AddExtension = true, Filter = "Binary File (*.bin)|*.bin", DefaultExt = ".bin", }; if ((bool)openFileDialog.ShowDialog()) { ViewModel.Load(openFileDialog.FileName); } }
private static bool CheckForTesseract() { if (!File.Exists((string)Settings.Default["TesseractPath"])) { if (ExistsInPath("tesseract.exe")) { Settings.Default ["TesseractPath"] = "tesseract.exe"; Settings.Default.Save(); return(true); } TaskDialog dialog = new TaskDialog(); dialog.WindowTitle = "Warning Tesseract Not Found"; dialog.MainIcon = TaskDialogIcon.Warning; dialog.MainInstruction = "Tesseract executable could not be located."; dialog.Content = @"Miharu requires Tesseract to function. Would you like to locate the Tesseract exectutable manually?"; TaskDialogButton okButton = new TaskDialogButton(ButtonType.Yes); dialog.Buttons.Add(okButton); TaskDialogButton cancelButton = new TaskDialogButton(ButtonType.No); dialog.Buttons.Add(cancelButton); TaskDialogButton button = dialog.ShowDialog(); if (button.ButtonType == ButtonType.No) { return(false); } VistaOpenFileDialog fileDialog = new VistaOpenFileDialog(); fileDialog.AddExtension = true; fileDialog.CheckFileExists = true; fileDialog.CheckPathExists = true; fileDialog.DefaultExt = ".exe"; fileDialog.Filter = "Tesseract (tesseract.exe)|tesseract.exe"; fileDialog.Multiselect = false; fileDialog.Title = "Select Tesseract Executable"; bool?res = fileDialog.ShowDialog(); if (res ?? false) { Settings.Default ["TesseractPath"] = fileDialog.FileName; Settings.Default.Save(); } else { return(false); } } return(true); }
private void NewChapterFilesMenuItem_Click(object sender, RoutedEventArgs e) { if (_chapterManager.IsChapterLoaded && !_chapterManager.IsChapterSaved) { string saveRes = WarnNotSaved(); if (saveRes == GetResource("SaveButtonText")) { SaveChapterMenuItem_Click(sender, new RoutedEventArgs()); } else if (saveRes == GetResource("CancelButtonText")) { return; } } VistaOpenFileDialog filesDialog = new VistaOpenFileDialog(); filesDialog.Multiselect = true; filesDialog.Title = "Select Images"; filesDialog.AddExtension = true; filesDialog.CheckFileExists = true; filesDialog.CheckPathExists = true; filesDialog.DefaultExt = ".png"; filesDialog.Filter = "Images (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png"; bool?res = filesDialog.ShowDialog(this); if (res ?? false) { try { Mouse.SetCursor(Cursors.Wait); _chapterManager.NewChapter(filesDialog.FileNames); GC.Collect(); Mouse.SetCursor(Cursors.Arrow); } catch (Exception ex) { Mouse.SetCursor(Cursors.Arrow); using (TaskDialog dialog = new TaskDialog()) { dialog.WindowTitle = "Error"; dialog.MainIcon = TaskDialogIcon.Error; dialog.MainInstruction = "There was an error loading the chapter."; dialog.Content = ex.Message; TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(okButton); TaskDialogButton button = dialog.ShowDialog(this); } } } }
private void btnFindInputPath_Click(object sender, EventArgs e) { if (IsServiceClass.IsService) { if (txtInputPath.Text.EndsWith("\\")) { txtInputPath.Text = txtInputPath.Text.Substring(0, txtInputPath.Text.LastIndexOf("\\")); } string path = AppConfigHelper.NormalizePathToWindows(txtInputPath.Text); // We want an actual file, so don't append "\\". if (analysis == "Kraken2" && radUseFastq.Checked) { path = AppConfigHelper.NormalizePathToWindows(path + "\\"); Cursor.Current = Cursors.WaitCursor; Explorer.frmExplorer = new Explorer(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig(), "Input path to folder with .fastq files", DirectoryHelper.IsServerPath(path), DirectoryHelper.CleanPath(path), string.Empty, null, AppConfigHelper.UbuntuPrefix()); } else { Explorer.frmExplorer = new Explorer(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig(), "Input path to folder with .fasta contig file", DirectoryHelper.IsServerPath(path), DirectoryHelper.CleanPath(path), "Fasta files (*.fasta)|*.fasta;*.fna;*.fa|All files (*.*)|*.*", null, AppConfigHelper.UbuntuPrefix()); } Explorer.frmExplorer.ShowDialog(); if (Explorer.frmExplorer.DialogResult == DialogResult.OK) { txtInputPath.Text = Explorer.PresentServerPath + Explorer.PresentLocalPath; // One of these is empty. } Explorer.frmExplorer = null; } else { VistaOpenFileDialog ofn = new VistaOpenFileDialog(); string path = AppConfigHelper.NormalizePathToWindows(txtInputPath.Text); ofn.InitialDirectory = path; ofn.Title = "Input path to folder with .fasta contig file"; ofn.CheckFileExists = true; ofn.FileName = ofn.InitialDirectory = AppConfigHelper.FileExists(path); ofn.Filter = "Fasta files (*.fasta)|*.fasta;*.fna;*.fa|All files (*.*)|*.*"; if (ofn.ShowDialog() != DialogResult.Cancel) { txtInputPath.Text = ofn.FileName.Trim(); } } EnableOK(); }
private void OnBrowseButtonClicked(object sender, RoutedEventArgs e) { var dialog = new VistaOpenFileDialog() { Multiselect = false, CheckFileExists = true, Filter = "Factorio Executable (factorio.exe)| factorio.exe", }; if (dialog.ShowDialog() == true) { TextBoxLocation.Text = dialog.FileName; } e.Handled = true; }
private void OnAddSolution(object obj) { VistaOpenFileDialog ofd = new VistaOpenFileDialog(); ofd.AddFilter("sln"); bool?result = ofd.ShowDialog(_mainWindow); if (!result.HasValue || !result.Value) { return; } Solution solution = Solution.OpenSolution(ofd.FileName); SolutionCollection.AddSolution(solution); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { string path = Convert.ToString(value); using (var dialog = new VistaOpenFileDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { path = dialog.FileName; } } return(new PathToFile { AbsolutePath = path }); }
public override Task Run(Command command) { var dialog = new VistaOpenFileDialog { Filter = "Log Files (*.log)|*.log", InitialDirectory = new FactorioScriptOutputFolder().Path }; if (dialog.ShowDialog() == true) { _output.SetFilePath(dialog.FileName); _shell.ShowTool(_output); } return(Task.CompletedTask); }
/// <summary> /// Launches a select file dialog and returns the selected path. /// </summary> /// <returns></returns> private string ShowSelectOriginFileDialog() { VistaOpenFileDialog selectFileDialog = new VistaOpenFileDialog { Multiselect = false, ValidateNames = true, AddExtension = true, CheckFileExists = true, CheckPathExists = true, Title = "Select a file" }; selectFileDialog.ShowDialog(); return(selectFileDialog.FileName); }
public static bool SelectKeyfile() { using (var selectFileDialog = new VistaOpenFileDialog()) { selectFileDialog.Title = "Select Keyfile"; if (selectFileDialog.ShowDialog() == DialogResult.OK) { Globals.KeyfilePath = selectFileDialog.FileName; return(true); } else { return(false); } } }
private void CertificateButtonClick(object sender, RoutedEventArgs e) { var dialog = new VistaOpenFileDialog { Filter = @"Certificates files (*.pk12)|*.pk12|All files (*.*)|*.*", CheckFileExists = true, Multiselect = false, }; if (dialog.ShowDialog(this) != true) { return; } Properties.Settings.Default.CertFile = dialog.FileName; }
private void BrowseButton_Click(object sender, RoutedEventArgs e) { var fileBrowser = new VistaOpenFileDialog { CheckFileExists = true, CheckPathExists = true, Filter = Properties.Resources.SupportedAudioFilesFilter }; if (fileBrowser.ShowDialog() != true) { return; } FilePath = fileBrowser.FileName; }
/// <summary> /// FileDialog for picking multiple file(s) /// </summary> /// <param name="browserProperties">Special Properties of File Dialog</param> /// <param name="filepath">User picked path(s) (Callback)</param> public void OpenMultiSelectFileBrowser(BrowserProperties browserProperties, Action <string[]> filepath) { var ofd = new VistaOpenFileDialog(); ofd.Multiselect = true; ofd.Title = browserProperties.title == null ? "Select a File" : browserProperties.title; ofd.InitialDirectory = browserProperties.initialDir == null ? @"C:\" : browserProperties.initialDir; ofd.Filter = browserProperties.filter == null ? "All files (*.*)|*.*" : browserProperties.filter; ofd.FilterIndex = browserProperties.filterIndex + 1; ofd.RestoreDirectory = browserProperties.restoreDirectory; if (ofd.ShowDialog(new WindowWrapper(GetActiveWindow())) == DialogResult.OK) { filepath(ofd.FileNames); } }
/// <summary> /// Import a CSV file /// </summary> private void Import() { VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "CSV files (*.csv)|*.csv", CheckFileExists = true }; dialog.ShowDialog(); string filename = dialog.FileName; if (string.IsNullOrEmpty(filename)) { return; } IDictionary <int, string> chapterMap = new Dictionary <int, string>(); try { StreamReader sr = new StreamReader(filename); string csv = sr.ReadLine(); while (csv != null) { if (csv.Trim() != string.Empty) { csv = csv.Replace("\\,", "<!comma!>"); string[] contents = csv.Split(','); int chapter; int.TryParse(contents[0], out chapter); chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ",")); } csv = sr.ReadLine(); } } catch (Exception) { // Do Nothing } // Now iterate over each chatper we have, and set it's name foreach (ChapterMarker item in Chapters) { string chapterName; chapterMap.TryGetValue(item.ChapterNumber, out chapterName); item.ChapterName = chapterName; // TODO force a fresh of this property } }
private void AddPageButton_Click(object sender, RoutedEventArgs e) { VistaOpenFileDialog fileDialog = new VistaOpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "Select Image"; fileDialog.AddExtension = true; fileDialog.CheckFileExists = true; fileDialog.CheckPathExists = true; fileDialog.DefaultExt = ".png"; fileDialog.Filter = "Images (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png"; bool?res = fileDialog.ShowDialog(this); if (res ?? false) { int previousIndex = PagesListBox.SelectedIndex; try { Mouse.SetCursor(Cursors.Wait); int index = _chapterManager.LoadedChapter.TotalPages - 1; if (PagesListBox.SelectedIndex >= 0) { index = PagesListBox.SelectedIndex; } foreach (string file in fileDialog.FileNames) { _chapterManager.AddPage(++index, file); } PagesListBox.Items.Refresh(); PagesListBox.SelectedIndex = index; UpdateButtons(); Mouse.SetCursor(Cursors.Arrow); } catch (Exception ex) { Mouse.SetCursor(Cursors.Arrow); PagesListBox.SelectedIndex = previousIndex; TaskDialog dialog = new TaskDialog(); dialog.WindowTitle = "Error"; dialog.MainIcon = TaskDialogIcon.Error; dialog.MainInstruction = "No images found."; dialog.Content = ex.Message; TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok); dialog.Buttons.Add(okButton); TaskDialogButton button = dialog.ShowDialog(this); } } }
private void ShowOpenFileDialog() { // As of .Net 3.5 SP1, WPF's Microsoft.Win32.OpenFileDialog class still uses the old style VistaOpenFileDialog dialog = new VistaOpenFileDialog(); dialog.Filter = "All files (*.*)|*.*"; if( !VistaFileDialog.IsVistaFileDialogSupported ) MessageBox.Show(this, "Because you are not using Windows Vista or later, the regular open file dialog will be used. Please use Windows Vista to see the new dialog.", "Sample open file dialog"); if( (bool)dialog.ShowDialog(this) ) MessageBox.Show(this, "The selected file was: " + dialog.FileName, "Sample open file dialog"); }