public OptionsDialog(Scan scan) { if (scan == null) { throw new ScanException("Invalid constructor parameter."); } this.scan = scan; InitializeComponent(); foreach (OutputFormat f in Enum.GetValues(typeof(OutputFormat))) { cmbOutputFormat.Items.Add(f); } foreach (TiffCompression f in Enum.GetValues(typeof(TiffCompression))) { cmbTiffCompression.Items.Add(f); } tbDevice.Text = scan.DefaultDevice; tbOutputFolder.Text = scan.OutputFolder; tbNamingTemplate.Text = scan.FileNamingTemplate; cmbOutputFormat.SelectedItem = scan.OutputFormat; nudJpegQuality.Value = (decimal) scan.JpegQuality; cmbTiffCompression.SelectedItem = scan.TiffCompression; lblExample.Text = "Example: " + String.Format(scan.FileNamingTemplate, 1) /*+ ", " + String.Format(scan.FileNamingTemplate, 2)*/; }
///<summary> /// Opens Options dialog. ///</summary> ///<param name="scanInstance">Scan object to show options for.</param> ///<exception cref="ScanException"></exception> public static void ShowOptionsDialog(Scan scanInstance) { if (scanInstance == null) { throw new ScanException("Invalid constructor parameter."); } using (OptionsDialog dlg = new OptionsDialog(scanInstance)) { if (dlg.ShowDialog() == DialogResult.OK) { scanInstance.SaveOptions(); } } }