public void SaveDialogModel_Fires_PropertyChange() { var vm = new SaveFileDialogViewModel(); vm.AssertThatAllProperties() .RaiseChangeNotification(); }
private void OnExportImage(Visual visual) { var dlg = new SaveFileDialogViewModel { Title = "Export Circuit", FileName = "", //Filter = "All Image Files (*.bmp;*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.tiff;*.tga)|*.bmp;*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.tiff;*.tga|BMP (*.bmp)|*.bmp|GIF (*.gif)|*.gif|JPG (*.jpg;*.jpeg;*.jpe;*.jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|PNG (*.png)|*.png|TIFF (*.tiff)|*.tiff|TGA (*.tga)|*.tga", Filter = "PNG FIle (*.png)|*.png", }; if (dlg.Show(this.Dialogs) != System.Windows.Forms.DialogResult.OK) { return; } try { using (var memstream = GenerateImage(visual)) using (FileStream fstream = File.OpenWrite(dlg.FileName)) { memstream.WriteTo(fstream); fstream.Flush(); fstream.Close(); } } catch (Exception e) { new MessageBoxViewModel("Error exporting image: " + e.Message, "Error").Show(this.Dialogs); } }
private IDisposable BindToSaveFileDialog(SaveFileDialogViewModel x) { return(x.IsOpen .Where(y => y) .Subscribe(_ => { using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = x.Filter.Value; dialog.OverwritePrompt = x.OverwritePrompt.Value; switch (dialog.ShowDialog(this)) { case DialogResult.OK: case DialogResult.Yes: x.FileName.Value = dialog.FileName; x.YesCommand.Execute(); break; case DialogResult.No: x.NoCommand.Execute(); break; case DialogResult.Cancel: x.CancelCommand.Execute(); break; } } })); }
private void StartStopCaptureCommand_Execute() { this.Capturing = !this.Capturing; if (!this.Capturing) { if (this.CaptureFrames.Count() == 0) { new MessageBoxViewModel("No frames captured, export cancelled!", "Capture Error").Show(this.Dialogs); return; } BreakAllCommand_Execute(); var dlg = new SaveFileDialogViewModel { Title = "Save Capture", Filter = "GIF files (*.gif)|*.hex|All files (*.*)|*.*", FileName = "*.gif", }; if (dlg.Show(this.Dialogs) == DialogResult.OK) { this.Exporting = true; var exportDlg = new CaptureExportViewModel(dlg.FileName, this.CaptureFrames, this.Simulation.Lcd.LcdAngle); this.Dialogs.Add(exportDlg); if (exportDlg.Success) { new MessageBoxViewModel("Export finished!").Show(this.Dialogs); } this.Exporting = false; } this.CaptureFrames.Clear(); } }
private void SaveEepromCommand_Execute() { try { var dlg = new SaveFileDialogViewModel { Title = "Save EEPROM", Filter = "EEPROM files (*.eep)|*.eep|All files (*.*)|*.*", FileName = "*.eep", }; if (dlg.Show(this.Dialogs) == DialogResult.OK) { BreakAllCommand_Execute(); var eeprom = AtmelContext.EEPROM .Select((x, i) => new { Index = i, Value = x }) .GroupBy(x => x.Index / 32) .Select(x => String.Join(" ", x.Select(v => v.Value).Select(val => String.Format("{0:X2}", val)) )) .ToList(); File.WriteAllLines(dlg.FileName, eeprom); } } catch (Exception e) { new MessageBoxViewModel("Error saving eeprom: " + e.Message, "Error").Show(this.Dialogs); } }
public void Calling_Save_For_Second_Time_Wont_Show_SaveDialog() { var dialogModel = new SaveFileDialogViewModel { Result = true, FileName = "C:\\" }; var vm = CreateViewModel(dialogModel); vm.Save(); //For the first time, opens the dialog vm.Save(); //For the second time saves on the same file _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), options => options.Repeat.Once()); }
public void Will_Not_Proceed_To_Save_When_No_File_Is_Selected() { var dialogModel = new SaveFileDialogViewModel { Result = true, FileName = null }; _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel)); var vm = CreateViewModel(dialogModel); vm.Save(); _projectService.AssertWasNotCalled(x => x.Save(Arg <Project> .Is.Anything, Arg <FileInfo> .Is.Anything)); }
public void Default_Project_Save_Dialog_Has_Correct_Filter() { var dialogViewModel = new SaveFileDialogViewModel { Result = true }; _viewModelFactory.Expect(x => x.Create <ISaveFileDialogViewModel>()).Return(dialogViewModel); var vm = CreateProjectViewModel(); vm.Save(); Assert.Equal("Rhino Project|*.rlic", dialogViewModel.Filter); }
public void Save_Action_Will_Open_SaveDialog() { var dialogModel = new SaveFileDialogViewModel { Result = true }; _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel)); var vm = CreateViewModel(dialogModel); vm.Save(); _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), x => x.Repeat.Once()); }
public void Save_Action_Will_Open_SaveDialog() { var dialogModel = new SaveFileDialogViewModel { Result = true }; _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel)); _viewModelFactory.Expect(x => x.Create <ISaveFileDialogViewModel>()).Return(dialogModel); var viewModel = CreateProjectViewModel(); viewModel.Save(); _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), x => x.Repeat.Once()); }
public void Calling_Save_For_Second_Time_Wont_Show_SaveDialog() { var dialogModel = new SaveFileDialogViewModel { Result = true, FileName = "C:\\" }; _viewModelFactory.Expect(x => x.Create <ISaveFileDialogViewModel>()).Return(dialogModel); var vm = CreateProjectViewModel(); vm.Save(); //For the first time, opens the dialog vm.Save(); //For the second time overwrites the same file _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), options => options.Repeat.Once()); }
public void Save_Action_Will_Call_ProjectService_If_Proper_Result_Is_Set() { var existingFile = Path.GetTempFileName(); var choosenFile = new FileInfo(existingFile); var model = new SaveFileDialogViewModel { Result = true, FileName = existingFile }; _dialogService.Expect(x => x.ShowSaveFileDialog(model)); var vm = CreateViewModel(model); vm.Save(); _projectService.Expect(x => x.Save(Arg <Project> .Is.Anything, Arg.Is(choosenFile))).Repeat.Once(); }
private ISaveFileDialogViewModel CreateSaveFileDialogModel() { var model = new SaveFileDialogViewModel { AddExtension = true, CheckFileExists = true, CheckPathExists = true, OverwritePrompt = true, SupportMultiDottedExtensions = true, DefaultExtension = "rlic", Filter = "Rhino License Project|*.rlic", InitialDirectory = "C:\\", Title = "Save File Dialog", }; return(model); }
public Task <SaveFileDialogResult> ShowDialogAsync() { var dialog = new SaveFileDialog() { DataTemplates = { ViewResolver.Default } }; var viewModel = new SaveFileDialogViewModel( new DialogView <SaveFileDialogResult>(dialog), ClipboardService.Instance, DefaultFileIconProvider.Instance, new MessageDialogService(dialog)); dialog.DataContext = viewModel; return(dialog.ShowDialog <SaveFileDialogResult>(_owner)); }
public void Export_Selected_License() { var licensepath = @"c:\License.xml"; var vm = CreateProjectViewModel(); var saveDialog = new SaveFileDialogViewModel { Result = true, FileName = licensepath }; vm.CurrentProject = new Project { Product = new Product() }; vm.SelectedLicense = new License { OwnerName = "John Doe", ExpirationDate = null, LicenseType = LicenseType.Trial }; _viewModelFactory.Expect(f => f.Create <ISaveFileDialogViewModel>()).Return(saveDialog); vm.ExportLicense(); _exportService.AssertWasCalled(x => x.Export(Arg.Is(vm.CurrentProject.Product), Arg.Is(vm.SelectedLicense), Arg <FileInfo> .Is.NotNull)); }
public string SaveFileDialog(string startFileName) { var saveFileDialog = new SaveFileDialogViewModel() { Title = "Сохранение файла", FileName = startFileName, Filter = "All files (*.*)|*.*", Multiselect = false }; if (saveFileDialog.Show(_dialogs)) { return(saveFileDialog.FileName); } else { return(null); } }
private void ExportImageCommand_Execute() { var dlg = new SaveFileDialogViewModel { Title = "Save Capture", Filter = "GIF files (*.gif)|*.gif|All files (*.*)|*.*", FileName = "*.gif", }; if (dlg.Show(this.Dialogs) == DialogResult.OK) { BreakAllCommand_Execute(); var frames = new List <CaptureFrame> { new CaptureFrame { Backlight = this.Simulation.Lcd.LcdCurrentBacklight, Pixels = (byte [])this.Simulation.Lcd.Pixels.Clone() } }; var exportDlg = new CaptureExportViewModel(dlg.FileName, frames, this.Simulation.Lcd.LcdAngle); this.Dialogs.Add(exportDlg); } }
private void OnSaveAs() { CancelCurrentTrace(); try { var dlg = new SaveFileDialogViewModel { Title = "Save Perfy Layout", Filter = "Perfy files (*.pfp)|*.pfp|All files (*.*)|*.*", FileName = "*.pfp" }; if (dlg.Show(this.Dialogs) == System.Windows.Forms.DialogResult.OK) { this.Caption = CaptionPrefix + " - " + Path.GetFileName(dlg.FileName); this.LastFilename = dlg.FileName; Save(dlg.FileName); } } catch (Exception e) { new MessageBoxViewModel("Error saving perfy file: " + e.Message, "Error").Show(this.Dialogs); } }
public async Task <string[]> ShowFileDialogAsync(FileDialog dialog, Window parent) { if (dialog is OpenFileDialog openFileDialog) { var view = new MovereOpenFileDialog() { DataTemplates = { ViewResolver.Default } }; var viewModel = new OpenFileDialogViewModel( new DialogView <OpenFileDialogResult>(view), ClipboardService.Instance, DefaultFileIconProvider.Instance, new MessageDialogService(view), openFileDialog.AllowMultiple, dialog.Filters.Select(ConvertFilter).ToImmutableArray()); if (!String.IsNullOrWhiteSpace(dialog.Directory)) { var directory = new DirectoryInfo(dialog.Directory); if (directory.Exists) { viewModel.FileExplorer.CurrentFolder = new Folder(directory); } } if (!(dialog.InitialFileName is null)) { viewModel.FileName = dialog.InitialFileName; } view.DataContext = viewModel; var result = await view.ShowDialog <OpenFileDialogResult>(parent); return(result == null?Array.Empty <string>() : result.SelectedPaths.ToArray()); } if (dialog is SaveFileDialog saveFileDialog) { var view = new MovereSaveFileDialog() { DataTemplates = { ViewResolver.Default } }; var viewModel = new SaveFileDialogViewModel( new DialogView <SaveFileDialogResult>(view), ClipboardService.Instance, DefaultFileIconProvider.Instance, new MessageDialogService(view)); if (!String.IsNullOrWhiteSpace(dialog.Directory)) { var directory = new DirectoryInfo(dialog.Directory); if (directory.Exists) { viewModel.FileExplorer.CurrentFolder = new Folder(directory); } } if (!(dialog.InitialFileName is null)) { viewModel.FileName = dialog.InitialFileName; } view.DataContext = viewModel; var result = await view.ShowDialog <SaveFileDialogResult>(parent); return((result == null || result.SelectedPath == null) ? Array.Empty <string>() : new string[] { result.SelectedPath }); } throw new NotImplementedException(); }