Beispiel #1
0
        public PathConfig(string _path = null)
        {
            DisplayPath      = "";
            DisplayPathParts = new string[0];
            SetDefaultPath();

            if (_path != null)
            {
                if (!(Directory.Exists(_path)))
                {
                    try
                    {
                        Directory.CreateDirectory(_path);
                    }
                    catch (Exception ex)
                    {
                        string msg1 = string.Format("Будет используется стандартный путь:\n\n{0}", rootPath);
                        Ex.Show(string.Format("{0}\n\n{1}", ex.Message, msg1));
                        return;
                    }
                }
                FullPathCurrent = _path;
                rootPath        = _path;
            }
        }
Beispiel #2
0
 private bool CheckInput(string input, string arg, ref string errMsg)
 {
     if (string.IsNullOrEmpty(arg))
     {
         return(true);
     }
     try
     {
         string name = funcReadBetween(arg, "[", "]");
         var    Keys = section.IniFile.GetSection(name).Keys;
         foreach (IniFileList.IniSectionList.IniKey key in Keys)
         {
             if (key.Name.ToLower() == "regex")
             {
                 var reg = new Regex(key.Value);
                 if (!reg.IsMatch(input))
                 {
                     errMsg = $"Неверный ввод: {input}\n{this.msg}";
                     return(false);
                 }
                 ;
             }
             else
             {
                 throw new ArgumentException();
             }
         }
     }
     catch
     {
         Ex.Show("Неправильно составлен тест. Неверные параметры.");
         return(false);
     }
     return(true);
 }
Beispiel #3
0
        private void buttonOpenFirstTest_Click(object sender, EventArgs e)
        {
            var test = PublicData.GetTest(0);

            if (test != null)
            {
                Process.Start((test).FilePath);
            }
            else
            {
                Ex.Show("Тест не является внешним.\n(или просто не найден)");
            }
        }
Beispiel #4
0
        private bool FailRun()
        {
            string outputMsg = $"[{display}] - Fail".prefix(failMsg);

            logger.Trace($"{nameof(isTestAutoStart)}={isTestAutoStart}");
            if (!isTestAutoStart)
            {
                PublicData.write_info(outputMsg);
                Ex.Show(outputMsg);
            }
            Thread.Sleep(200);
            return(false);
        }
Beispiel #5
0
        public static async Task UpdateFromNetToLocalConfig()
        {
            if (string.IsNullOrEmpty(PublicData.CustomRootPath))
            {
                return;
            }
            if (!Directory.Exists(PublicData.CustomRootPath))
            {
                var msg = $"Указанный путь не существует: {PublicData.CustomRootPath}";
                Ex.Show(msg);
                PublicData.write_info(msg);
                return;
            }
            PublicData.write_info($"Началась синхронизация конфигов...");
            //copy from network to local
            string localRoot = Environment.CurrentDirectory;
            var    fromCopy  = Directory.EnumerateFiles(PublicData.CustomRootPath, "*", SearchOption.AllDirectories);
            await TaskEx.Run(() => Parallel.ForEach(fromCopy, tab =>
            {
                var where = tab.Replace(PublicData.CustomRootPath, localRoot);
                var dir   = new FileInfo(where).DirectoryName;
                Ex.Try(() =>
                {
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    File.Copy(tab, where, true);
                });
            }));

            //delete local tests
            var pathLocalTests  = Path.Combine(localRoot, testsFolder);
            var pathNetTests    = Path.Combine(PublicData.CustomRootPath, testsFolder);
            var filesLocalTests = Directory.EnumerateFiles(pathLocalTests, "*", SearchOption.AllDirectories);
            var filesNetTests   = Directory.EnumerateFiles(pathNetTests, "*", SearchOption.AllDirectories);
            var whereToFind     = new List <string>(filesNetTests);
            await TaskEx.Run(() => Parallel.ForEach(filesLocalTests, localFile =>
            {
                var fileToFind = localFile.Replace(localRoot, PublicData.CustomRootPath);
                if (!whereToFind.Contains(fileToFind))
                {
                    Ex.Try(() => File.Delete(localFile));
                }
            }));

            PublicData.write_info($"Синхронизация конфигов завершена.");
        }
