Ejemplo n.º 1
0
            public KeyboardHelperImpl()
            {
                m_keymanHandler = LgKeymanHandlerClass.Create();

                if (!MiscUtils.IsUnix)
                {
                    m_lts = LgTextServicesClass.Create();
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Get available Keyman (Windows) keyboards.
        /// </summary>
        /// <param name="doIfError">
        /// Delegate to run if KeymanHandler.Init throws an exception. Takes the exception
        /// as an argument.
        /// </param>
        private static IEnumerable <string> GetAvailableKeyboards(Action <Exception> doIfError)
        {
            ILgKeymanHandler keymanHandler = LgKeymanHandlerClass.Create();

            try
            {
                var keyboards = new List <string>();

                try
                {
                    // Update handler with any new/removed keyman keyboards
                    keymanHandler.Init(true);
                }
                catch (Exception e)
                {
                    if (doIfError != null)
                    {
                        doIfError(e);
                    }
                    return(keyboards);
                }
                int clayout = keymanHandler.NLayout;

                for (int i = 0; i < clayout; ++i)
                {
                    var item = keymanHandler.get_Name(i);
                    // JohnT: haven't been able to reproduce FWR-1935, but apparently there's some bizarre
                    // circumstance where one of the names comes back null. If so, leave it out.
                    if (item != null)
                    {
                        keyboards.Add(item);
                    }
                }
                return(keyboards);
            }
            finally
            {
                keymanHandler.Close();
                Marshal.ReleaseComObject(keymanHandler);
            }
        }
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inits the keyman combo.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void InitKeymanCombo()
        {
            CheckDisposed();

            ILgKeymanHandler keymanHandler = LgKeymanHandlerClass.Create();

            m_cboKeyboard.Items.Clear();             // Clear out any old items from combobox list
            try
            {
                keymanHandler.Init(true);                 // Update handler with any new/removed keyman keyboards
            }
            catch (Exception e)
            {
                if (!m_fKeymanInitErrorReported)
                {
                    m_fKeymanInitErrorReported = true;
                    string caption = FwCoreDlgControls.kstidKeymanInitFailed;
                    string message = e.Message;
                    if (message == null || message == string.Empty)
                    {
                        message = caption;
                    }
                    MessageBox.Show(this.ParentForm, message, caption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }
            int    clayout    = keymanHandler.NLayout;
            string strKbdName = m_langDef.WritingSystem.KeymanKbdName;

            if (strKbdName == null)
            {
                strKbdName = FwCoreDlgControls.kstid_None;
            }
            m_cboKeyboard.Items.Add(FwCoreDlgControls.kstid_None);
            for (int i = 0; i < clayout; ++i)
            {
                m_cboKeyboard.Items.Add(keymanHandler.get_Name(i));
            }
            m_cboKeyboard.SelectedItem = strKbdName;
        }
Ejemplo n.º 4
0
 public KeyboardHelperImpl()
 {
     m_keymanHandler = LgKeymanHandlerClass.Create();
 }