Example #1
0
			/// <summary>
			/// Sets the available keyboard retrievers. Note that if this is called more than once,
			/// the retrievers installed previously will be closed and no longer useable. Do not
			/// pass retriever instances that have been previously passed. At least one retriever
			/// must be of type System.
			/// </summary>
			public static void SetKeyboardRetrievers(IKeyboardRetrievingAdaptor[] retrievers)
			{
				if (!(Keyboard.Controller is IKeyboardControllerImpl))
					Keyboard.Controller = new KeyboardControllerImpl();

				Instance.Keyboards.Clear(); // InitializeAdaptors below will fill it in again.

				if (KeyboardRetrievers == null)
					KeyboardRetrievers = new Dictionary<KeyboardType, IKeyboardRetrievingAdaptor>();

				foreach (var retriever in KeyboardRetrievers.Values)
					retriever.Close();

				KeyboardRetrievers.Clear();

				RegisterAvailableKeyboardRetrievers(retrievers);
			}
		private void SetKeyboardAdaptors(IKeyboardRetrievingAdaptor[] adaptors)
		{
			_keyboards.Clear();
			foreach (IKeyboardRetrievingAdaptor adaptor in _adaptors.Values)
				adaptor.Dispose();
			_adaptors.Clear();

			foreach (IKeyboardRetrievingAdaptor adaptor in adaptors)
			{
				if (adaptor.IsApplicable)
				{
					if ((adaptor.Type & KeyboardAdaptorType.System) == KeyboardAdaptorType.System)
						_adaptors[KeyboardAdaptorType.System] = adaptor;
					if ((adaptor.Type & KeyboardAdaptorType.OtherIm) == KeyboardAdaptorType.OtherIm)
						_adaptors[KeyboardAdaptorType.OtherIm] = adaptor;
				}
			}

			foreach (IKeyboardRetrievingAdaptor adaptor in adaptors)
			{
				if (!_adaptors.ContainsValue(adaptor))
					adaptor.Dispose();
			}

			// Now that we know who can deal with the keyboards we can retrieve all available
			// keyboards, as well as add the used keyboard adaptors as error report property.
			var bldr = new StringBuilder();
			foreach (IKeyboardRetrievingAdaptor adaptor in _adaptors.Values)
			{
				adaptor.Initialize();

				if (bldr.Length > 0)
					bldr.Append(", ");
				bldr.Append(adaptor.GetType().Name);
			}
			ErrorReport.AddProperty("KeyboardAdaptors", bldr.ToString());
			Logger.WriteEvent("Keyboard adaptors in use: {0}", bldr.ToString());
		}
Example #3
0
			private static void RegisterAvailableKeyboardRetrievers(IKeyboardRetrievingAdaptor[] retrievers)
			{
				foreach (var retriever in retrievers)
				{
					if (retriever.IsApplicable)
					{
						if ((retriever.Type & KeyboardType.System) == KeyboardType.System)
							KeyboardRetrievers[KeyboardType.System] = retriever;
						if ((retriever.Type & KeyboardType.OtherIm) == KeyboardType.OtherIm)
							KeyboardRetrievers[KeyboardType.OtherIm] = retriever;
					}
				}

				foreach (var retriever in retrievers)
				{
					if (!KeyboardRetrievers.ContainsValue(retriever))
						retriever.Close();
				}

				// Now that we know who can deal with the keyboards we can retrieve all available
				// keyboards, as well as add the used keyboard adaptors as error report property.
				var bldr = new StringBuilder();
				foreach (var retriever in KeyboardRetrievers.Values)
				{
					retriever.Initialize();
					retriever.RegisterAvailableKeyboards();

					if (bldr.Length > 0)
						bldr.Append(", ");
					bldr.Append(retriever.GetType().Name);
				}
				ErrorReport.AddProperty("KeyboardAdaptors", bldr.ToString());
				Logger.WriteEvent("Keyboard adaptors in use: {0}", bldr.ToString());
			}