示例#1
0
        /// <summary>
        /// Initializes the <see cref="EventInput"/> class.
        /// </summary>
        /// <param name="window">
        /// A <see cref="GameWindow"/> to which text input should be linked.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="window"/> is a null reference.
        /// </exception>
        public static void Initialize(GameWindow window)
        {
            if (initialized)
            {
                throw new InvalidOperationException("EventInput.Initialize(GameWindow) can only be called once!");
            }

            if (window == null)
            {
                throw new ArgumentNullException();
            }

            EventInput.hookProcDelegate = new WndProc(HookProc);
            EventInput.prevWndProc      = (IntPtr)EventInput.SetWindowLong(window.Handle, EventInput.GWL_WNDPROC, (int)Marshal.GetFunctionPointerForDelegate(EventInput.hookProcDelegate));

            EventInput.hIMC        = ImmGetContext(window.Handle);
            EventInput.initialized = true;
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyboardDispatcher"/> class.
 /// </summary>
 /// <param name="window">
 /// An instance of <see cref="GameWindow"/> needed for visualizing.
 /// </param>
 public KeyboardDispatcher(GameWindow window)
 {
     EventInput.Initialize(window);
     EventInput.CharEntered += new EventHandler <CharacterEventArgs>(this.EventInput_CharEntered);
     EventInput.KeyDown     += new EventHandler <KeyEventArgs>(this.EventInput_KeyDown);
 }