private KeymanVersion GetInstalledKeymanVersion()
        {
#if !MONO
            // limit the COMException catching by determining the current version once and assuming it for the
            // rest of the adaptor's lifetime
            try
            {
                var keyman10 = new KeymanClass();
                return(KeymanVersion.Keyman10);
            }
            catch (COMException)
            {
                // not 10
            }
            try
            {
                var keyman = new TavultesoftKeymanClass();
                return(KeymanVersion.Keyman7to9);
            }
            catch (COMException)
            {
                // Not 7-9
            }
            try
            {
                var keymanLink = new KeymanLink.KeymanLink();
                return(KeymanVersion.Keyman6);
            }
            catch (COMException)
            {
            }
#endif
            return(KeymanVersion.NotInstalled);
        }
        public void UpdateAvailableKeyboards()
        {
            CheckDisposed();
            Dictionary <string, KeymanKeyboardDescription> curKeyboards = KeyboardController.Instance.Keyboards.OfType <KeymanKeyboardDescription>().ToDictionary(kd => kd.Id);

#if !MONO
            switch (InstalledKeymanVersion)
            {
            case KeymanVersion.Keyman10:
                // Keyman10 keyboards are handled by the WinKeyboardAdapter and WindowsKeyboardSwitchingAdapter
                break;

            case KeymanVersion.Keyman7to9:
                var keyman = new TavultesoftKeymanClass();
                UpdateKeyboards(curKeyboards, keyman.Keyboards.OfType <Keyman7Interop.IKeymanKeyboard>().Select(kb => kb.Name), false);
                break;

            case KeymanVersion.Keyman6:
                var keymanLink = new KeymanLink.KeymanLink();
                if (keymanLink.Initialize())
                {
                    UpdateKeyboards(curKeyboards, keymanLink.Keyboards.Select(kb => kb.KbdName), true);
                }
                break;
            }
#endif
        }
Exemple #3
0
        public void UpdateAvailableKeyboards()
        {
            // Try the Keyman 7/8 interface
            try
            {
                var keyman = new TavultesoftKeymanClass();
                foreach (IKeymanKeyboard keyboard in keyman.Keyboards)
                {
                    KeyboardController.Manager.RegisterKeyboard(new KeymanKeyboardDescription(keyboard.Name, false, this));
                }
            }
            catch (Exception)
            {
                // Keyman 7 isn't installed or whatever.
            }

            // Try the Keyman 6 interface
            try
            {
                var keymanLink = new KeymanLink.KeymanLink();
                if (keymanLink.Initialize())
                {
                    foreach (var keyboard in keymanLink.Keyboards)
                    {
                        KeyboardController.Manager.RegisterKeyboard(new KeymanKeyboardDescription(keyboard.KbdName, true, this));
                    }
                }
            }
            catch (Exception)
            {
                // Keyman 6 isn't installed or whatever.
            }
        }
Exemple #4
0
        public void DeactivateKeyboard(KeyboardDescription keyboard)
        {
            CheckDisposed();
#if !MONO
            try
            {
                if (((KeymanKeyboardDescription)keyboard).IsKeyman6)
                {
                    var keymanLink = new KeymanLink.KeymanLink();
                    if (keymanLink.Initialize())
                    {
                        keymanLink.SelectKeymanKeyboard(null, false);
                    }
                }
                else
                {
                    var keyman = new TavultesoftKeymanClass();
                    keyman.Control.ActiveKeyboard = null;
                }
            }
            catch (Exception)
            {
                // Keyman not installed?
            }
#endif
        }
