Ejemplo n.º 1
0
        private void FrmSelectLanguage_Load(object sender, EventArgs e)
        {
            //this.DialogResult = DialogResult.Cancel;

            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            for (int i = 0; i < InputLanguage.InstalledInputLanguages.Count; i++)
            {
                InputLanguage il = InputLanguage.InstalledInputLanguages[i];
                cboLanguage.Items.Add(il.LayoutName);
            }


            string customInputLanguage = ApiFunction.GetIniString("INPUTLANGUAGE", "N" + TrasenFrame.Forms.FrmMdiMain.CurrentUser.LoginCode, Constant.ApplicationDirectory + "//CustomInputLanguage.ini");

            if (customInputLanguage == "" || customInputLanguage == null)
            {
                lblNote.Text = "提示:您(" + TrasenFrame.Forms.FrmMdiMain.CurrentUser.Name + ")在本机还未设置个人中文输入法";
            }
            for (int i = 0; i < cboLanguage.Items.Count; i++)
            {
                if (cboLanguage.Items[i].ToString() == customInputLanguage)
                {
                    cboLanguage.SelectedIndex = i;
                    lblNote.Text = "您(" + TrasenFrame.Forms.FrmMdiMain.CurrentUser.Name + ")已经在本机设置了中文输入法";
                    return;
                }
            }
        }
        private async Task LoadSupportedLanguagesAsync()
        {
            try
            {
                SupportedLanguages supportedLanguages = await this.translatorTextService.GetSupportedLanguagesAsync();

                this.alternativeTranslationDict = supportedLanguages.Dictionary.ToDictionary(l => l.Key, l => l.Value.Translations);
                List <Language> translationLanguageList = supportedLanguages.Translation
                                                          .Select(v =>
                {
                    Language translationLang = v.Value;
                    translationLang.Code     = v.Key;
                    return(translationLang);
                })
                                                          .OrderBy(v => v.Name).ToList();

                InputLanguageCollection.AddRange(translationLanguageList);
                OutputLanguageCollection.AddRange(translationLanguageList);
                OutputLanguage = OutputLanguageCollection.FirstOrDefault(l => l.Code.Equals(DefaultLanguage.Code, StringComparison.OrdinalIgnoreCase));
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure loading languages.");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置输入法状态
        /// </summary>
        /// <param name="userCode">用户代码</param>
        /// <param name="OnOff">true打开中文输入法,false关闭中文输入法</param>
        public static void SetILStatus(string userCode, bool OnOff)
        {
            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            string cnIL      = ApiFunction.GetIniString("INPUTLANGUAGE_CN", "N" + userCode, Constant.ApplicationDirectory + "//UserCustomSetting.ini");
            string enIL      = ApiFunction.GetIniString("INPUTLANGUAGE_EN", "N" + userCode, Constant.ApplicationDirectory + "//UserCustomSetting.ini");
            string needSetIL = "";

            if (OnOff == true)
            {
                needSetIL = cnIL;
            }
            else
            {
                needSetIL = enIL;
            }

            for (int i = 0; i < InputLanguage.InstalledInputLanguages.Count; i++)
            {
                InputLanguage il = InputLanguage.InstalledInputLanguages[i];
                if (il.LayoutName == needSetIL)
                {
                    InputLanguage.CurrentInputLanguage = il;
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        public override KeyboardLayoutContent Process(KeyboardLayoutSource input, ContentProcessorContext context)
        {
            // Load keyboard layout
            IntPtr hkl = NativeMethods.User32.LoadKeyboardLayout(input.LayoutId, NativeMethods.User32.KLF_NOTELLSHELL);

            if (hkl == IntPtr.Zero)
            {
                throw new InvalidContentException(String.Format("Keyboard layout {0} not found", input.LayoutId));
            }

            //
            KeyboardLayoutContent kbl = new KeyboardLayoutContent(input.LayoutId);

            InitializeScanCodes(hkl, kbl.Keys);
            FindSpecialShiftState(hkl, kbl);
            ProcessKeys(hkl, kbl);

            // Check, if the keyboard layout can be unloaded
            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage il in ilc)
            {
                if (hkl == il.Handle)
                {
                    hkl = IntPtr.Zero;
                    break;
                }
            }
            if (hkl != IntPtr.Zero)
            {
                NativeMethods.User32.UnloadKeyboardLayout(hkl);
            }

            return(kbl);
        }
Ejemplo n.º 5
0
        private async Task LoadSupportedLanguagesAsync()
        {
            try
            {
                SupportedLanguages supportedLanguages = await this.translatorTextService?.GetSupportedLanguagesAsync();

                if (supportedLanguages != null)
                {
                    List <LanguageDictionary> languageDictionaryList = supportedLanguages.Dictionary
                                                                       .Select(v =>
                    {
                        LanguageDictionary languageDict = v.Value;
                        languageDict.Code = v.Key;
                        return(languageDict);
                    })
                                                                       .OrderBy(v => v.Name)
                                                                       .ToList();
                    InputLanguageCollection.Clear();
                    InputLanguageCollection.AddRange(languageDictionaryList);
                }
            }
            catch (Exception ex)
            {
                await Util.GenericApiCallExceptionHandler(ex, "Failure loading languages.");
            }
        }
Ejemplo n.º 6
0
        public void InputLanguage_InstalledInputLanguages_Get_ReturnsExpected()
        {
            InputLanguageCollection collection = InputLanguage.InstalledInputLanguages;

            Assert.NotSame(collection, InputLanguage.InstalledInputLanguages);
            Assert.NotEmpty(collection);
            Assert.All(collection.Cast <InputLanguage>(), VerifyInputLanguage);
        }
Ejemplo n.º 7
0
        private void Landing_Load(object sender, EventArgs e)
        {
            IPAddress[] ips     = Dns.GetHostAddresses(Dns.GetHostName());
            IPAddress   localIp = ips[ips.Length - 1];

            this.ip     = localIp.ToString();
            label5.Text = localIp.ToString();

            //获取所在网段
            string[] strs = this.ip.Split('.');
            //根据ip地址选择默认的频段
            int temp = int.Parse(strs[strs.Length - 1]);

            if (temp >= 0 && temp <= 50)
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (temp > 50 && temp <= 100)
            {
                comboBox1.SelectedIndex = 1;
            }
            else if (temp > 100 && temp <= 155)
            {
                comboBox1.SelectedIndex = 2;
            }
            else if (temp > 155 && temp <= 200)
            {
                comboBox1.SelectedIndex = 3;
            }
            else
            {
                comboBox1.SelectedIndex = 4;
            }
            this.channel  = comboBox1.SelectedIndex + 1;//绑定频道
            this.BoxIndex = comboBox1.SelectedIndex;

            Model.UserData data = new Model.UserData(localIp.ToString(), "", "im1", this.channel);
            KeyData.StaticInfo.MyUser = data;

            //将输入法设置为搜狗输入法
            InputLanguageCollection langs = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage lang in langs)
            {
                if (lang.LayoutName.Contains("搜狗拼音"))
                {
                    InputLanguage.CurrentInputLanguage = lang;
                }
            }

            this.pictureBox1.BackgroundImage = HeadImages.im1;
            this.RandName();
            Animation.窗体动画.Enter_Animate(this.Handle, Animation.Enter_Animations.自下向上滑动, 600);
            KeyData.receiver.StartRead();
            Transmitters.Sender.SendAllTestInfo();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 加载本机安装的输入法
        /// </summary>
        private void LoadInstalledLanguage()
        {
            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            for (int i = 0; i < InputLanguage.InstalledInputLanguages.Count; i++)
            {
                InputLanguage il = InputLanguage.InstalledInputLanguages[i];
                cboChineseIL.Items.Add(il.LayoutName);
                cboEnglishIL.Items.Add(il.LayoutName);
            }
        }
        private void OnSwapLanguageButtonClicked(object sender, RoutedEventArgs e)
        {
            if (InputLanguage != null && OutputLanguage != null)
            {
                this.inputText.Text         = this.outputText.Text;
                this.previousTranslatedText = this.inputText.Text;
                this.outputText.Text        = string.Empty;

                customOutputLanguage = InputLanguage;
                InputLanguage        = InputLanguageCollection.FirstOrDefault(l => l.Code.Equals(OutputLanguage.Code, StringComparison.OrdinalIgnoreCase));
            }
        }
Ejemplo n.º 10
0
        public static InputLanguage GetDesiredInputLanguage(string layoutName)
        {
            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage il in ilc)
            {
                if (il.LayoutName.IndexOf(layoutName) != -1)
                {
                    return(il);
                }
            }
            return(null);
        }
Ejemplo n.º 11
0
        public void ShowInputLan()
        {
            InputLanguageCollection iLc = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage iL in iLc)
            {
                this.comboBox1.Items.Add(iL.LayoutName);
            }
            int InputCount = this.comboBox1.SelectedIndex;

            if (InputCount != 0)
            {
                this.comboBox1.SelectedIndex = 0;
            }
        }
        private void InputLanguageChanged()
        {
            if (InputLanguage != null)
            {
                // update output language combobox
                string outputLangCode = customOutputLanguage?.Code ?? OutputLanguage?.Code;
                OutputLanguageCollection.Clear();
                OutputLanguageCollection.AddRange(InputLanguageCollection.Where(x => x.Code != InputLanguage.Code));

                OutputLanguage       = OutputLanguageCollection.FirstOrDefault(l => l.Code.Equals(outputLangCode ?? DefaultLanguage.Code, StringComparison.OrdinalIgnoreCase)) ?? OutputLanguageCollection.FirstOrDefault();
                customOutputLanguage = null;

                // Pivot Image
                this.detectedLanguageTextBox.Text = $"Detected Language: {InputLanguage.Name}";
            }
        }
Ejemplo n.º 13
0
        public static bool SetEnglishLanguage()
        {
            bool bolResultLoc = false;

            InputLanguageCollection ilcLanguages = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage ilLanguage in ilcLanguages)
            {
                if (ilLanguage.Culture.Name == "en-US")
                {
                    InputLanguage.CurrentInputLanguage = ilLanguage;
                    bolResultLoc = true;
                }
            }

            return(bolResultLoc);
        }
        public IndividualSetExten_KeyboardInputIndex()
        {
            InitializeComponent();

            Text = "中文输入法";

            InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage il in ilc)
            {
                comboBox1.Items.Add(il.LayoutName);
            }

            AppSet appSet = AppSet.Load();

            this.comboBox1.SelectedIndex = appSet.KeyboardInputIndex;
        }
