private void btnRestoreDefaults_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to reset all settings to their default values (this can't be undone)?", "Reset to default values", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { //for classic settings, at least до тех пор, пока полностью не перейдем на CUSTOM XML Properties.Settings.Default.Reset(); //Загрузить из файла ConfigManagement.Load(); //Перерисовать LoadDataIntoGrids("All"); } }
private void SaveXMLSettingsToConfigFile() { //1. Update ConfigXML ConfigManagement.UpdateConfigValue("Options", "lastsettemp", ObsControl.objMaxim.CameraSetPoint.ToString()); ConfigManagement.UpdateConfigValue("Devices", "FocuserDriverName", ObsControl.ASCOMFocuser.DRIVER_NAME); //focuser driver name ConfigManagement.UpdateConfigValue("Devices", "FocuserAutoConnect", ObsControl.ASCOMFocuser.Enabled.ToString()); //auto connect focuser //IQP_SaveSettingsToConfigFile(); //2. Save ConfigXML to disk ConfigManagement.Save(); //3. Load config from disk ConfigManagement.Load(); LoadOtherParamsFromXML(); //4. Side settings }
/// <summary> /// Main form load event - startup actions take place here /// </summary> private void Form1_Load(object sender, EventArgs e) { //DefBackColor DefBackColor = chkMaxim.BackColor; DefBackColorTextBoxes = txtShortAlt.BackColor; //Load config ConfigManagement.Load(); //Load parameters LoadParams(); //Update interface for current Settings values //IQP_UpdateSettingsDialogFields(); //Init programs objects using loaded settings ObsControl.InitProgramsObj(); //Load parameters after all objects was initialized LoadOtherParamsFromXML(); //Dump log, because interface may hang wating for connection Logging.DumpToFile(); //Connect Devices, which are general adapters (no need to power or control something) try { ObsControl.ASCOMSwitch.Connect = true; ObsControl.ASCOMSwitch.CheckPowerDeviceStatus_async(); } catch (Exception ex) { Logging.AddLog("Error connecting Switch on startup [" + ex.Message + "]", LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } try { ObsControl.ASCOMDome.Connect = true; } catch (Exception ex) { Logging.AddLog("Error connecting Dome on startup [" + ex.Message + "]", LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } //Update visual interface statuses UpdateStatusbarASCOMStatus(); UpdatePowerButtonsStatus(); //init graphic elements ROOF_startPos = rectRoof.Location; //Update visual Roof Status UpdateRoofStatus(); //Start tcp server SocketServer = new SocketServerClass(this); toolStripStatus_Connection.Text = "CONNECTIONS: 0"; if (true) { backgroundWorker_SocketServer.RunWorkerAsync(); toolStripStatus_Connection.ForeColor = Color.Black; } else { toolStripStatus_Connection.ForeColor = Color.Gray; } //init vars //DrawTelescopeV(panelTelescope); //Init versiondata static class //Display about information VersionData.initVersionData(); LoadAboutData(); //Init Log DropDown box foreach (LogLevel C in Enum.GetValues(typeof(LogLevel))) { toolStripDropDownLogLevel.DropDownItems.Add(Enum.GetName(typeof(LogLevel), C)); } toolStripDropDownLogLevel.Text = Enum.GetName(typeof(LogLevel), LogLevel.Activity); //Fill in Combobox Boltwood comboBoxRainFlag.DataSource = Enum.GetNames(typeof(Enum_RainFlag)); comboBoxWetFlag.DataSource = Enum.GetNames(typeof(Enum_WetFlag)); comboBoxCloudCond.DataSource = Enum.GetNames(typeof(Enum_CloudCond)); comboBoxWindCond.DataSource = Enum.GetNames(typeof(Enum_WindCond)); comboBoxRainCond.DataSource = Enum.GetNames(typeof(Enum_RainCond)); comboBoxDaylightCond.DataSource = Enum.GetNames(typeof(Enum_DayCond)); comboBoxRoofCloseFlag.DataSource = Enum.GetNames(typeof(Enum_RoofFlag)); comboBoxAlertFlag.DataSource = Enum.GetNames(typeof(Enum_AlertFlag)); //Run all timers at the end mainTimer_Short.Enabled = true; mainTimer_Long.Enabled = true; mainTimer_VeryLong.Enabled = true; logRefreshTimer.Enabled = true; weatherSmallChart.Series[0].XValueType = ChartValueType.DateTime; weatherSmallChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "HH:mm"; foreach (Series Sr in chartWT.Series) { Sr.XValueType = ChartValueType.DateTime; } foreach (ChartArea CA in chartWT.ChartAreas) { CA.AxisX.LabelStyle.Format = "HH:mm"; } //FORM APPEARENCE Form_Normal_Width = this.Width; borderWidth = (this.Width - this.ClientSize.Width) / 2; titleBarHeight = this.Height - this.ClientSize.Height - 2 * borderWidth; statusBarHeight = statusBar.Height; prevX = this.Location.X; prevY = this.Location.Y; Form_SwitchTo_Maximum_Mode(); // TEST COMMAND LINE PARAMETERS bool autostart = false; string comport_over = string.Empty; AuxilaryProc.CheckStartParams(out autostart, out comport_over); if (autostart) { this.btnStartAll.PerformClick(); } }