Exemple #5
0
        public void UpdateAvailableKeyboards()
        {
            CheckDisposed();
            Dictionary <string, KeymanKeyboardDescription> curKeyboards = KeyboardController.Instance.Keyboards.OfType <KeymanKeyboardDescription>().ToDictionary(kd => kd.Id);

            // Try the Keyman 7/8 interface
            try
            {
                var keyman = new TavultesoftKeymanClass();
                UpdateKeyboards(curKeyboards, keyman.Keyboards.OfType <IKeymanKeyboard>().Select(kb => kb.Name), false);
            }
            catch (Exception)
            {
                // Keyman 7 isn't installed or whatever.
            }

            // Try the Keyman 6 interface
            try
            {
                var keymanLink = new KeymanLink.KeymanLink();
                if (keymanLink.Initialize())
                {
                    UpdateKeyboards(curKeyboards, keymanLink.Keyboards.Select(kb => kb.KbdName), true);
                }
            }
            catch (Exception)
            {
                // Keyman 6 isn't installed or whatever.
            }

            foreach (KeymanKeyboardDescription keyboard in curKeyboards.Values)
            {
                keyboard.SetIsAvailable(false);
            }
        }
		public void UpdateAvailableKeyboards()
		{
			// Try the Keyman 7/8 interface
			try
			{
				var keyman = new TavultesoftKeymanClass();
				foreach (IKeymanKeyboard keyboard in keyman.Keyboards)
					KeyboardController.Manager.RegisterKeyboard(new KeymanKeyboardDescription(keyboard.Name, false, this));
			}
			catch (Exception)
			{				
				// Keyman 7 isn't installed or whatever.
			}

			// Try the Keyman 6 interface
			try
			{
				var keymanLink = new KeymanLink.KeymanLink();
				if (keymanLink.Initialize())
				{
					foreach (var keyboard in keymanLink.Keyboards)
						KeyboardController.Manager.RegisterKeyboard(new KeymanKeyboardDescription(keyboard.KbdName, true, this));
				}
			}
			catch (Exception)
			{
				// Keyman 6 isn't installed or whatever.
			}
		}
Exemple #7
0
        public bool ActivateKeyboard(KeyboardDescription keyboard)
        {
            CheckDisposed();
#if !MONO
            var keymanKbdDesc = (KeymanKeyboardDescription)keyboard;
            if (keymanKbdDesc.IsKeyman6)
            {
                try
                {
                    var keymanLink = new KeymanLink.KeymanLink();
                    if (!keymanLink.Initialize())
                    {
                        ErrorReport.NotifyUserOfProblem("Keyman6 could not be activated.");
                        return(false);
                    }
                    keymanLink.SelectKeymanKeyboard(keyboard.Id);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    var keyman        = new TavultesoftKeymanClass();
                    int oneBasedIndex = keyman.Keyboards.IndexOf(keyboard.Id);

                    if (oneBasedIndex < 1)
                    {
                        ErrorReport.NotifyUserOfProblem("The keyboard '{0}' could not be activated using Keyman 7.",
                                                        keyboard.Id);
                        return(false);
                    }
                    keyman.Control.ActiveKeyboard = keyman.Keyboards[oneBasedIndex];
                }
                catch (Exception)
                {
                    // Keyman 7 not installed?
                    return(false);
                }
            }
#endif

            KeyboardController.Instance.ActiveKeyboard = keyboard;
            return(true);
        }
Exemple #8
0
        public bool ActivateKeyboard(IKeyboardDefinition keyboard)
        {
            var keymanKbdDesc = (KeymanKeyboardDescription)keyboard;

            if (keymanKbdDesc.IsKeyman6)
            {
                try
                {
                    KeymanLink.KeymanLink keymanLink = new KeymanLink.KeymanLink();
                    if (!keymanLink.Initialize())
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem("Keyman6 could not be activated.");
                        return(false);
                    }
                    keymanLink.SelectKeymanKeyboard(keyboard.Layout);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                try
                {
                    TavultesoftKeymanClass keyman = new TavultesoftKeymanClass();
                    int oneBasedIndex             = keyman.Keyboards.IndexOf(keyboard.Layout);

                    if (oneBasedIndex < 1)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem("The keyboard '{0}' could not be activated using Keyman 7.",
                                                                         keyboard.Layout);
                        return(false);
                    }
                    keyman.Control.ActiveKeyboard = keyman.Keyboards[oneBasedIndex];
                }
                catch (Exception)
                {
                    // Keyman 7 not installed?
                    return(false);
                }
            }

            ((IKeyboardControllerImpl)Keyboard.Controller).ActiveKeyboard = keyboard;
            return(true);
        }
        public bool ActivateKeyboard(IKeyboardDefinition keyboard)
        {
            var keymanKbdDesc = (KeymanKeyboardDescription)keyboard;
            if (keymanKbdDesc.IsKeyman6)
            {
                try
                {
                    KeymanLink.KeymanLink keymanLink = new KeymanLink.KeymanLink();
                    if (!keymanLink.Initialize())
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem("Keyman6 could not be activated.");
                        return false;
                    }
                    keymanLink.SelectKeymanKeyboard(keyboard.Layout);
                }
                catch (Exception)
                {
                    return false;
                }
            }
            else
            {
                try
                {
                    TavultesoftKeymanClass keyman = new TavultesoftKeymanClass();
                    int oneBasedIndex = keyman.Keyboards.IndexOf(keyboard.Layout);

                    if (oneBasedIndex < 1)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem("The keyboard '{0}' could not be activated using Keyman 7.",
                            keyboard.Layout);
                        return false;
                    }
                    keyman.Control.ActiveKeyboard = keyman.Keyboards[oneBasedIndex];
                }
                catch (Exception)
                {
                    // Keyman 7 not installed?
                    return false;
                }
            }

            ((IKeyboardControllerImpl)Keyboard.Controller).ActiveKeyboard = keyboard;
            return true;
        }
