예제 #1
0
        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
        }
예제 #2
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.
            }
        }
예제 #3
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
        }
예제 #4
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.
			}
		}
예제 #6
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);
        }
예제 #7
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);
        }
예제 #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;
        }
예제 #9
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?
     }
 }
예제 #10
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);
		}
예제 #11
0
		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?
			}
		}
예제 #12
0
		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;
		}