public void FormStateTest() { var settingsModel = new ApplicationSettingsModel() { ImageFormatExtension = ".jpg", FormStateModels = new Dictionary <string, FormStateModel>(), LastAppStartTime = DateTime.Now, InputDirectory = "", OutputDirectory = "" }; FormStateModel formStateModel = new FormStateModel() { FormName = "TestForm", FormPosition = new Point(32, 128), WindowState = FormState.Maximized, FormSize = new Size(247, 377) }; settingsModel.FormStateModels.Add(formStateModel.FormName, formStateModel); Assert.IsTrue(_repository.SaveSettings(settingsModel), "SaveSettings(settingsModel) failed"); var loadedSettings = _repository.LoadSettings(); FormStateModel reconstructedFormState = loadedSettings.FormStateModels.Count > 0 ? loadedSettings.FormStateModels.Values.First() : null; Assert.IsNotNull(reconstructedFormState, "reconstructedFormState != null"); // Test each property bool objectsAreEqual = reconstructedFormState.Equals(formStateModel); Assert.IsTrue(objectsAreEqual, "Reconstructed object not equal to original object."); }
private async Task OnMessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) { var awaited = await result; FormStateModel model = new FormStateModel(); model.Value = awaited.Text; var form = new FormDialog<FormStateModel >(model , BuildForm , FormOptions.PromptInStart); context.Call(form , this.AfterResume); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { FormStateModel model; if (_applicationSettingsService.Settings.FormStateModels == null) { _applicationSettingsService.Settings.FormStateModels = new ConcurrentDictionary <string, FormStateModel>(); } if (_applicationSettingsService.Settings.FormStateModels.ContainsKey(Name)) { model = _applicationSettingsService.Settings.FormStateModels[Name]; } else { model = new FormStateModel(); _applicationSettingsService.Settings.FormStateModels.Add(Name, model); } model.FormPosition = Location; model.FormSize = new Size(Width, Height); model.FormName = Name; switch (WindowState) { case FormWindowState.Normal: model.WindowState = FormState.Normal; break; case FormWindowState.Minimized: model.WindowState = FormState.Minimized; break; case FormWindowState.Maximized: model.WindowState = FormState.Maximized; model.FormSize = MinimumSize; break; default: model.WindowState = FormState.Normal; break; } if (cboxImageFormat.SelectedItem is ImageFormatModel formatModel) { _applicationSettingsService.Settings.ImageFormatExtension = formatModel.Extension; } _applicationSettingsService.Settings.OutputDirectory = lnkOutputDirectory.Text; _applicationSettingsService.SaveSettings(); e.Cancel = false; }