Ejemplo n.º 15
0
        public Main()
        {
            InitializeComponent();
            inputBox.ReadOnly = true;
            this.WindowState  = FormWindowState.Maximized;
            initChart();
            loadConfig();
            InputLanguageCollection langs = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage lang in langs)
            {
                if (lang.LayoutName == "中文(简体,中国)微软拼音")
                {
                    InputLanguage.CurrentInputLanguage = lang;
                }
            }
        }
Ejemplo n.º 16
0
        public static void DumpScanCodesVirtualKeys(String kid)
        {
            IntPtr hkl = NativeMethods.User32.LoadKeyboardLayout(kid, NativeMethods.User32.KLF_NOTELLSHELL);

            if (hkl == IntPtr.Zero)
            {
                Console.WriteLine("Sorry, that keyboard does not seem to be valid.");
            }
            else
            {
                int         nLCID = int.Parse(kid, NumberStyles.HexNumber);
                CultureInfo ci    = new System.Globalization.CultureInfo(nLCID & 0xFFFF);
                Console.WriteLine("{0}, {1}, {2}\n", ci.Name, ci.DisplayName, ci.EnglishName);

                Console.WriteLine("VK\tSC");
                Console.WriteLine("------------");
                for (KeysEx vk = KeysEx.None; vk <= KeysEx.Last; vk++)
                {
                    uint sc = NativeMethods.User32.MapVirtualKeyEx((uint)vk, 0, hkl);
                    Console.WriteLine("{0}\t{1}", vk, sc);
                }

                Console.WriteLine("\nSC\tVK");
                Console.WriteLine("------------");
                for (KeysEx vk = KeysEx.None; vk <= KeysEx.Last; vk++)
                {
                    uint sc = NativeMethods.User32.MapVirtualKeyEx((uint)vk, 0, hkl);
                    Console.WriteLine("{1}\t{0}", vk, sc);
                }

                InputLanguageCollection ilc = InputLanguage.InstalledInputLanguages;
                foreach (InputLanguage il in ilc)
                {
                    if (hkl == il.Handle)
                    {
                        hkl = IntPtr.Zero;
                        break;
                    }
                }
                if (hkl != IntPtr.Zero)
                {
                    NativeMethods.User32.UnloadKeyboardLayout(hkl);
                }
            }
        }
        private async Task DetectedLanguageAsync(string text)
        {
            try
            {
                if (!string.IsNullOrEmpty(text))
                {
                    DetectedLanguageResult detectedLanguageResult = await this.translatorTextService.DetectLanguageAsync(text);

                    if (detectedLanguageResult != null)
                    {
                        InputLanguage = InputLanguageCollection.FirstOrDefault(l => l.Code.Equals(detectedLanguageResult.Language, StringComparison.OrdinalIgnoreCase));
                    }
                }
            }
            catch
            {
                // just ignore the exception here and let user select the language
            }
        }
