Beispiel #1
0
        static string SoundVolumeAdjust()
        {
            string  sectionName = "Sound";
            bool    NeedToSave  = false;
            var     fileOptions = PublicData.FindFileInTreeBySection(sectionName);
            IniFile ini         = new IniFile();

            ini.Load(fileOptions);
            IniFile.IniSection sectionVolume = ini.GetSection(sectionName);
            var vol_key = sectionVolume.GetAddKey("volume");

            if (vol_key == null)
            {
                vol_key = sectionVolume.AddKey("volume"); NeedToSave = true;
            }
            int dec_volume = 20;

            try
            {
                dec_volume = int.Parse(vol_key.Value);
            }
            catch (Exception)
            {
                dec_volume = 20;
                NeedToSave = true;
            }
            if (dec_volume > 100)
            {
                dec_volume = 20; NeedToSave = true;
            }
            vol_key.SetValue(dec_volume.ToString());
            if (NeedToSave)
            {
                ini.SaveShowMessage(fileOptions);
            }
            return(dec_volume.ToString("X2"));
        }
Beispiel #2
0
        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;
            });
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            MoveFiles();
            labelDefectRed.Visible = false;
            YesBox2.Visible        = false;
            NoBox2.Visible         = false;

            labelSNRed.Visible = false;
            YesBox1.Visible    = false;
            NoBox1.Visible     = false;

            if (textBoxSN.Text.Length < 5)
            {
                textBoxSN.Focus();
                labelSNRed.Visible     = true;
                labelDefectRed.Visible = false;
                NoBox1.Visible         = true;
                YesBox1.Visible        = false;
                textBoxSN.SelectAll();
                return;
            }
            YesBox1.Visible = true;
            if (textBoxDefect.Text.Length != 3)
            {
                textBoxDefect.Focus();
                labelDefectRed.Visible = true;
                NoBox2.Visible         = true;
                YesBox2.Visible        = false;
                textBoxDefect.SelectAll();
                return;
            }
            labelDefectRed.Visible = false;
            YesBox2.Visible        = true;
            NoBox2.Visible         = false;


            string        pathReject = GetPathRejectFromFile();
            DirectoryInfo dir        = new DirectoryInfo(pathReject);
            var           filename   = "#" + textBoxSN.Text + " " + System.DateTime.Now.ToString() + ".txt";

            filename = filename.Replace(':', '-');
            filename = filename.Replace('/', '.');
            var          fullway = dir.FullName + "\\" + filename;
            StreamWriter file;

            try
            {
                file = File.CreateText(fullway);
            }
            catch (DirectoryNotFoundException ex2)
            {
                PublicData.write_info(ex2.Message);
                try
                {
                    dir.Create();
                    file = System.IO.File.CreateText(fullway);
                }
                catch
                {
                    try
                    {
                        dir = new DirectoryInfo(OfflinePath);
                        dir.Create();
                        fullway = dir.FullName + "\\" + filename;
                        file    = System.IO.File.CreateText(fullway);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("НЕ СОХРАНИЛОСЬ !\n" + ex.Message,
                                        "Ошибка записи", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        this.Close();
                        return;
                    }
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                PublicData.write_info(ex.Message);
                try
                {
                    dir     = new DirectoryInfo(OfflinePath);
                    fullway = dir.FullName + "\\" + filename;
                    file    = System.IO.File.CreateText(fullway);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("НЕ СОХРАНИЛОСЬ !\n" + ex2.Message,
                                    "Ошибка записи", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
            }
            catch (Exception ex)
            {
                PublicData.write_info(ex.Message);
                try
                {
                    dir     = new DirectoryInfo(OfflinePath);
                    fullway = dir.FullName + "\\" + filename;
                    file    = System.IO.File.CreateText(fullway);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("НЕ СОХРАНИЛОСЬ !\n" + ex.Message + '\n' + ex2.Message,
                                    "Ошибка записи", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    this.Close();
                    return;
                }
            }
            if (file == null)
            {
                return;
            }

            string  PlaceNumber = "999";
            IniFile comini      = new IniFile();

            comini.Load("com_settings.ini");
            try
            {
                IniFile.IniSection portsection = comini.GetSection("ports");
                PlaceNumber = portsection.GetAddKey("PlaceNumber").Value;
            }
            catch { };

            string msg = textBoxSN.Text + "\t" + textBoxDefect.Text + PlaceNumber;

            file.WriteLine(msg);
            file.Close();
            PublicData.write_info("сохранен " + filename);
            PublicData.brak_blink();
            this.Close();
        }