private void CmdOK_Click(object sender, EventArgs e) // OK button event handler { // Place any validation constraint checks here // Update the state variables with results from the dialogue //Telescope.comPort = (string)comboBoxComPort.SelectedItem; var currentConnectionString = iOptronZEQ25.Properties.Settings.Default.ConnectionString; var newCOMPort = (string)comboBoxComPort.SelectedItem; var newConnectionString = $"{newCOMPort}:9600"; iOptronZEQ25.Properties.Settings.Default.COMPort = newCOMPort; iOptronZEQ25.Properties.Settings.Default.ConnectionString = newConnectionString; SharedResources.CommPortName = newCOMPort; SharedResources.ConnectionString = newConnectionString; // tl.Enabled = chkTrace.Checked; //Properties.Settings.Default.Trace = chkTrace.Checked; iOptronZEQ25.Properties.Settings.Default.Save(); // Properties.Settings.Default.CommPort = (string)comboBoxComPort.SelectedItem; //Log.Info($"SetupDialog successful, saving settings"); if (newConnectionString != currentConnectionString) { //Log.Warn( // $"Connection string has changed from {oldConnectionString} to {newConnectionString} - replacing the TansactionProcessorFactory"); SharedResources.UpdateTransactionProcessFactory(); } Close(); }
// // PUBLIC COM INTERFACE ITelescopeV3 IMPLEMENTATION // #region Common properties and methods. /// <summary> /// Displays the Setup Dialog form. /// If the user clicks the OK button to dismiss the form, then /// the new settings are saved, otherwise the old values are reloaded. /// THIS IS THE ONLY PLACE WHERE SHOWING USER INTERFACE IS ALLOWED! /// </summary> // public void SetupDialog() // { // // consider only showing the setup dialog if not connected // // or call a different dialog if connected // if (IsOnline) // System.Windows.Forms.MessageBox.Show("Already connected, just press OK"); // using (SetupDialogForm F = new SetupDialogForm(tl)) // { // var result = F.ShowDialog(); // if (result == System.Windows.Forms.DialogResult.OK) // { // //WriteProfile(); // Persist device configuration values to the ASCOM Profile store // //Properties.Settings.Default.Save(); // //SharedResources.UpdateTransactionProcessFactory(); // } // } // } public void SetupDialog() { SharedResources.DoSetupDialog(clientId); }