Ejemplo n.º 18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //获取系统中已经安装的文字输入法
            InputLanguageCollection mInputs = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage mInput in mInputs)
            {
                this.comboBox1.Items.Add(mInput.LayoutName);
            }
            //获取当前输入法信息
            InputLanguage CurrentInput = InputLanguage.CurrentInputLanguage;

            this.textBox1.Text = CurrentInput.LayoutName;
            //获取输入法的语言区域
            this.textBox3.Text = CurrentInput.Culture.DisplayName;
            //获取默认的输入法信息
            InputLanguage dInput = InputLanguage.DefaultInputLanguage;

            this.textBox2.Text = dInput.LayoutName;
        }
Ejemplo n.º 19
0
        // ————————
        // Получение раскладки клавиатуры активного окна
        private static string GetKeyboardLayoutId()
        {
            _InstalledInputLanguages = InputLanguage.InstalledInputLanguages;

            // Получаем хендл активного окна
            IntPtr hWnd = GetForegroundWindow();
            // Получаем номер потока активного окна
            int WinThreadProcId = GetWindowThreadProcessId(hWnd, out _ProcessId);
            // Получаем раскладку
            IntPtr KeybLayout = GetKeyboardLayout(WinThreadProcId);

            // Циклом перебираем все установленные языки для проверки идентификатора
            for (int i = 0; i < _InstalledInputLanguages.Count; i++)
            {
                if (KeybLayout == _InstalledInputLanguages[i].Handle)
                {
                    _CurrentInputLanguage = _InstalledInputLanguages[i].Culture.ThreeLetterWindowsLanguageName.ToString();
                }
            }
            return(_CurrentInputLanguage);
        }
