PreferencesWindowViewModel() { var rSystemFonts = Fonts.SystemFontFamilies.Select(r => new SystemFont(r)).ToList(); var rCurrentFont = Preference.Current.UI.Font; if (!rSystemFonts.Any(r => r.FontFamily.Source == rCurrentFont)) rSystemFonts.Insert(0, new SystemFont(rCurrentFont)); SystemFonts = rSystemFonts.AsReadOnly(); LoadedPlugins = PluginService.Instance.LoadedPlugins.Select(r => new PluginViewModel(r)).ToList().AsReadOnly(); OpenFolderPickerCommand = new DelegatedCommand<string>(rpType => { using (var rFolderPicker = new CommonOpenFileDialog() { FolderPicker = true }) { if (rFolderPicker.Show() == CommonFileDialogResult.OK) { var rPath = rFolderPicker.Filename; switch (rpType) { case "Cache": Preference.Current.Cache.Path = rPath; break; case "Screenshot": Preference.Current.Browser.Screenshot.Destination = rPath; break; } } } }); OpenCustomSoundFileDialogCommand = new DelegatedCommand<string>(rpType => { using (var rDialog = new CommonOpenFileDialog()) { rDialog.FileTypes.Add(new CommonFileDialogFileType(StringResources.Instance.Main.PreferenceWindow_Notification_SoundFileType, "wav;mp3;aac;wma")); if (rDialog.Show() == CommonFileDialogResult.OK) { var rFilename = rDialog.Filename; switch (rpType) { case "General": Preference.Current.Notification.SoundFilename = rFilename; break; case "HeavilyDamaged": Preference.Current.Notification.HeavilyDamagedWarningSoundFilename = rFilename; break; } } } }); }
private void SelectFolder_Click(object sender, RoutedEventArgs e) { var dlg = new CommonOpenFileDialog(); dlg.Title = "Select Download Folder ..."; dlg.IsFolderPicker = true; dlg.AddToMostRecentlyUsedList = false; dlg.AllowNonFileSystemItems = false; dlg.EnsureFileExists = true; dlg.EnsurePathExists = true; dlg.EnsureReadOnly = false; dlg.EnsureValidNames = true; dlg.Multiselect = false; dlg.ShowPlacesList = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { DownloadFolderPath = dlg.FileName; // Do something with selected folder string } }
public void Execute(object parameter) { using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) { if (String.IsNullOrEmpty(model.CheckingPlanDir)) { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } else { dialog.InitialDirectory = model.CheckingPlanDir; } dialog.IsFolderPicker = true; // Show the dialog to set the path to the directory of the checking plan. if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { model.CheckingPlanDir = dialog.FileName; } }; }
public string SelectFolder(string default_folder = "") { var dlg = new CommonOpenFileDialog { Title = "Select the folder", IsFolderPicker = true, AddToMostRecentlyUsedList = false, InitialDirectory = default_folder, DefaultDirectory = default_folder, AllowNonFileSystemItems = false, EnsureFileExists = true, EnsurePathExists = true, EnsureReadOnly = false, EnsureValidNames = true, Multiselect = false, ShowPlacesList = true }; return(dlg.ShowDialog() == CommonFileDialogResult.Ok ? dlg.FileName : null); }
/// <inheritdoc /> public bool?ShowSelectFolderDialog([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out string folderPath, string title = null) { folderPath = null; using var dialog = new CommonOpenFileDialog(); if (title != null) { dialog.Title = title; } dialog.IsFolderPicker = true; dialog.Multiselect = false; switch (dialog.ShowDialog()) { case CommonFileDialogResult.Ok: folderPath = dialog.FileName; return(true); case CommonFileDialogResult.Cancel: return(false); default: return(null); } }
private void OpenDirectoryItem_Click(object sender, EventArgs e) { CommonOpenFileDialog dialog = new CommonOpenFileDialog() { RestoreDirectory = true, EnsureFileExists = true, Title = "Select Files", IsFolderPicker = true }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { foreach (var item in Directory.GetFiles(dialog.FileName)) { if (item.EndsWith(".java")) { AssignmentManager.NewAssignment(item); } } } UpdateList(); }
void btnChooseImagesFolder_Click(object sender, RoutedEventArgs e) { //needed check, if (CommonFileDialog.IsPlatformSupported) { var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; //CommonFileDialogResult result = dialog.ShowDialog(); if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { ServerSettings.ImagesPath = dialog.FileName; } } else { System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ServerSettings.ImagesPath = dialog.SelectedPath; } } }
private string SelectFile(params CommonFileDialogFilter[] filters) { var dialog = new CommonOpenFileDialog(); dialog.AllowNonFileSystemItems = true; dialog.IsFolderPicker = false; dialog.EnsurePathExists = true; dialog.EnsureValidNames = true; dialog.DefaultFileName = "Select file"; dialog.Title = "Select file"; foreach (var filter in filters) { dialog.Filters.Add(filter); } if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { return(dialog.FileName); } return(null); }
public void Execute(object parameter) { using (var dialog = new CommonOpenFileDialog()) { dialog.InitialDirectory = "C:\\"; dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { string path = dialog.FileName; string name = path.Split('\\').Last(); _service.AddResourceDirectory(new Domain.Models.ResourceDirectory() { Name = name, Path = path, LastAccessed = DateTime.Now }); _viewModel.RefreshView(); } } }
private void button5_Click(object sender, EventArgs e) { CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { iv.OutputDirectoryFilePath = dialog.FileName; //"\\" is added in the output part. textBox5.Text = iv.OutputDirectoryFilePath; mySettings.Default.textBox5OutputPath = iv.OutputDirectoryFilePath; } //FolderBrowserDialog fbd = new FolderBrowserDialog(); //DialogResult result = fbd.ShowDialog(); //if (result == DialogResult.OK) //{ // iv.OutputDirectoryFilePath = fbd.SelectedPath; // textBox5.Text = iv.OutputDirectoryFilePath; // mySettings.Default.textBox5OutputPath = iv.OutputDirectoryFilePath; //} }
private void cmdResetTrajectoryDataDirectory_Click(object sender, RoutedEventArgs e) { CommonOpenFileDialog openTrajectoryDataDirectoryDialog = new CommonOpenFileDialog { IsFolderPicker = true, Title = "打开轨迹数据文件夹" }; CommonFileDialogResult result = openTrajectoryDataDirectoryDialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { string directoryName = openTrajectoryDataDirectoryDialog.FileName; trajectoryFileNames = Directory.GetFiles(directoryName); currentTrajectoryIndex = 0; // Clear the existing trajectory before showing another trajectory. imageCanvas.Children.Clear(); currentTrajectory = new Trajectory(trajectoryFileNames[currentTrajectoryIndex]); currentTrajectory.Draw(imageCanvas, imageCanvas.ActualHeight * this.CurrentBackgroundImagePixelWidth / this.CurrentBackgroundImagePixelHeight, imageCanvas.ActualHeight, this.CurrentBackgroundImagePixelWidth, this.CurrentBackgroundImagePixelHeight); } }
public override void Execute(MainWindowViewModel parameter) { if (parameter.SelectedMapping == null) { return; } DirectoryInfo?dirInfo = parameter.SelectedMapping.Directory != null ? new DirectoryInfo(parameter.SelectedMapping.Directory) : null; var openDirectoryDialog = new CommonOpenFileDialog { IsFolderPicker = true, InitialDirectory = dirInfo != null && dirInfo.Exists && dirInfo.Parent != null ? dirInfo.Parent.FullName : null }; if (openDirectoryDialog.ShowDialog() == CommonFileDialogResult.Ok) { parameter.SelectedMapping.Directory = openDirectoryDialog.FileName; } }
private void b_Archive_Click(object sender, RoutedEventArgs e) { var dialog = new CommonOpenFileDialog(); dialog.Title = "Select the archive file"; if (dialog.ShowDialog() == CommonFileDialogResult.OK) { tb_ExtractArchive.Text = dialog.FileName; tb_Messages.Text = ""; using (var extr = new SevenZipExtractor(dialog.FileName)) { pb_Extract2.Maximum = extr.ArchiveFileData.Count; tb_Messages.BeginChange(); foreach (var item in extr.ArchiveFileData) { //tb_Messages.Text += string.Format("{0} [{1}]" + Environment.NewLine, item.FileName, item.Size); } tb_Messages.EndChange(); tb_Messages.ScrollToEnd(); } } }
private void Excel_Click(object sender, RoutedEventArgs e) { var l = new Loger(); var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; CommonFileDialogResult path = dialog.ShowDialog(); try { if (path == CommonFileDialogResult.Ok) { l.MakeLogIntoExcelFile(dialog.FileName); } } catch (Exception ex) { Debug.WriteLine(ex.Message); MessageBox.Show($"Cannot access file", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void FileButtonClick(object sender, RoutedEventArgs e) { var folderPicker = new CommonOpenFileDialog(); folderPicker.Title = "Select closest common ancestor of enlistments."; folderPicker.IsFolderPicker = true; var result = folderPicker.ShowDialog(); switch (result) { case CommonFileDialogResult.Ok: FileName.Text = folderPicker.FileName; FileName.ToolTip = folderPicker.FileName; break; case CommonFileDialogResult.Cancel: default: FileName.Text = null; FileName.ToolTip = null; return; } }
private void CmdAddFolder_Click(object sender, RoutedEventArgs e) { using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) { dialog.IsFolderPicker = true; dialog.Title = "Please select the folder you want to watch for new PDFs."; CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { Logging.Info("The user starting watching folder {0}", dialog.FileName); if (string.IsNullOrEmpty(TxtFolders.Text)) { TxtFolders.Text = dialog.FileName; } else { TxtFolders.Text += "\r\n" + dialog.FileName; } } } }
private string AskForFile() { var dialog = new CommonOpenFileDialog { IsFolderPicker = false }; dialog.ShowDialog(this); try { if (string.IsNullOrEmpty(dialog?.FileName)) { return(null); } return(dialog.FileName); } catch (Exception ex) { return(null); } }
private bool AskHearthstoneLocation(out string hsLocation) { hsLocation = String.Empty; var dialog = new CommonOpenFileDialog { EnsurePathExists = true, EnsureFileExists = true, DefaultDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Battle.net"), InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Battle.net"), Multiselect = false, EnsureValidNames = true, Title = "Find Battle.net location", IsFolderPicker = true, AllowNonFileSystemItems = false, AllowPropertyEditing = false, RestoreDirectory = true }; do { var result = dialog.ShowDialog(); if (result != CommonFileDialogResult.Ok) { return(false); } var launcher = Path.Combine(dialog.FileName, "Battle.net Launcher.exe"); if (File.Exists(launcher)) { hsLocation = launcher; return(true); } var msg = MessageBox.Show("Could not find 'Battle.net Launcher.exe'. Try again?", "Battle.net launcher not found.", MessageBoxButton.YesNo); if (msg == MessageBoxResult.No) { return(false); } }while (true); }
protected override void Invoke(object parameter) { // WPF標準のファイルダイアログにはフォルダー選択モードが無いので WindowsAPICodePackを使う var dialog = new CommonOpenFileDialog() { EnsurePathExists = true, EnsureValidNames = true, Multiselect = false, IsFolderPicker = true, //DefaultDirectory = "", Title = "保存フォルダーを選択", }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { var command = this.CompleteCommand; if (null != command && command.CanExecute(dialog.FileName)) { command.Execute(dialog.FileName); } } }
/// <summary> /// This method shows a dialog box that allows the user /// to navigate to a local repo. /// </summary> /// <returns>A repository. If failed or canceled, returns null.</returns> static public Repository ShowDialog() { CommonOpenFileDialog d = new CommonOpenFileDialog(); d.IsFolderPicker = true; CommonFileDialogResult result = d.ShowDialog(); switch (result) { case CommonFileDialogResult.Ok: return(OpenFromPath(d.FileName)); case CommonFileDialogResult.None: break; case CommonFileDialogResult.Cancel: break; } return(null); }
private void FileOpenClick(object sender, RoutedEventArgs e) { var vm = DataContext as MainVM; using (var dialog = new CommonOpenFileDialog()) { dialog.IsFolderPicker = true; dialog.AllowNonFileSystemItems = false; dialog.AddToMostRecentlyUsedList = true; try { dialog.InitialDirectory = System.IO.Path.GetDirectoryName(vm.project.path); dialog.DefaultFileName = System.IO.Path.GetFileName(vm.project.path); } catch { } if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { vm.cmdFileOpen.Execute(dialog.FileName); } } }
private void MenuItem2_Click(object sender, RoutedEventArgs e) { CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true;//设置为选择文件夹 if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { string folderPath = dialog.FileName; var t = pictureCards.Last(); pictureCards.Remove(t); //PictureCard newItem = new PictureCard() { ImgSource = folderPath, ImgWidth = 42, ImgHeigh = 42 }; PictureCard newItem = new PictureCard(new Wallpaper() { Path = folderPath, IsFloder = true }); newItem.OnBrowerClick += NewItem_OnBrowerClick; newItem.OnDelClick += NewItem_OnDelClick; newItem.OnMainButtonClick += NewItem_OnMainButtonClick; pictureCards.Add(newItem); pictureCards.Add(t); } }
private void Application_Startup(object sender, StartupEventArgs e) { var cofd = new CommonOpenFileDialog(); cofd.IsFolderPicker = true; cofd.InitialDirectory = System.IO.Path.GetFullPath(System.AppDomain.CurrentDomain.BaseDirectory); if (cofd.ShowDialog() != CommonFileDialogResult.Ok) { Shutdown(); return; } Core.PacketStructureManager.assets = new Core.AssetManager(cofd.FileName); PacketCreator.setVersion(OpCodeVersion.P2904); mWindow = new MainWindow(); MainWindow = mWindow; mWindow.Show(); mWindow.close = true; timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(500); timer.Tick += timer_Tick; timer.Start(); }
private void btnEditSyncSettings_Click(object sender, RoutedEventArgs e) { try { SyncControlGridItem dataRowView = (SyncControlGridItem)((Button)e.Source).DataContext; string id = dataRowView.Id; foreach (SyncControlGridItem item in sync_control_grid_item_set.grid_items) { if (item.Id == id) { // turn this lib into an IntranetLibrary with a new path? // // https://stackoverflow.com/questions/11624298/how-to-use-openfiledialog-to-select-a-folder/41511598#answer-41511598 using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) { dialog.InitialDirectory = item.SyncTarget; dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { try { item.SyncTarget = dialog.FileName; GridLibraryGrid.Items.Refresh(); } catch (NotImplementedException ex) { MessageBoxes.Warn(ex.Message); } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private async void ButtonSaveSelectCompositions(object sender, RoutedEventArgs e) { var selectedBuf = albumCompositions.SelectedItems; var selected = selectedBuf.Cast <AlbumResponse>().ToList(); if (selected.Count > 0) { var dialog = new CommonOpenFileDialog { IsFolderPicker = true }; var result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { var path = dialog.FileName; foreach (AlbumResponse composition in selected) { await DownloadCompositions(composition, path); } } } }
/// <summary> /// ファイルダイアログの設定を行う。 /// </summary> private void fnc_DialogSetting(CommonOpenFileDialog browser) { // ダイアログ設定:共通 fnc_DialogSetting_Common(browser); // 選択形式別設定 switch (oType) { case OpenType.FILE: // ダイアログ設定:ファイル選択 fnc_DialogSetting_File(browser); break; case OpenType.FOLDER: // ダイアログ設定:フォルダ選択 fnc_DialogSetting_Folder(browser); break; default: break; } }
private string SelectFolder(string title) { CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true, EnsurePathExists = true, EnsureValidNames = true, ShowPlacesList = true, RestoreDirectory = true, Multiselect = false, Title = title }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { return(dialog.FileName); } else { return(null); } }
private string?CommonFileDialog() { CommonOpenFileDialog dlg = new CommonOpenFileDialog { Title = "Select a project file to open...", IsFolderPicker = false, InitialDirectory = @"C:\", AddToMostRecentlyUsedList = false, AllowNonFileSystemItems = false, DefaultDirectory = @"C:\", EnsureFileExists = true, EnsurePathExists = true, EnsureReadOnly = false, EnsureValidNames = true, Multiselect = false, ShowPlacesList = true }; dlg.Filters.Add(new CommonFileDialogFilter("JSON Project Files", "*.json")); return(dlg.ShowDialog() == CommonFileDialogResult.Ok ? dlg.FileName : null); }
private void SelectButton_OnClick(object sender, RoutedEventArgs e) { var dlg = new CommonOpenFileDialog { IsFolderPicker = false, Multiselect = false, Title = @"打开", AddToMostRecentlyUsedList = false, EnsurePathExists = true, NavigateToShortcut = true, Filters = { new CommonFileDialogFilter(@"视频文件", @"*.mp4;*.flv;*.mkv"), new CommonFileDialogFilter(@"所有文件", @"*.*") } }; if (dlg.ShowDialog(this) == CommonFileDialogResult.Ok) { InputFileTextBox2.Text = dlg.FileName; } }
private void Load_Files_Folders_Click(object sender, RoutedEventArgs e) { var screen = new CommonOpenFileDialog(); screen.IsFolderPicker = true; screen.Multiselect = true; if (screen.ShowDialog() == CommonFileDialogResult.Ok) { foreach (var file in screen.FileNames) { string[] filePaths = Directory.GetFiles(file); foreach (var f in filePaths) { Files_DataGrid.Items.Add(new file() { OldName = Path.GetFileName(f), Path = Path.GetFullPath(f) }); } } } }
public void NewRecipe() { CommonOpenFileDialog dialog = new CommonOpenFileDialog { IsFolderPicker = true, }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { Recipe newRecipe = _container.Resolve <Recipe>(); newRecipe.Name = "Test"; newRecipe.Path = dialog.FileName; foreach (string name in Properties.Settings.Default.DrawingNames) { DrawingController newController = _container.Resolve <DrawingController>( name, new ResolverOverride[] { new ParameterOverride("drawing", _container.Resolve <IDrawing>(name)), }); newRecipe.DrawingControllerMap.Add(name, newController); } foreach (string name in Properties.Settings.Default.AlgorithmNames) { SpecController newController = _container.Resolve <SpecController>( new ResolverOverride[] { new ParameterOverride("spec", _container.Resolve <ISpec>(name)) }); newRecipe.SpecControllerMap.Add(name, newController); } CurrentRecipe = newRecipe; } }
/// <summary> /// Shows a dialog that lets the user select a folder /// </summary> /// <param name="description">The textual description of the operation /// to show to the user.</param> /// <param name="initialFolder">The initial folder.</param> /// <returns> /// The selected folder, or <c>null</c> if the user cancelled. /// </returns> public string SelectFolder(string description, string initialFolder) { CommonOpenFileDialog dialog = new CommonOpenFileDialog { Title = description, FoldersOnly = true, CheckFileExists = true, UsageIdentifier = new Guid("{E69E4F08-E54D-4523-891F-1B245D644DA7}") }; if (initialFolder != null && Directory.Exists(initialFolder)) { dialog.InitialDirectory = initialFolder; } CommonFileDialogResult result = dialog.ShowDialog(); if (result.Canceled) { return null; } else { return dialog.FileName; } }