private void _btnMoveTop_Click(object sender, EventArgs e)
        {
            MyLanguage ml    = (MyLanguage)_enabledLanguagesListBox.SelectedItem;
            int        index = _enabledLanguagesListBox.Items.IndexOf(ml);

            if (index <= 0)
            {
                return;
            }

            _enabledLanguagesListBox.Items.RemoveAt(index);
            _enabledLanguagesListBox.Items.Insert(0, ml);
            _enabledLanguagesListBox.SetSelected(0, true);
        }
Exemplo n.º 2
0
        private void InitOCRLanguages(IOcrEngine ocrEngine)
        {
            var languageManager = ocrEngine.LanguageManager;

            // Get the languages supported by this engine and fill the list box
            string[] languages           = languageManager.GetSupportedLanguages();
            string[] enabledLanguages    = languageManager.GetEnabledLanguages();
            var      languagesDictionary = new Dictionary <string, string>();

            var friendlyNames = new string[languages.Length];

            int index = 0;

            foreach (var language in languages)
            {
                friendlyNames[index] = MyLanguage.GetLanguageFriendlyName(language);
                languagesDictionary.Add(friendlyNames[index], language);
                index++;
            }

            index = 0;
            foreach (var friendlyName in friendlyNames)
            {
                // Don't add the enabled languages to the available languages list
                bool languageEnabled = false;
                foreach (var enabledLanguage in enabledLanguages)
                {
                    if (languagesDictionary[friendlyName].Equals(enabledLanguage))
                    {
                        languageEnabled = true;
                        break;
                    }
                }

                if (!languageEnabled)
                {
                    var ml = new MyLanguage(languagesDictionary[friendlyName], friendlyName, index);
                    _languagesListBox.Items.Add(ml);
                }
                index++;
            }

            // Fill the 'Enabled Languages' list box
            foreach (var enabledLanguage in enabledLanguages)
            {
                index = 0;
                foreach (var entry in languagesDictionary)
                {
                    if (entry.Value.Equals(enabledLanguage))
                    {
                        break;
                    }
                    index++;
                }

                string friendlyName = MyLanguage.GetLanguageFriendlyName(enabledLanguage);
                var    ml           = new MyLanguage(enabledLanguage, friendlyName, index);
                _enabledLanguagesListBox.Items.Add(ml);
            }

            if (!languageManager.SupportsEnablingMultipleLanguages || _languagesListBox.Items.Count <= 1)
            {
                _languagesListBox.SelectionMode = SelectionMode.One;
            }

            string[] additionalLanguages = languageManager.GetAdditionalLanguages();
            if (additionalLanguages != null && additionalLanguages.Length > 0)
            {
                _languagesAdditionalLabel.Text = "There are more languages supported by this engine that are not installed on this machine.\r\nVisit our website at http://www.leadtools.com for more information.";
            }
        }
        public EnableLanguagesDialog(IOcrEngine ocrEngine, Image moveRightImage, Image moveLeftImage, Image moveTopImage)
        {
            InitializeComponent();

            _ocrEngine = ocrEngine;
            IOcrLanguageManager languageManager = _ocrEngine.LanguageManager;

            // Get the languages supported by this engine and fill the list box
            string[] languages        = languageManager.GetSupportedLanguages();
            string[] enabledLanguages = languageManager.GetEnabledLanguages();
            Dictionary <string, string> languagesDictionary = new Dictionary <string, string>();

            string[] friendlyNames = new string[languages.Length];

            int i = 0;

            foreach (string language in languages)
            {
                friendlyNames[i] = MyLanguage.GetLanguageFriendlyName(language);
                languagesDictionary.Add(friendlyNames[i], language);
                i++;
            }

            //Array.Sort(friendlyNames, 1, friendlyNames.Length - 1);

            i = 0;
            foreach (string friendlyName in friendlyNames)
            {
                // Don't add the enabled languages to the available languages list
                bool languageEnabled = false;
                foreach (string enabledLanguage in enabledLanguages)
                {
                    if (languagesDictionary[friendlyName].Equals(enabledLanguage))
                    {
                        languageEnabled = true;
                        break;
                    }
                }

                if (!languageEnabled)
                {
                    MyLanguage ml = new MyLanguage(languagesDictionary[friendlyName], friendlyName, i);
                    _languagesListBox.Items.Add(ml);
                }
                i++;
            }

            // Fill the 'Enabled Languages' list box
            foreach (string enabledLanguage in enabledLanguages)
            {
                i = 0;
                foreach (KeyValuePair <string, string> entry in languagesDictionary)
                {
                    if (entry.Value.Equals(enabledLanguage))
                    {
                        break;
                    }
                    i++;
                }
                string     friendlyName = MyLanguage.GetLanguageFriendlyName(enabledLanguage);
                MyLanguage ml           = new MyLanguage(enabledLanguage, friendlyName, i);
                _enabledLanguagesListBox.Items.Add(ml);
            }

            if (!languageManager.SupportsEnablingMultipleLanguages || _languagesListBox.Items.Count <= 1)
            {
                _languagesListBox.SelectionMode = SelectionMode.One;
            }

            string[] additionalLanguages = languageManager.GetAdditionalLanguages();
            if (additionalLanguages != null && additionalLanguages.Length > 0)
            {
                _additionalLabel.Text = DemosGlobalization.GetResxString(GetType(), "Resx_SupportedLanguages") + "\n" + DemosGlobalization.GetResxString(GetType(), "Resx_EngineComponents");
            }

            // Set the buttons images
            if (moveRightImage != null)
            {
                _btnMoveRight.Image = moveRightImage;
            }
            else
            {
                _btnMoveRight.Text = "→";
            }
            if (moveLeftImage != null)
            {
                _btnMoveLeft.Image = moveLeftImage;
            }
            else
            {
                _btnMoveLeft.Text = "←";
            }
            if (moveTopImage != null)
            {
                _btnMoveTop.Image = moveTopImage;
            }
            else
            {
                _btnMoveTop.Text = "↑";
            }

            UpdateUIState();
        }