Ejemplo n.º 20
0
        // Token: 0x0600002D RID: 45 RVA: 0x00004F28 File Offset: 0x00003128
        public static bool CIS()
        {
            bool result;

            try
            {
                InputLanguageCollection installedInputLanguages = InputLanguage.InstalledInputLanguages;
                string[] array = new string[]
                {
                    "Kazakh",
                    "Russian",
                    "Belarusian",
                    "Ukrainian",
                    "Kyrgyz",
                    "Uzbek",
                    "Georgian",
                    "Azerbaijani",
                    "Tajik",
                    "Armenian",
                    "Turkmen"
                };
                foreach (object obj in installedInputLanguages)
                {
                    foreach (string value in array)
                    {
                        bool flag = ((InputLanguage)obj).Culture.EnglishName.Contains(value);
                        if (flag)
                        {
                            return(true);
                        }
                    }
                }
                result = false;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 21
0
        private void OnSwapLanguageButtonClicked(object sender, RoutedEventArgs e)
        {
            var inputLanguage  = this.inputLanguageComboBox.SelectedValue as LanguageDictionary;
            var outputLanguage = this.outputLanguageComboBox.SelectedValue as Language;

            if (inputLanguage == null || outputLanguage == null)
            {
                return;
            }

            this.inputText.Text         = this.outputText.Text;
            this.previousTranslatedText = this.inputText.Text;
            this.outputText.Text        = string.Empty;
            LanguageDictionary newInputLanguage = InputLanguageCollection.FirstOrDefault(l => l.Code.Equals(outputLanguage.Code, StringComparison.OrdinalIgnoreCase));

            if (newInputLanguage != null)
            {
                Language newOutputLanguage = newInputLanguage.Translations?.FirstOrDefault(l => l.Code.Equals(inputLanguage.Code, StringComparison.OrdinalIgnoreCase));
                this.outputLanguageName = newOutputLanguage?.Name ?? this.outputLanguageName;
                this.inputLanguageComboBox.SelectedValue = newInputLanguage;
            }
        }
Ejemplo n.º 22
0
        private int GetKeyboardLayoutId()
        {
            int processId;
            int keyboardLayoutId = 0;
            InputLanguageCollection inputLanguageCollection = InputLanguage.InstalledInputLanguages;

            IntPtr handle = NativeMethods.GetForegroundWindow();

            int winThreadProcId = NativeMethods.GetWindowThreadProcessId(handle, out processId);

            IntPtr KeybLayout = NativeMethods.GetKeyboardLayout(winThreadProcId);

            foreach (InputLanguage language in inputLanguageCollection)
            {
                if (KeybLayout == language.Handle)
                {
                    keyboardLayoutId = language.Culture.KeyboardLayoutId;
                    break;
                }
            }

            return(keyboardLayoutId);
        }
Ejemplo n.º 23
0
 private static bool langs()
 {
     try
     {
         InputLanguageCollection lang = InputLanguage.InstalledInputLanguages;
         string[] cislangs            = new string[] { "Kazakh", "Russian", "Belarusian", "Ukrainian" };
         foreach (object langs in lang)
         {
             foreach (string langs2 in cislangs)
             {
                 if (((InputLanguage)langs).Culture.EnglishName.Contains(langs2))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     catch
     {
         return(true);
     }
 }
Ejemplo n.º 24
0
 public static bool CIS()
 {
     try
     {
         InputLanguageCollection lang = InputLanguage.InstalledInputLanguages; // Getting all laguages on PC
         string[] array = new string[] { "Kazakh", "Russian", "Belarusian", "Ukrainian", "Kyrgyz", "Uzbek", "Georgian", "Azerbaijani", "Tajik", "Armenian", "Turkmen" };
         foreach (object langs in lang)
         {
             foreach (string value in array)
             {
                 if (((InputLanguage)langs).Culture.EnglishName.Contains(value))
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 25
0
        private async Task DetectedLanguageAsync(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            try
            {
                DetectedLanguageResult detectedLanguageResult = await this.translatorTextService?.DetectLanguageAsync(text);

                if (detectedLanguageResult != null)
                {
                    this.inputLanguage = InputLanguageCollection
                                         .FirstOrDefault(l => l.Code.Equals(detectedLanguageResult.Language, StringComparison.OrdinalIgnoreCase));
                    if (this.inputLanguage != null)
                    {
                        switch (this.pivotControl.SelectedIndex)
                        {
                        case 0:     // Pivot Text
                            this.inputLanguageComboBox.SelectedValue = this.inputLanguage;
                            break;

                        case 1:     // Pivot Image
                            this.detectedLanguageTextBox.Text = $"Detected Language: {this.inputLanguage.Name}";
                            UpdateOutputLanguageCombobox(this.inputLanguage);
                            break;
                        }
                    }
                }
            }
            catch
            {
                // just ignore the exception here and let user select the language
            }
        }
Ejemplo n.º 26
0
        internal static SortedList <uint, KeyboardLayoutInfo> KeyboardsOnMachine()
        {
            InputLanguageCollection installedInputLanguages = InputLanguage.InstalledInputLanguages;
            RegistryKey             keyLayouts         = null;
            RegistryKey             keyLayout          = null;
            SortedList <uint, KeyboardLayoutInfo> list = null;
            NumberFormatInfo nfi = new NumberFormatInfo();

            try
            {
                keyLayouts = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Keyboard Layouts", false);
                if (keyLayouts == null)
                {
                    throw new SecurityException();
                }

                list = new SortedList <uint, KeyboardLayoutInfo>(keyLayouts.SubKeyCount);
                foreach (String strKLID in keyLayouts.GetSubKeyNames())
                {
                    keyLayout = keyLayouts.OpenSubKey(strKLID, false);
                    String layoutName = "";
                    String layoutText = keyLayout.GetValue("Layout Text", "").ToString();
                    String pszSource  = keyLayout.GetValue("Layout Display Name", "").ToString();
                    if ((pszSource != null) && (pszSource.Length > 0))
                    {
                        StringBuilder pszOutBuf = new StringBuilder(260);
                        if (NativeMethods.Shlwapi.SHLoadIndirectString(pszSource, pszOutBuf, (uint)pszOutBuf.Capacity, IntPtr.Zero) == 0)
                        {
                            layoutName = pszOutBuf.ToString();
                        }
                    }
                    if (layoutName.Length == 0)
                    {
                        layoutName = layoutText;
                    }

                    if (layoutName.Length > 0 || layoutText.Length > 0)
                    {
                        uint nKLID = uint.Parse(strKLID, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);

                        // Ignore 0x5FE and Input Method Editor (IME) layouts
                        if ((nKLID & 0xFFF) == 0x5FE || nKLID >= 0xE0000000)
                        {
                            continue;
                        }

                        bool   doUnloadKeyboardLayout = true;
                        IntPtr hkl = NativeMethods.User32.LoadKeyboardLayout(nKLID.ToString("x8", nfi), 0x80);
                        if (hkl == IntPtr.Zero)
                        {
                            continue;
                        }

                        foreach (InputLanguage language in installedInputLanguages)
                        {
                            if (hkl == language.Handle)
                            {
                                doUnloadKeyboardLayout = false;
                                break;
                            }
                        }
                        if (doUnloadKeyboardLayout)
                        {
                            NativeMethods.User32.UnloadKeyboardLayout(hkl);
                        }

                        KeyboardLayoutInfo keyboard = new KeyboardLayoutInfo();
                        keyboard.HKL        = nKLID;
                        keyboard.LayoutFile = keyLayout.GetValue("Layout File", "").ToString();
                        keyboard.LayoutText = layoutText;
                        keyboard.LayoutName = layoutName;
                        String s = keyLayout.GetValue("Layout Id", "").ToString();
                        if (s.Length > 0)
                        {
                            keyboard.LayoutID = ushort.Parse(s, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
                        }
                        list.Add(nKLID, keyboard);
                    }
                    keyLayout.Close();
                    keyLayout = null;
                }
            }
            catch (ArgumentException)
            {
                list = null;
            }
            catch (SecurityException)
            {
                list = null;
            }
            finally
            {
                if (keyLayout != null)
                {
                    keyLayout.Close();
                }
                if (keyLayouts != null)
                {
                    keyLayouts.Close();
                }
            }
            return(list);
        }
Ejemplo n.º 27
0
        public Form1()
        {
            int x;

            InitializeComponent();

            ComOpenYet      = false;
            OpenButton.Text = "Открыть";
            _setk           = new SetK(SetKMethod);

            // Create the NotifyIcon.
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon();

            // The Icon property sets the icon that will appear
            // in the systray for this application.
            notifyIcon1.Icon = this.Icon;

            // The ContextMenu property sets the menu that will
            // appear when the systray icon is right clicked.
            //notifyIcon1.ContextMenu = this.contextMenu1;

            // The Text property sets the text that will be displayed,
            // in a tooltip, when the mouse hovers over the systray icon.
            notifyIcon1.Text    = "Смена раскладки клавиатуры";
            notifyIcon1.Visible = false;

            // Handle the DoubleClick event to activate the form.
            notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);

            // Задаем массивы элементов управления
            InputLanguageCollection installedLangs = InputLanguage.InstalledInputLanguages;

            foreach (InputLanguage lang in installedLangs)
            {
                KeybItems.Add(lang);
                Keyblang.Add(lang.LayoutName);
            }

            this.Width = 36 + 141 * Gr;
            // Комбобоксы
            for (x = 0; x < Gr; x++)
            {
                ComboBox newcombo = new ComboBox {
                    Location = new Point(12 + x * 141, 40),
                    Size     = new Size(width: 135, height: 21),
                    Visible  = true,
                    Parent   = this
                };

                newcombo.SelectedIndexChanged += new EventHandler(keyb_onchange);
                newcombo.Items.AddRange(Keyblang.ToArray());
                Keybs[x] = newcombo;
            }
            // Кнопки
            for (x = 0; x < Gr; x++)
            {
                Button newbut = new Button {
                    Location = new Point(12 + x * 141, 70),
                    Size     = new Size(width: 135, height: 21),
                    Visible  = true,
                    Parent   = this
                };

                newbut.Click += new EventHandler(but_onclick);
                Bts[x]        = newbut;
            }
            // Настройки
            x = 0;
            string opencomst = "";

            if (System.IO.File.Exists("config.ini"))
            {
                StreamReader sr = new StreamReader("config.ini");
                string       line;

                opencomst = sr.ReadLine();

                int i = 0;
                while (((line = sr.ReadLine()) != null) && (x < Gr))
                {
                    i = Convert.ToInt32(line);
                    if ((i < KeybItems.Count) && (i >= 0))
                    {
                        //Setkey[x] = i;
                        Keybs[x].SelectedIndex = i;
                    }
                    else
                    {
                        Setkey[x] = -1;
                    };

                    x++;
                }

                sr.Close();
            }

            for (; x < Gr; x++)
            {
                Setkey[x] = -1;
            }

            // Create a new SerialPort object with default settings.
            _serialPort = new SerialPort();
            int cc = -1;

            foreach (string s in SerialPort.GetPortNames())
            {
                COMcombo.Items.Add(s);
                if (opencomst == s)
                {
                    cc = COMcombo.Items.Count;
                }
            }

            if (cc != -1)
            {
                COMcombo.SelectedItem = COMcombo.Items[cc - 1];
                COMOpen(null, null);
            }

            if (!System.IO.File.Exists("config.ini"))
            {
                NeedSaveConfig = true;
            }
            else
            {
                NeedSaveConfig = false;
            }
        }