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 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 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); } }