예제 #1
0
        private void Save()
        {
            if (numericUpDown1.Text != "")
            {
                int size = Convert.ToInt32(numericUpDown1.Text);
                mainForm.changeFontListView(size);

                var set = new SavingManager();
                set.Key(Setting.FontListView).ValueInt = size;
                set.Key(Setting.FileEndProg).Value     = "." + textBoxFileEnd.Text.Trim(' ', '.', '"');
                set.Save();
            }

            IniFile ini = new IniFile(PublicData.configFile);

            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();
        }
예제 #2
0
        private void btnCreateWBFile_Click(object sender, EventArgs e)
        {
            string fileEnd  = new SavingManager().Key(Setting.FileEndOptions).Value;
            string fileName = "WBSettings" + fileEnd;
            string fullPath = Path.Combine(PublicData.FolderConfigPath, fileName);

            try
            {
                File.CreateText(fullPath).Close();
            }
            catch (Exception ex)
            {
                PublicData.ShowMessage(ex, "Ошибка. Не удалось создать файл.");
                return;
            }
            try
            {
                var set = new SavingManager(Where.custom, fullPath, "WBSettings");
                set.Key(Setting.CoolX);
                set.Key(Setting.CoolY);
                set.Key(Setting.StandartX);
                set.Key(Setting.StandartY);
                set.Key(Setting.WarmX);
                set.Key(Setting.WarmY);
                set.Key(Setting.ToleranceXY);
                set.Key(Setting.Average);
                set.Key(Setting.Green128Below);
                set.Save();
                Process.Start(fullPath);
            }
            catch (Exception ex)
            {
                PublicData.ShowMessage(ex, "Ошибка. Не удалось открыть файл.");
            }
        }
예제 #3
0
        public static async Task AutoUpdateFromNetToLocalConfig()
        {
            if (!PublicData.isAutoSyncConfig)
            {
                return;
            }
            var    today          = DateTime.Today;
            string month          = today.Month < 10 ? $"0{today.Month}" : $"{today.Month}";
            string day            = today.Day < 10 ? $"0{today.Day}" : $"{today.Day}";
            string datestring     = $"{today.Year}{month}{day}";
            int    todayDateValue = 0;

            try
            {
                todayDateValue = int.Parse(datestring);
            }
            catch { return; }
            var sets      = new SavingManager();
            int dateSaved = Setting.dateConfigUpdate.Get(sets).ValueInt;

            if (isUseCustomRootPath)
            {
                if (todayDateValue > dateSaved)
                {
                    if (Form1.CountSuccess > 9)
                    {
                        await UpdateFromNetToLocalConfig();

                        sets.Key(Setting.dateConfigUpdate).ValueInt = todayDateValue;
                        sets.Save();
                    }
                }
            }
        }
예제 #4
0
        void LoadSettings()
        {
            var setting = new SavingManager();

            if (!(setting.Key(Setting.LastTVSelection).Value == ""))
            {
                LastSelect = setting.Key(Setting.LastTVSelection).Value.Split(new char[] { '©' }, StringSplitOptions.RemoveEmptyEntries);
            }

            this.Location = new Point(setting.Key(Setting.FormLocationX).ValueInt, setting.Key(Setting.FormLocationY).ValueInt);
            this.Size     = new Size(setting.Key(Setting.FormSizeX).ValueInt, setting.Key(Setting.FormSizeY).ValueInt);

            splitContainer1.Panel2Collapsed = true;
            try
            {
                splitContainer1.SplitterDistance = setting.Key(Setting.Split1).ValueInt;
                splitContainer3.SplitterDistance = setting.Key(Setting.Split3).ValueInt;
                splitContainer4.SplitterDistance = setting.Key(Setting.Split4).ValueInt;
            } catch { }

            listView1.Font = new Font("Arial", setting.Key(Setting.FontListView).ValueInt);
        }
 private void SetHeadline()
 {
     Ex.Log("MainWindow.SetHeadline()");
     try
     {
         var local = new SavingManager(Where.local);
         label1.Content = local.Key(Setting.HeadlineLauncherText).Value;
         local.Save();
     }
     catch (Exception ex)
     {
         ex.Log("Error at SetHeadline()");
     }
 }
