コード例 #1
0
        private InputManager()
        {
            // STA Requirement
            //
            // Avalon doesn't necessarily require STA, but many components do.  Examples
            // include Cicero, OLE, COM, etc.  So we throw an exception here if the
            // thread is not STA.
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                throw new InvalidOperationException(SR.Get(SRID.RequiresSTA));
            }

            _stagingArea = new Stack();

            _primaryKeyboardDevice = new Win32KeyboardDevice(this);
            _primaryMouseDevice    = new Win32MouseDevice(this);
            _primaryCommandDevice  = new CommandDevice(this);

            _continueProcessingStagingAreaCallback = new DispatcherOperationCallback(ContinueProcessingStagingArea);

            _hitTestInvalidatedAsyncOperation = null;
            _hitTestInvalidatedAsyncCallback  = new DispatcherOperationCallback(HitTestInvalidatedAsyncCallback);

            _layoutUpdatedCallback = new EventHandler(OnLayoutUpdated); //need to cache it, LM only keeps weak ref
            ContextLayoutManager.From(Dispatcher).LayoutEvents.Add(_layoutUpdatedCallback);

            // Timer used to synchronize the input devices periodically
            _inputTimer          = new DispatcherTimer(DispatcherPriority.Background);
            _inputTimer.Tick    += new EventHandler(ValidateInputDevices);
            _inputTimer.Interval = TimeSpan.FromMilliseconds(125);
        }
コード例 #2
0
        /// <summary>
        ///     Initializes a new instance of this class.
        /// </summary>
        /// <param name="commandDevice">The logical CommandDevice associated with this event.</param>
        /// <param name="timestamp">The time when the input occured.</param>
        /// <param name="command">Command associated with this event.</param>
        internal CommandDeviceEventArgs(CommandDevice commandDevice, int timestamp, ICommand command)
            : base(commandDevice, timestamp)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            _command = command;
        }
コード例 #3
0
ファイル: CommandDevice.cs プロジェクト: JianwenSun/cc
        /// <summary>
        ///     Initializes a new instance of this class.
        /// </summary>
        /// <param name="commandDevice">The logical CommandDevice associated with this event.</param>
        /// <param name="timestamp">The time when the input occured.</param>
        /// <param name="command">Command associated with this event.</param>
        internal CommandDeviceEventArgs(CommandDevice commandDevice, int timestamp, ICommand command)
            : base(commandDevice, timestamp)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            _command = command;
        }
コード例 #4
-1
ファイル: InputManager.cs プロジェクト: JianwenSun/cc
        private InputManager()
        {
            // STA Requirement
            //
            // Avalon doesn't necessarily require STA, but many components do.  Examples
            // include Cicero, OLE, COM, etc.  So we throw an exception here if the
            // thread is not STA.
            if(Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                throw new InvalidOperationException(SR.Get(SRID.RequiresSTA));
            }

            _stagingArea = new Stack();

            _primaryKeyboardDevice = new Win32KeyboardDevice(this);
            _primaryMouseDevice = new Win32MouseDevice(this);
            _primaryCommandDevice = new CommandDevice(this);

            _stylusLogic = new StylusLogic(this);

            _continueProcessingStagingAreaCallback = new DispatcherOperationCallback(ContinueProcessingStagingArea);

            _hitTestInvalidatedAsyncOperation = null;
            _hitTestInvalidatedAsyncCallback = new DispatcherOperationCallback(HitTestInvalidatedAsyncCallback);

            _layoutUpdatedCallback = new EventHandler(OnLayoutUpdated); //need to cache it, LM only keeps weak ref
            ContextLayoutManager.From(Dispatcher).LayoutEvents.Add(_layoutUpdatedCallback);

            // Timer used to synchronize the input devices periodically
            _inputTimer = new DispatcherTimer(DispatcherPriority.Background);
            _inputTimer.Tick += new EventHandler(ValidateInputDevices);
            _inputTimer.Interval = TimeSpan.FromMilliseconds(125);
        }