private FileDialogResult ShowDialog(FileDialog dialog, FileDialogOptions options) { if (dialog == null) throw new ArgumentNullException(nameof(dialog)); if (options != null) { SetDialogProperties(dialog, options); } bool? result; //Try to get the active window var owner = WindowUtil.GetActiveWindow(); if (owner == null) { result = dialog.ShowDialog(); } else { result = dialog.ShowDialog(owner); } if (result == true) { return new FileDialogResult() { FileName = dialog.FileName, FileNames = dialog.FileNames }; } return null; }
private void SaveFile() { var options = new FileDialogOptions() { Filter = Filter }; var result = _fileDialogService.ShowSaveFileDialog(options); if (result != null) { FileName = result.FileName; } }
private void SetDialogProperties(FileDialog dialog, FileDialogOptions options) { if (dialog == null) throw new ArgumentNullException(nameof(dialog)); if (options == null) throw new ArgumentNullException(nameof(options)); dialog.AddExtension = options.AddExtension; dialog.CheckFileExists = options.CheckFileExists; dialog.CheckPathExists = options.CheckPathExists; dialog.DefaultExt = options.DefaultExt; dialog.FileName = options.FileName; dialog.FilterIndex = options.FilterIndex; dialog.InitialDirectory = options.InitialDirectory; dialog.Title = options.Title; dialog.ValidateNames = options.ValidateNames; dialog.Filter = options.Filter; }
private void SetDialogProperties(FileDialog dialog, FileDialogOptions options) { if (dialog == null) { throw new ArgumentNullException(nameof(dialog)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } dialog.AddExtension = options.AddExtension; dialog.CheckFileExists = options.CheckFileExists; dialog.CheckPathExists = options.CheckPathExists; dialog.DefaultExt = options.DefaultExt; dialog.FileName = options.FileName; dialog.FilterIndex = options.FilterIndex; dialog.InitialDirectory = options.InitialDirectory; dialog.Title = options.Title; dialog.ValidateNames = options.ValidateNames; dialog.Filter = options.Filter; }
private FileDialogResult ShowDialog(FileDialog dialog, FileDialogOptions options) { if (dialog == null) { throw new ArgumentNullException(nameof(dialog)); } if (options != null) { SetDialogProperties(dialog, options); } bool?result; //Try to get the active window var owner = WindowUtil.GetActiveWindow(); if (owner == null) { result = dialog.ShowDialog(); } else { result = dialog.ShowDialog(owner); } if (result == true) { return(new FileDialogResult() { FileName = dialog.FileName, FileNames = dialog.FileNames }); } return(null); }
/// <summary> /// Show the SafeFileDialog. /// </summary> /// <param name="options"></param> /// <returns></returns> public FileDialogResult ShowSaveFileDialog(FileDialogOptions options = null) { return ShowDialog(new SaveFileDialog(), options); }
private void Open() { if (!SaveIfDirty()) return; var options = new FileDialogOptions() { Filter = Filter }; var result = _fileDialogService.ShowOpenFileDialog(options); if (result != null) { Path = result.FileName; Text = File.ReadAllText(result.FileName); _dirtyService.MarkClean(); } }
private bool SaveAs() { var options = new FileDialogOptions() { Filter = Filter }; var result = _fileDialogService.ShowSaveFileDialog(options); if (result == null) return false; File.WriteAllText(result.FileName, Text); Path = result.FileName; _dirtyService.MarkClean(); return true; }
/// <summary> /// Show the SafeFileDialog. /// </summary> /// <param name="options"></param> /// <returns></returns> public FileDialogResult ShowSaveFileDialog(FileDialogOptions options = null) { return(ShowDialog(new SaveFileDialog(), options)); }
private void Open() { var options = new FileDialogOptions() { Filter = FileFilter }; var result = _fileDialogService.ShowOpenFileDialog(options); if (result != null) { var metadata = HostPersistor.LoadFromFile(result.FileName); Filename = result.FileName; Program = new ProgramViewModel(metadata.Functions); } }
private bool SaveAs() { var options = new FileDialogOptions() { Filter = FileFilter }; var result = _fileDialogService.ShowSaveFileDialog(options); if (result != null) { Filename = result.FileName; SaveInner(); return true; } return false; }