예제 #6
0
        void SaveSettings()
        {
            var setting = new SavingManager();

            setting.Key(Setting.Split1).ValueInt = splitContainer1.SplitterDistance;
            setting.Key(Setting.Split3).ValueInt = splitContainer3.SplitterDistance;
            setting.Key(Setting.Split4).ValueInt = splitContainer4.SplitterDistance;

            setting.Key(Setting.FormSizeX).ValueInt     = this.Size.Width;
            setting.Key(Setting.FormSizeY).ValueInt     = this.Size.Height;
            setting.Key(Setting.FormLocationX).ValueInt = this.Location.X;
            setting.Key(Setting.FormLocationY).ValueInt = this.Location.Y;

            setting.Save();
        }
예제 #7
0
        private void LaunchPorgram()
        {
            IniFile ini     = new IniFile(pathconfig.GetFilePath(listView1.FocusedItem.Text));
            var     section = ini.GetSection("exe");

            if (section != null)
            {
                foreach (IniFile.IniSection.IniKey fileName in section.Keys)
                {
                    try
                    {
                        System.Diagnostics.Process.Start(fileName.Name);
                    }
                    catch (Exception ex1)
                    {
                        var local = Path.Combine(Environment.CurrentDirectory, fileName.Name);
                        try
                        {
                            System.Diagnostics.Process.Start(local);
                        }
                        catch (Exception ex2)
                        {
                            Ex.Show($"{ex1.Message}:\n{fileName.Name}\n\n{ex2.Message}:\n{local}");
                        }
                    }
                    break;
                }
                this.Close();
                return;
            }

            PublicData.operation        = listView1.FocusedItem.Text;
            PublicData.fileOperation    = pathconfig.GetFilePath(listView1.FocusedItem.Text);
            PublicData.cancelLaunch     = false;
            PublicData.DisplayModel     = pathconfig.displayPathParts;
            PublicData.model            = (PublicData.DisplayModel.Length > 0) ? PublicData.DisplayModel[0] : PublicData.operation;
            PublicData.FolderConfigPath = pathconfig.FullPath;

            var set = new SavingManager();

            set.Key(Setting.LastTVSelection).Value = String.Join("©", pathconfig.displayPathParts) + "©" + PublicData.operation;
            set.Save();

            this.Close();
        }
예제 #8
0
        private static void WarningSwipe()
        {
            Ex.Log("SystemManager.WarningSwipe()");
            StringBuilder msg = new StringBuilder("ВНИМАНИЕ! Не отключены свайпы границ экрана в Windows, что нарушает безопасность.\n\n");

            msg.AppendLine("Воспользуйтесь TuningGameStand.exe от имени администратора для отключения свайпов.\n");
            msg.AppendLine("Для отключения этого сообщения (не рекомендуется) в файле settings.ini выставьте параметр DisableSwipeWarning=1.\n");
            OnSwipesEnabledWarning += () => Ex.Show(msg.ToString());

            RegPath.ReadSwipeEdgeMachine();
            var  set            = new SavingManager(Where.local);
            bool isForceDisable = set.Key(Setting.DisableSwipeWarning).ValueBool;

            set.Save();
            if (RegPath.isDisabledSwipes == false && isForceDisable == false)
            {
                Ex.Log("SystemManager.OnSwipesEnabledWarning()");
                OnSwipesEnabledWarning();
            }
        }
예제 #9
0
 public static SavingManager.sKey Get(this Setting set, SavingManager obj)
 {
     return(obj.Key(set));
 }
예제 #10
0
        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();
        }