private void loadPresets(string name) { var presets = PresetsList.ToObject(settings.presets); if (presets == null) { return; } if (presets.Count > 0) { Preset ps = (Preset)presets[0]; Log.Debug("Load presets: {0} > {1}\n", presets.Count, ps.Name); } }
public void Save() { PresetsList a; var s = Properties.Settings.Default.presets; if (!string.IsNullOrEmpty(s)) { a = PresetsList.ToObject(s); } else { a = new PresetsList(); } if (a.Count == 0) { a.Add(this); } else { int idx = 0; bool found = false; foreach (var item in a) { Preset ps = (Preset)item; if (ps.Name == Name) { found = true; break; } idx += 1; } if (found) { a.Insert(idx, this); } else { a.Add(this); } } Log.Debug("Save preset: {0}\n", a.ToString()); Properties.Settings.Default.presets = a.ToString(); }
public MainWindow() { InitializeComponent(); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; worker.DoWork += new DoWorkEventHandler(do_runApp); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(on_workerCompleted); previewWorker.WorkerSupportsCancellation = false; previewWorker.DoWork += new DoWorkEventHandler(do_previewTransformation); previewWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(on_previewWorkerComplete); int ww = settings.winWidth; int wh = settings.winHeight; int wx = settings.winLeft; int wy = settings.winTop; if (ww > 100) { this.Width = ww; } if (wh > 70) { this.Height = wh; } if (wx >= 0) { this.Left = wx; } if (wy >= 0) { this.Top = wy; } if (settings.winMaximzed) { this.WindowState = FormWindowState.Maximized; } var defaultPreset = new Preset { Name = "Välj...", SourceDir = settings.lastSrcDir, DestinationDir = settings.lastDestDir }; if (!string.IsNullOrEmpty(settings.presets)) { presets = PresetsList.ToObject(settings.presets); } if (presets == null) { presets = new PresetsList(); } presets.Insert(0, defaultPreset); initPresets(); updateGlobalSettings(); }