public static bool brak() { var form = new FormScaner(); var result = form.ShowDialog(); return(true); }
private void Reload() { #region old txtWBLogsPath.Text = PublicData.LogsWBPath; txtCheckpassLogsPath.Text = PublicData.LogsCheckPassPath; string[] ports = SerialPort.GetPortNames(); string[] baudrates = { "9600", "57600", "115200" }; comboBoxPort1.Items.Clear(); comboBoxPort1.Items.AddRange(ports); comboBoxPort2.Items.Clear(); comboBoxPort2.Items.AddRange(ports); comboBoxBaudrate1.Items.Clear(); comboBoxBaudrate1.Items.AddRange(baudrates); comboBoxBaudrate2.Items.Clear(); comboBoxBaudrate2.Items.AddRange(baudrates); comboBoxPort1.Text = PublicData.port1Name; comboBoxPort2.Text = PublicData.port2Name; comboBoxBaudrate1.Text = PublicData.port1_rate; comboBoxBaudrate2.Text = PublicData.port2_rate; textBoxFileEnd.Text = new SavingManager().Key(Setting.FileEndOptions).Value; labelAutoCustomDescrip.Text = string.Format("по {0} файлу с [auto] секцией", textBoxFileEnd.Text); //if (Data.port1_name == null) comboBox1.Text = comboBox1.Items[0].ToString(); //if (Data.port2_name == null) comboBox2.Text = comboBox2.Items[0].ToString(); portBox1.Checked = PublicData.isPort1; portBox2.Checked = PublicData.isPort2; checkBoxFixOpen.Checked = PublicData.FixOpenPort; #endregion txtRejectPath.Text = FormScaner.GetPathRejectFromFile(); txtConfigPath.Text = PublicData.ReadFromFileRootPath(); IniFile comini = new IniFile(); comini.Load("com_settings.ini"); try { IniFile.IniSection portsection = comini.GetSection("ports"); PublicData.placeNumber = portsection.GetAddKey("PlaceNumber").Value ?? PublicData.placeNumber; } catch { }; textBoxPlaceNumber.Text = PublicData.placeNumber; SetTooltips(); VisualRefresh(); var get = new SavingManager(Where.user, PublicData.UniqOperationPath); PublicData.isAutoStart = Setting.isAutoStart.Get(get).ValueBool; PublicData.isAutoFirstTest = Setting.isAutoFirstTest.Get(get).ValueBool; PublicData.timeAfterAutostart = Setting.timeAfterAutostart.Get(get).ValueInt; checkBoxAutoStart.Checked = PublicData.isAutoStart; panelAutoFirstTest.Enabled = PublicData.isAutoStart; panelAutoCustom.Enabled = PublicData.isAutoStart; numericUpDownTimeAfterAutostart.Value = PublicData.timeAfterAutostart; radioButtonAutoFirstTest.Checked = PublicData.isAutoFirstTest; radioButtonAutoCustom.Checked = !PublicData.isAutoFirstTest; checkBoxAutonomMode.Checked = Ex.isAutonomMode; checkBoxRootPath.Checked = PublicData.isUseCustomRootPath; checkBoxAutoSync.Checked = PublicData.isAutoSyncConfig; string tempDate = Setting.dateConfigUpdate.Get(new SavingManager()).Value; Ex.Try(() => { labelSyncDate.Text = (tempDate.Length == 8) ? tempDate.Insert(6, ".").Insert(4, ".") : tempDate; }); }
private void CloseAndSave() { buttonOk.Enabled = false; #region old //SetPorts(comboBox2.Text, comboBox2.Text, comboBox3.Text, comboBox4.Text); PublicData.isPort1 = portBox1.Checked; PublicData.isPort2 = portBox2.Checked; PublicData.FixOpenPort = checkBoxFixOpen.Checked; PublicData.isAutoStart = checkBoxAutoStart.Checked; PublicData.port1_rate = comboBoxBaudrate1.Text; PublicData.port2_rate = comboBoxBaudrate2.Text; PublicData.port1Name = comboBoxPort1.Text; PublicData.port2Name = comboBoxPort2.Text; PublicData.placeNumber = textBoxPlaceNumber.Text; mainForm.SetPorts(comboBoxPort1.Text, comboBoxPort2.Text, comboBoxBaudrate1.Text, comboBoxBaudrate2.Text); string on1, on2, fixon, auto, minolta; on1 = PublicData.isPort1 ? "1" : "0"; on2 = PublicData.isPort2 ? "1" : "0"; fixon = PublicData.FixOpenPort ? "1" : "0"; auto = PublicData.isAutoStart ? "1" : "0"; minolta = PublicData.isConnectedMinolta ? "1" : "0"; IniFile ini = new IniFile("com_settings.ini"); ini.SetKeyValue("ports", "port1_name", comboBoxPort1.Text); ini.SetKeyValue("ports", "port2_name", comboBoxPort2.Text); ini.SetKeyValue("ports", "port1_enable", on1); ini.SetKeyValue("ports", "port2_enable", on2); ini.SetKeyValue("ports", "port1_rate", comboBoxBaudrate1.Text); ini.SetKeyValue("ports", "port2_rate", comboBoxBaudrate2.Text); ini.SetKeyValue("ports", "FixOpenPort", fixon); ini.SetKeyValue("ports", "AutoStart", auto); ini.SetKeyValue("ports", "PlaceNumber", textBoxPlaceNumber.Text); ini.SaveShowMessage("com_settings.ini"); ini = new IniFile(PublicData.configFile); ini.ForceRenameKey("brak", FormScaner.GetPathRejectFromFile(), txtRejectPath.Text); if (txtRejectPath.Text.Length == 0) { ini.RemoveSection("brak"); } if (txtConfigPath.Text.Length == 0) { ini.RemoveSection(PublicData.configSection); PublicData.CustomRootPath = null; } string oldPath = PublicData.ReadFromFileRootPath(); if (oldPath == null) { oldPath = ""; } if (ini.ForceRenameKey(PublicData.configSection, oldPath, txtConfigPath.Text)) { PublicData.CustomRootPath = txtConfigPath.Text; } ini.SaveShowMessage(); #endregion var set = new SavingManager(); set.Key(Setting.FileEndOptions).Value = "." + textBoxFileEnd.Text.Trim(' ', '.', '"'); set.Save(); var local = new SavingManager(Where.local); PublicData.LogsCheckPassPath = txtCheckpassLogsPath.Text; PublicData.LogsWBPath = txtWBLogsPath.Text; local.Key(Setting.LogsCheckPassPath).Value = PublicData.LogsCheckPassPath; local.Key(Setting.LogsWBPath).Value = PublicData.LogsWBPath; Ex.isAutonomMode = checkBoxAutonomMode.Checked; local.Key(Setting.isAutonomMode).ValueBool = Ex.isAutonomMode; PublicData.isUseCustomRootPath = checkBoxRootPath.Checked; local.Key(Setting.isUseCustomRootPath).ValueBool = PublicData.isUseCustomRootPath; PublicData.isAutoSyncConfig = checkBoxAutoSync.Checked; local.Key(Setting.isAutoSyncConfig).ValueBool = PublicData.isAutoSyncConfig; local.Save(); var appdata = new SavingManager(Where.user, PublicData.UniqOperationPath); appdata.Key(Setting.isAutoStart).ValueBool = checkBoxAutoStart.Checked; appdata.Key(Setting.isAutoFirstTest).ValueBool = radioButtonAutoFirstTest.Checked; appdata.Key(Setting.timeAfterAutostart).Value = numericUpDownTimeAfterAutostart.Value.ToString(); appdata.Save(); Code.InitializePort1(); Code.InitializePortGenr(); PublicData.isAutoStart = appdata.Key(Setting.isAutoStart).ValueBool; PublicData.isAutoFirstTest = appdata.Key(Setting.isAutoFirstTest).ValueBool; PublicData.timeAfterAutostart = appdata.Key(Setting.timeAfterAutostart).ValueInt; if (PublicData.FixOpenPort) { Code.OpenPorts(); } else { Code.ClosePorts(); } mainForm.stats(); logger.Debug($"autostart = {PublicData.isAutoStart}"); if (PublicData.isAutoStart) { mainForm.AutoStartLauncher().RunParallel(); } this.Close(); }