Beispiel #6
0
        public static bool sound(string fileName)
        {
            PlayerSound.Stop();
            string file = PublicData.FindFileInTreeByName(fileName);

            try
            {
                PlayerSound = new System.Media.SoundPlayer(file);
                PlayerSound.Play();
                return(true);
            }
            catch
            {
                Ex.Show("Не найден файл " + fileName);
                return(false);
            }
        }
Beispiel #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();
        }
Beispiel #8
0
        private void buttonOpenAutoFile_Click(object sender, EventArgs e)
        {
            var    section = PublicData.FindSectionInTreeBySection(PublicData.constAutoName);
            string file    = (section == null) ? null : section.IniFile.Path;

            if (file == null)
            {
                Ex.Show("Файл настройки автостарта не найден.\r\n"
                        + "Ищется: файл с секцией [Auto].");
                return;
            }
            try
            {
                Process.Start("notepad.exe", file);
            }
            catch (Exception ex)
            {
                PublicData.ShowMessage(ex, "Ошибка. Не удалось открывать файл.");
            }
        }
Beispiel #9
0
        private void btnOpenWBFile_Click(object sender, EventArgs e)
        {
            var section = PublicData.FindSectionInTreeBySection("WBSettings");
            var file    = (section == null) ? null : section.IniFile.Path;

            if (file == null)
            {
                Ex.Show("Файл настроек Баланса Белого не найден.\r\n"
                        + "Ищется: файл с секцией [WBSettings].");
                return;
            }
            try
            {
                Process.Start("notepad.exe", file);
            }
            catch (Exception ex)
            {
                ex.Show("Ошибка. Не удалось открывать файл.");
            }
        }
        /// <summary>
        /// Обрабатывает входной сигнал (или ошибку) из RedRat.
        /// </summary>
        public void SignalDataHandler(object sender, EventArgs e)
        {
            if (e is SignalEventArgs)
            {
                var siea = (SignalEventArgs)e;

                switch (siea.Action)
                {
                //case SignalEventAction.EXCEPTION:
                //    MessageBox.Show(siea.Exceptionex.Info());
                //    break;

                case SignalEventAction.MODULATED_SIGNAL:
                    //MessageBox.Show("Есть ИК-данные...");
                    modSignal = siea.ModulatedSignal;
                    break;

                //case SignalEventAction.IRDA_PACKET:
                //    MessageBox.Show("Have IR data IRDA_PACKET...");
                //    irPacket = siea.IrDaPacket;
                //    break;
                case SignalEventAction.INPUT_CANCELLED:
                    break;

                default:
                    logger.Trace("Сигнал не пришел");
                    //MessageBox.Show("Сигнал не пришел");
                    break;
                }

                haveSignal = true;
            }
            else
            {
                logger.Warn("Event of unknown type....");
                Ex.Show("Event of unknown type....");
            }
        }
Beispiel #11
0
        public static Byte[] GetBytesFromHexString(string _Input)
        {
            string strInput = _Input.Replace(" ", "");

            Byte[] bytArOutput = new Byte[] { };
            if (!string.IsNullOrEmpty(strInput) && strInput.Length % 2 == 0)
            {
                SoapHexBinary hexBinary = null;
                try
                {
                    hexBinary = SoapHexBinary.Parse(strInput);
                    if (hexBinary != null)
                    {
                        bytArOutput = hexBinary.Value;
                    }
                }
                catch (Exception ex)
                {
                    Ex.Show(ex.Info());
                }
            }
            return(bytArOutput);
        }
Beispiel #12
0
 private void справкаToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Ex.Show("\"Shift + Tab\" - для открытия дерева папок");
 }