internal void updateFromForm(FormSettings formSettings) { serialDeviceId = formSettings.serialDeviceId; for (int co = 0; co < TransceiverController.PIN_FUNCTIONS.Count; co++) { pinout[co] = SerialDevice.SerialDevice.PINS.IndexOf(formSettings.transceiverPinSettings[co].pin); invertPins[co] = formSettings.transceiverPinSettings[co].invert; } }
private void updateTransceiverControllerConfig(TransceiverControllerConfig tcConfig, FormSettings formSettings) { tcConfig.transceiverType = formSettings.cwTransceiverType; tcConfig.serialDeviceId = formSettings.serialDeviceId; for (int co = 0; co < TransceiverController.PIN_FUNCTIONS.Count; co++) { tcConfig.pinout[co] = SerialDevice.SerialDevice.PINS.IndexOf(formSettings.transceiverPinSettings[co].pin); tcConfig.invertPins[co] = formSettings.transceiverPinSettings[co].invert; } tcConfig.tciHost = formSettings.tciHost; tcConfig.tciPort = formSettings.tciPort; tcConfig.tciTrnsNo = formSettings.tciTrnsNo; }
public void showSettings() { transceiverController.disconnect(); FormSettings formSettings = new FormSettings(dataPath); formSettings.textBoxLogin.Text = config.httpService.callsign; formSettings.textBoxPassword.Text = config.httpService.password; if (config.httpService.updateIterval != 0) { formSettings.updateIntervalRadioButtons[config.httpService.updateIterval].Checked = true; } formSettings.buttonLogin.Click += async delegate(object sender, EventArgs e) { config.httpService.callsign = formSettings.textBoxLogin.Text; config.httpService.password = formSettings.textBoxPassword.Text; System.Net.HttpStatusCode?loginStatusCode = await httpService.login(); if (loginStatusCode == System.Net.HttpStatusCode.OK) { MessageBox.Show("Logged in successfully.", Assembly.GetExecutingAssembly().GetName().Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } }; formSettings.checkBoxAutoLogin.Checked = config.autoLogin; foreach (KeyValuePair <string, CheckBox> item in formSettings.mainFormPanelCheckboxes) { item.Value.Checked = config.getMainFormPanelVisible(item.Key); } formSettings.cwTransceiverType = config.transceiverController.transceiverType; formSettings.serialDeviceId = config.transceiverController.serialDeviceId; for (int co = 0; co < TransceiverController.PIN_FUNCTIONS.Count; co++) { formSettings.transceiverPinSettings[co].pin = config.transceiverController.pinout[co] == -1 ? "" : SerialDevice.SerialDevice.PINS[config.transceiverController.pinout[co]]; formSettings.transceiverPinSettings[co].invert = config.transceiverController.invertPins[co]; } formSettings.tciHost = config.transceiverController.tciHost; formSettings.tciPort = config.transceiverController.tciPort; formSettings.tciTrnsNo = config.transceiverController.tciTrnsNo; formSettings.autoCqRxPause = config.autoCqRxPause; formSettings.esmMacro = config.esmMacro; for (int co = 0; co < formSettings.CwMacros.Count; co++) { formSettings.CwMacros[co].Item1.Text = config.cwMacros[co][0]; formSettings.CwMacros[co].Item2.Text = config.cwMacros[co][1]; } formSettings.watchAdifLog = config.watchAdifLog; formSettings.watchAdifLogPath = config.watchAdifLogPath; for (int field = 0; field < TnxlogConfig.QthFieldCount; field++) { formSettings.setQthFieldAdifLabel(field, config.qthFieldTitles[field]); formSettings.setQthFieldAdif(field, config.qthAdifFields[field]); } formSettings.setCommentFieldAdif(config.commentAdifField); if (formSettings.ShowDialog(this.formMain) == System.Windows.Forms.DialogResult.OK) { config.httpService.callsign = formSettings.textBoxLogin.Text; config.httpService.password = formSettings.textBoxPassword.Text; config.httpService.updateIterval = formSettings.updateIntervalRadioButtons.Where(x => x.Value.Checked).FirstOrDefault().Key; config.autoLogin = formSettings.checkBoxAutoLogin.Checked; if (config.autoLogin && !httpService.connected) { Task.Run(async() => await httpService.login(true)); } foreach (KeyValuePair <string, CheckBox> item in formSettings.mainFormPanelCheckboxes) { config.setMainFormPanelVisible(item.Key, item.Value.Checked); } updateTransceiverControllerConfig(config.transceiverController, formSettings); config.autoCqRxPause = formSettings.autoCqRxPause; config.esmMacro = formSettings.esmMacro; for (int co = 0; co < formSettings.CwMacros.Count; co++) { config.cwMacros[co][0] = formSettings.CwMacros[co].Item1.Text.ToUpper(); config.cwMacros[co][1] = formSettings.CwMacros[co].Item2.Text.ToUpper(); } config.watchAdifLog = formSettings.watchAdifLog; config.watchAdifLogPath = formSettings.watchAdifLogPath; for (int field = 0; field < TnxlogConfig.QthFieldCount; field++) { config.qthAdifFields[field] = formSettings.getQthFieldAdif(field).Trim().ToUpper(); } config.commentAdifField = formSettings.getCommentFieldAdif().Trim().ToUpper(); formMain.adifQthMenu(); config.write(); } formSettings.Dispose(); initServices(); formMain.updateCwMacrosTitles(); }