Exemple #10
0
 public void DeactivateKeyboard(IKeyboardDefinition keyboard)
 {
     try
     {
         if (((KeymanKeyboardDescription)keyboard).IsKeyman6)
         {
             KeymanLink.KeymanLink keymanLink = new KeymanLink.KeymanLink();
             if (keymanLink.Initialize())
             {
                 keymanLink.SelectKeymanKeyboard(null, false);
             }
         }
         else
         {
             TavultesoftKeymanClass keyman = new TavultesoftKeymanClass();
             keyman.Control.ActiveKeyboard = null;
         }
     }
     catch (Exception)
     {
         // Keyman not installed?
     }
 }
		public void UpdateAvailableKeyboards()
		{
			CheckDisposed();
			Dictionary<string, KeymanKeyboardDescription> curKeyboards = KeyboardController.Instance.Keyboards.OfType<KeymanKeyboardDescription>().ToDictionary(kd => kd.Id);
			// Try the Keyman 7/8 interface
			try
			{
				var keyman = new TavultesoftKeymanClass();
				UpdateKeyboards(curKeyboards, keyman.Keyboards.OfType<IKeymanKeyboard>().Select(kb => kb.Name), false);
			}
			catch (Exception)
			{				
				// Keyman 7 isn't installed or whatever.
			}

			// Try the Keyman 6 interface
			try
			{
				var keymanLink = new KeymanLink.KeymanLink();
				if (keymanLink.Initialize())
					UpdateKeyboards(curKeyboards, keymanLink.Keyboards.Select(kb => kb.KbdName), true);
			}
			catch (Exception)
			{
				// Keyman 6 isn't installed or whatever.
			}

			foreach (KeymanKeyboardDescription keyboard in curKeyboards.Values)
				keyboard.SetIsAvailable(false);
		}
		public void DeactivateKeyboard(KeyboardDescription keyboard)
		{
			CheckDisposed();
			try
			{
				if (((KeymanKeyboardDescription) keyboard).IsKeyman6)
				{
					var keymanLink = new KeymanLink.KeymanLink();
					if (keymanLink.Initialize())
						keymanLink.SelectKeymanKeyboard(null, false);
				}
				else
				{
					var keyman = new TavultesoftKeymanClass();
					keyman.Control.ActiveKeyboard = null;
				}
			}
			catch (Exception)
			{
				// Keyman not installed?
			}
		}
		public bool ActivateKeyboard(KeyboardDescription keyboard)
		{
			CheckDisposed();
			var keymanKbdDesc = (KeymanKeyboardDescription)keyboard;
			if (keymanKbdDesc.IsKeyman6)
			{
				try
				{
					var keymanLink = new KeymanLink.KeymanLink();
					if (!keymanLink.Initialize())
					{
						ErrorReport.NotifyUserOfProblem("Keyman6 could not be activated.");
						return false;
					}
					keymanLink.SelectKeymanKeyboard(keyboard.Id);
				}
				catch (Exception)
				{
					return false;
				}
			}
			else
			{
				try
				{
					var keyman = new TavultesoftKeymanClass();
					int oneBasedIndex = keyman.Keyboards.IndexOf(keyboard.Id);

					if (oneBasedIndex < 1)
					{
						ErrorReport.NotifyUserOfProblem("The keyboard '{0}' could not be activated using Keyman 7.",
							keyboard.Id);
						return false;
					}
					keyman.Control.ActiveKeyboard = keyman.Keyboards[oneBasedIndex];
				}
				catch (Exception)
				{
					// Keyman 7 not installed?
					return false;
				}
			}

			KeyboardController.Instance.ActiveKeyboard = keyboard;
			return true;
		}