Пример #1
0
        private void settingsToolStripButton_Click(object sender, EventArgs e)
        {
            //Program.SettingsForm.Show();
            SimpleSettingsForm settingsForm = new SimpleSettingsForm(allLanguages, languages);

            if (settingsForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                UpdateLanguages();
                hotkeys.ClearHotKey();
                hotkeys.RegisterHotKey(Program.Settings.AutoTyper.Hotkey);
                OcrNetwork.Update();
            }
        }
Пример #2
0
        public void Initialize()
        {
            isUpdating = true;

            Program.SetEngines(engines);
            Program.SetTranslators(translators);

            foreach (var value in Enum.GetValues(typeof(OcrEngineType)))
            {
                OcrEngineType type   = (OcrEngineType)value;
                OcrEngine     engine = OcrEngine.Create(type);
                if (engine != null)// && engine.IsInstalled)
                {
                    engines[type] = engine;
                    ocrEngineToolStripComboBox.Items.Add(type);
                }
            }
            if (ocrEngineToolStripComboBox.Items.Count > 0)
            {
                ocrEngineToolStripComboBox.SelectedIndex = 0;
            }

            foreach (var value in Enum.GetValues(typeof(TranslatorType)))
            {
                TranslatorType type       = (TranslatorType)value;
                Translator     translator = Translator.Create(type);
                if (translator != null && translator.IsEnabled)
                {
                    translators[type] = translator;
                    translateApiToolStripComboBox.Items.Add(type);
                }
            }
            if (translateApiToolStripComboBox.Items.Count > 0)
            {
                translateApiToolStripComboBox.SelectedIndex = 0;
            }

            foreach (var value in Enum.GetValues(typeof(OcrEngineProfile)))
            {
                OcrEngineProfile profile = (OcrEngineProfile)value;
                if (profile < OcrEngineProfile.Linear)
                {
                    ocrProfileToolStripComboBox.Items.Add(profile);
                }
                else
                {
                    for (int i = 2; i <= Program.ProfilesCount; i++)
                    {
                        ocrProfileToolStripComboBox.Items.Add(profile + " " + i + "x");
                    }
                }
            }
            if (ocrProfileToolStripComboBox.Items.Count > 0)
            {
                ocrProfileToolStripComboBox.SelectedIndex = 0;
            }

            UpdateLanguages();

            ocrEngineToolStripComboBox.ComboBox.PreviewKeyDown     += ComboBox_PreviewKeyDown;
            ocrProfileToolStripComboBox.ComboBox.PreviewKeyDown    += ComboBox_PreviewKeyDown;
            translateApiToolStripComboBox.ComboBox.PreviewKeyDown  += ComboBox_PreviewKeyDown;
            translateFromToolStripComboBox.ComboBox.PreviewKeyDown += ComboBox_PreviewKeyDown;
            translateToToolStripComboBox.ComboBox.PreviewKeyDown   += ComboBox_PreviewKeyDown;

            ocrEngineToolStripComboBox.ComboBox.MouseWheel     += toolStripComboBox_MouseWheel;
            ocrProfileToolStripComboBox.ComboBox.MouseWheel    += toolStripComboBox_MouseWheel;
            translateApiToolStripComboBox.ComboBox.MouseWheel  += toolStripComboBox_MouseWheel;
            translateFromToolStripComboBox.ComboBox.MouseWheel += toolStripComboBox_MouseWheel;
            translateToToolStripComboBox.ComboBox.MouseWheel   += toolStripComboBox_MouseWheel;

            comboBoxPrevIndex[ocrEngineToolStripComboBox]     = 0;
            comboBoxPrevIndex[ocrProfileToolStripComboBox]    = 0;
            comboBoxPrevIndex[translateApiToolStripComboBox]  = 0;
            comboBoxPrevIndex[translateFromToolStripComboBox] = 0;
            comboBoxPrevIndex[translateToToolStripComboBox]   = 0;

            translateFromToolStripComboBox.ComboBox.DrawItem += LanguageComboBox_DrawItem;
            translateFromToolStripComboBox.ComboBox.DrawMode  = DrawMode.OwnerDrawFixed;

            translateToToolStripComboBox.ComboBox.DrawItem += LanguageComboBox_DrawItem;
            translateToToolStripComboBox.ComboBox.DrawMode  = DrawMode.OwnerDrawFixed;

            ocrEngineToolStripComboBox.ComboBox.DrawItem += EngineComboBox_DrawItem;
            ocrEngineToolStripComboBox.ComboBox.DrawMode  = DrawMode.OwnerDrawFixed;

            ocrImagePanel.ImageChanged += ocrImagePanel_ImageChanged;
            OcrHelper.Complete         += OcrHelper_Complete;
            OcrHelper.Start            += OcrHelper_Start;
            TranslateHelper.Start      += TranslateHelper_Start;
            TranslateHelper.Complete   += TranslateHelper_Complete;

            string from = Program.Settings.LanguageProfiles.Slot1;
            string to   = Program.Settings.TargetLanguage.TargetLanguage;

            if (!string.IsNullOrEmpty(from) && !string.IsNullOrEmpty(to))
            {
                int fromIndex = translateFromToolStripComboBox.Items.IndexOf(from);
                int toIndex   = translateToToolStripComboBox.Items.IndexOf(to);
                if (fromIndex >= 0 && toIndex >= 0)
                {
                    translateFromToolStripComboBox.SelectedIndex = fromIndex;
                    translateToToolStripComboBox.SelectedIndex   = toIndex;
                }
            }

            hotkeys.KeyPressed += hotkeys_KeyPressed;
            hotkeys.ClearHotKey();
            hotkeys.RegisterHotKey(Program.Settings.AutoTyper.Hotkey);

            isUpdating = false;
            SettingsChanged();

            OcrNetwork.Update();
        }