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); }
public InvokeOnRenderCallback( DispatcherOperationCallback callback, object arg) { this._callback = callback; this._arg = arg; }
internal StylusLogic(InputManager inputManager) { _inputManager = new SecurityCriticalData<InputManager>(inputManager);; _inputManager.Value.PreProcessInput += new PreProcessInputEventHandler(PreProcessInput); _inputManager.Value.PreNotifyInput += new NotifyInputEventHandler(PreNotifyInput); _inputManager.Value.PostProcessInput += new ProcessInputEventHandler(PostProcessInput); #if !MULTICAPTURE _overIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsEnabledChanged); _overIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsVisibleChanged); _overIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsHitTestVisibleChanged); _reevaluateStylusOverDelegate = new DispatcherOperationCallback(ReevaluateStylusOverAsync); _reevaluateStylusOverOperation = null; _captureIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsEnabledChanged); _captureIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsVisibleChanged); _captureIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsHitTestVisibleChanged); _reevaluateCaptureDelegate = new DispatcherOperationCallback(ReevaluateCaptureAsync); _reevaluateCaptureOperation = null; #endif _shutdownHandler = new EventHandler(this.OnDispatcherShutdown); _processDisplayChanged = new DispatcherOperationCallback(ProcessDisplayChanged); _processDeferredMouseMove = new DispatcherOperationCallback(ProcessDeferredMouseMove); ReadSystemConfig(); _dlgInputManagerProcessInput = new DispatcherOperationCallback(InputManagerProcessInput); }
private LayoutManager() { // This constructor exists to prevent instantiation of a LayoutManager by any // means other than through LayoutManager.CurrentLayoutManager. _updateLayoutBackground = new DispatcherOperationCallback(UpdateLayoutBackground); _updateCallback = new DispatcherOperationCallback(UpdateLayoutCallback); }
object RunOnUIThread(DispatcherOperationCallback dispatcherMethod) { if (Application.Current.Dispatcher.Thread == Thread.CurrentThread) { // This avoids dispatching to the UI thread if we are already in the UI thread. // Without this runing a command like 1/0 was throwing due to nested dispatches. return(dispatcherMethod.Invoke(null)); } Exception e = null; object returnValue = null; SynchronizationContext sync = new DispatcherSynchronizationContext(JobWindow.Dispatcher); sync.Send( new SendOrPostCallback(delegate(object obj) { try { returnValue = dispatcherMethod.Invoke(obj); } catch (Exception uiException) { e = uiException; } }), null); if (e != null) { throw new System.Reflection.TargetInvocationException(e.Message, e); } return(returnValue); }
// // Invoke a delegate in a try/catch. // internal object WrappedInvoke(DispatcherOperationCallback callback, object arg) { object result = null; try { result = callback(arg); } catch (Exception e) { #if TINYCLR_DEBUG_DISPATCHER // allow the debugger to break on the original exception. if (System.Diagnostics.Debugger.IsAttached) { } else #endif if (_finalExceptionHandler == null || !_finalExceptionHandler(this, e)) { throw; } } return(result); }
private void UpdateWithNewResult(Exception error, object newData, DispatcherOperationCallback completionWork, object callbackArgs) { bool errorChanged = (_error != error); _error = error; if (error != null) { newData = null; _initialLoadCalled = false; // allow again InitialLoad after an error } _data = newData; if (completionWork != null) { completionWork(callbackArgs); } // notify any listeners OnPropertyChanged(new PropertyChangedEventArgs("Data")); if (DataChanged != null) { DataChanged(this, EventArgs.Empty); } if (errorChanged) { OnPropertyChanged(new PropertyChangedEventArgs("Error")); } }
/// <summary> /// Executes the specified delegate asynchronously with the specified /// arguments, on the thread that the Dispatcher was created on. /// </summary> /// <param name="method"> /// A delegate to a method that takes parameters of the same number /// and type that are contained in the args parameter. /// </param> /// <param name="args"> /// An object to pass as the argument to the given method. /// This can be null if no arguments are needed. /// </param> /// <returns> /// A DispatcherOperation object that represents the result of the /// BeginInvoke operation. null if the operation could not be queued. /// </returns> public DispatcherOperation BeginInvoke(DispatcherOperationCallback method, object args) { if (method == null) { throw new ArgumentNullException("method"); } DispatcherOperation operation = null; lock (_instanceLock) { if (!_hasShutdownFinished) { operation = new DispatcherOperation(this, method, args); // Add the operation to the work queue _queue.Enqueue(operation); // set the event only when the queue becomes non-empty, // the dispatcher only waits when the queue is empty, // so this makes it wake-up if (_queue.Count == 1) { _event.Set(); } } } return(operation); }
internal void BeginInvokeOnRender(DispatcherOperationCallback callback, object arg) { Debug.Assert(callback != null); // While technically it could be OK for the arg to be null, for now // I know that arg represents the this reference for the layout // process and should never be null. Debug.Assert(arg != null); if (this._invokeOnRenderCallbacks == null) { lock (this) { if (this._invokeOnRenderCallbacks == null) { this._invokeOnRenderCallbacks = new ArrayList(); } } } lock (this._invokeOnRenderCallbacks) { this._invokeOnRenderCallbacks.Add(new InvokeOnRenderCallback(callback, arg)); } PostRender(); }
/// <summary> /// Constructor /// </summary> internal MediaEventsHelper(MediaPlayer mediaPlayer) { _mediaOpened = new DispatcherOperationCallback(OnMediaOpened); this.DispatcherMediaOpened += _mediaOpened; _mediaFailed = new DispatcherOperationCallback(OnMediaFailed); this.DispatcherMediaFailed += _mediaFailed; _mediaPrerolled = new DispatcherOperationCallback(OnMediaPrerolled); this.DispatcherMediaPrerolled += _mediaPrerolled; _mediaEnded = new DispatcherOperationCallback(OnMediaEnded); this.DispatcherMediaEnded += _mediaEnded; _bufferingStarted = new DispatcherOperationCallback(OnBufferingStarted); this.DispatcherBufferingStarted += _bufferingStarted; _bufferingEnded = new DispatcherOperationCallback(OnBufferingEnded); this.DispatcherBufferingEnded += _bufferingEnded; _scriptCommand = new DispatcherOperationCallback(OnScriptCommand); this.DispatcherScriptCommand += _scriptCommand; _newFrame = new DispatcherOperationCallback(OnNewFrame); this.DispatcherMediaNewFrame += _newFrame; SetSender(mediaPlayer); }
internal MouseDevice(InputManager inputManager) { _inputManager = new SecurityCriticalData<InputManager>(inputManager); _inputManager.Value.PreProcessInput += new PreProcessInputEventHandler(PreProcessInput); _inputManager.Value.PreNotifyInput += new NotifyInputEventHandler(PreNotifyInput); _inputManager.Value.PostProcessInput += new ProcessInputEventHandler(PostProcessInput); // Get information about how far two clicks of a double click can be considered // to be in the "same place and time". // // The call here goes into the safe helper calls, more of a consistency in approach // _doubleClickDeltaX = SafeSystemMetrics.DoubleClickDeltaX; _doubleClickDeltaY = SafeSystemMetrics.DoubleClickDeltaY; _doubleClickDeltaTime = SafeNativeMethods.GetDoubleClickTime(); _overIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsEnabledChanged); _overIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsVisibleChanged); _overIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsHitTestVisibleChanged); _reevaluateMouseOverDelegate = new DispatcherOperationCallback(ReevaluateMouseOverAsync); _reevaluateMouseOverOperation = null; _captureIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsEnabledChanged); _captureIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsVisibleChanged); _captureIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsHitTestVisibleChanged); _reevaluateCaptureDelegate = new DispatcherOperationCallback(ReevaluateCaptureAsync); _reevaluateCaptureOperation = null; _inputManager.Value.HitTestInvalidatedAsync += new EventHandler(OnHitTestInvalidatedAsync); }
public static bool InitWPFArithmeticExceptionWorkround() { try { // Call fpreset early just to handle case with missed "msvcrt.dll" // in future Windows versions _fpreset(); Assembly assembly = typeof(System.Windows.UIElement).Assembly; Type managerType = assembly.GetType("System.Windows.ContextLayoutManager"); if (managerType != null) { FieldInfo field = managerType.GetField("_updateCallback", BindingFlags.Static | BindingFlags.NonPublic); if (field != null) { _oldUpdateLayoutCallback = field.GetValue(null) as DispatcherOperationCallback; if (_oldUpdateLayoutCallback != null) { field.SetValue(null, new DispatcherOperationCallback(UpdateLayoutCallback)); return(true); } } } } catch { } return(false); }
internal void BeginInvokeOnRender(DispatcherOperationCallback callback, object arg) { Debug.Assert(callback != null); // While technically it could be OK for the arg to be null, for now // I know that arg represents the this reference for the layout // process and should never be null. Debug.Assert(arg != null); if (_invokeOnRenderCallbacks == null) { lock (this) { if (_invokeOnRenderCallbacks == null) { _invokeOnRenderCallbacks = new ArrayList(); } } } lock (_invokeOnRenderCallbacks) { _invokeOnRenderCallbacks.Add(new InvokeOnRenderCallback(callback, arg)); } PostRender(); }
/// <summary> /// <see cref="System.Windows.Documents.DocumentPaginator.GetPageAsync(int,object)"/> /// </summary> internal void GetPageAsync(int pageNumber, object userState) { DocumentsTrace.FixedFormat.IDF.Trace(string.Format("IDP.GetPageAsync({0}, {1})", pageNumber, userState)); // Make sure that the call is in the right context. // Dispatcher.VerifyAccess(); // Page number cannot be negative. if (pageNumber < 0) { throw new ArgumentOutOfRangeException("pageNumber", SR.Get(SRID.IDPNegativePageNumber)); } if (userState == null) { throw new ArgumentNullException("userState"); } // Add to outstanding AsyncOp list GetPageAsyncRequest asyncRequest = new GetPageAsyncRequest(new RequestedPage(pageNumber /*childPaginator, childPageNumber*/), userState); _asyncOps[userState] = asyncRequest; DispatcherOperationCallback queueTask = new DispatcherOperationCallback(_GetPageAsyncDelegate); Dispatcher.BeginInvoke(DispatcherPriority.Background, queueTask, asyncRequest); }
public InvokeOnRenderCallback( DispatcherOperationCallback callback, object arg) { _callback = callback; _arg = arg; }
/// <summary>現在メッセージ待ち行列の中にある全UIメッセージを処理する</summary> private void DoEvents() { // 新しくネスト化されたメッセージ ポンプを作成 DispatcherFrame frame = new DispatcherFrame(); // DispatcherFrame (= 実行ループ) を終了させるコールバック DispatcherOperationCallback exitFrameCallback = (f) => { // ネスト化されたメッセージ ループを抜ける ((DispatcherFrame)f).Continue = false; return(null); }; // 非同期で実行する // 優先度を Background にしているので、このコールバックは // ほかに処理するメッセージがなくなったら実行される DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke( DispatcherPriority.Background, exitFrameCallback, frame); // 実行ループを開始する Dispatcher.PushFrame(frame); // コールバックが終了していない場合は中断 if (exitOperation.Status != DispatcherOperationStatus.Completed) { exitOperation.Abort(); } }
/// <summary> /// /// </summary> public SignalPackage(Dispatcher d, DispatcherOperationCallback callback, DispatcherPriority p, object t) { _Dispatcher = d; _Priority = p; _Tag = t; _Callback = callback; }
/// <summary> /// This code runs in the worker thread when LoadStreamAsync() finishes. /// </summary> /// <param name="asyncResult"></param> private void LoadStreamCallback(Stream asyncResult) { // Now have the UI thread regain control and initialize the SoundPlayer DispatcherOperationCallback loadStreamCompletedCaller = new DispatcherOperationCallback(OnLoadStreamCompleted); Dispatcher.BeginInvoke(DispatcherPriority.Normal, loadStreamCompletedCaller, asyncResult); }
/// <summary> /// Maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation. /// </summary> /// <param name="source"></param> public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register the object as an input source with the input manager and // get back an InputProviderSite object. The InputProviderSite // object forwards the input report to the input manager. The input // manager then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's // ReportInput method. callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return site.ReportInput(args.Device, args.Report); }); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider. HardwareProvider hwProvider = new HardwareProvider(); // Create the pins that are needed for the buttons. Default their // values for the emulator. Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins. If the left pin is // not set, assume none of the pins are set and set the left pin // back to the default emulator value. if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) pinLeft = Cpu.Pin.GPIO_Pin0; else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as // input from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons with the pins as discovered or set // above. new ButtonPad(this, Button.VK_LEFT , pinLeft ), new ButtonPad(this, Button.VK_RIGHT , pinRight ), new ButtonPad(this, Button.VK_UP , pinUp ), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN , pinDown ), }; this.buttons = buttons; }
internal LoadedOrUnloadedOperation( DispatcherOperationCallback callback, DependencyObject target) { Debug.Assert(callback != null && target != null); _callback = callback; _target = target; }
private void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(ExitFrames); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); }
/// <summary> /// The MediaContext lives in the Dispatcher and is the MediaSystem's class that keeps /// per Dispatcher state. /// </summary> internal MediaContext() { _renderMessage = new DispatcherOperationCallback(RenderMessageHandler); // we have one render target, the window manager _target = WindowManager.Instance; _screen = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight); }
PostSerializationTask( DispatcherOperationCallback taskItem ) { _dispatcher.BeginInvoke(DispatcherPriority.Background, taskItem, null); }
public FrameTimer(DispatcherFrame frame, int milliseconds, DispatcherOperationCallback callback, DispatcherPriority priority) : base(priority) { this.frame = frame; this.callback = callback; Interval = TimeSpan.FromMilliseconds(milliseconds); Tick += new EventHandler(OnTick); }
///<summary> /// This is a private wrapper for encapsulating the CallbackResult class creation ///</summary> public static CallbackResult EnqueueCallback( DispatcherPriority priority, DispatcherOperationCallback method, object args) { DispatcherOperation operation = BeginInvoke(Dispatcher.CurrentDispatcher, priority, method, args); return(new CallbackResult(operation)); }
internal DispatcherOperation( Dispatcher dispatcher, DispatcherOperationCallback method, object args) { _dispatcher = dispatcher; _method = method; _args = args; }
object RunOnUIThread(DispatcherOperationCallback dispatcherMethod, bool async) { if (Application.Current != null) { if (Application.Current.Dispatcher.Thread == Thread.CurrentThread) { // This avoids dispatching to the UI thread if we are already in the UI thread. // Without this runing a command like 1/0 was throwing due to nested dispatches. return dispatcherMethod.Invoke(null); } } Exception e = null; object returnValue = null; SynchronizationContext sync = new DispatcherSynchronizationContext(Dispatcher); if (sync == null) { return null; } if (async) { sync.Post( new SendOrPostCallback(delegate(object obj) { try { returnValue = dispatcherMethod.Invoke(obj); } catch (Exception uiException) { e = uiException; } }), null); } else { sync.Send( new SendOrPostCallback(delegate(object obj) { try { returnValue = dispatcherMethod.Invoke(obj); } catch (Exception uiException) { e = uiException; } }), null); } if (e != null) { throw new System.Reflection.TargetInvocationException(e.Message, e); } return returnValue; }
/// <summary> /// Activates the first instance of the application. /// </summary> /// <param name="args"> List of arguments to pass to the first instance. </param> public void InvokeFirstInstance(IList <string> args) { if (Application.Current != null) { // Do an asynchronous call to ActivateFirstInstance function var operationCallback = new DispatcherOperationCallback(ActivateFirstInstanceCallback); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, operationCallback, args); } }
/// <summary> /// UIを更新します /// </summary> public static void UpdateUI() { DispatcherFrame frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(obj => { ((DispatcherFrame)obj).Continue = false; return null; }); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); }
/// <summary> /// /// </summary> /// <param name="task"></param> /// <param name="arg"></param> /// <param name="priority"></param> public void BeginInvoke(DispatcherOperationCallback task, Object arg, DispatcherPriority priority) { try { Dispatcher.CurrentDispatcher.BeginInvoke(priority, new DispatcherOperationCallback(task), arg); } catch (Exception E) { failTest("The following exception was thrown queuing task \"" + task.ToString() + "\": " + E.ToString() + "\n"); } }
internal MediaContext() { this._renderMessage = new DispatcherOperationCallback(this.RenderMessageHandler); DisplayController displayController = WindowManager.Instance.DisplayController; this._target = WindowManager.Instance; this._screen = new GHIElectronics.TinyCLR.UI.Bitmap(Graphics.FromHdc(displayController.Hdc)); this._screenW = (int)displayController.ActiveSettings.Width; this._screenH = (int)displayController.ActiveSettings.Height; this._dirtyX0 = (int)displayController.ActiveSettings.Width; this._dirtyY0 = (int)displayController.ActiveSettings.Height; }
/// <summary> /// 增加了: 错误处理。 /// </summary> /// <param name="newData"></param> /// <param name="error"></param> /// <param name="completionWork"></param> /// <param name="callbackArguments"></param> protected override void OnQueryFinished(object newData, Exception error, DispatcherOperationCallback completionWork, object callbackArguments) { base.OnQueryFinished(newData, error, completionWork, callbackArguments); if (error != null) { Logger.LogError("DataProvider 获取数据报错", error); Action <Exception> action = e => e.Alert(); Application.Current.Dispatcher.Invoke(action, error); } }
private void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(obj => { ((DispatcherFrame)obj).Continue = false; return(null); }); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); }
/// <summary> /// 現在メッセージ待ち行列の中にあるUIメッセージを処理する /// </summary> public static void UpdateUI() { var frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(obj => { ((DispatcherFrame)obj).Continue = false; return(null); }); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); }
/// <summary> /// Will flush dispatcher queue. /// </summary> /// <param name="priority"></param> /// <param name="d"></param> /// <param name="args"></param> /// <param name="delay"></param> public static void DelayedBeginInvoke(DispatcherPriority priority, DispatcherOperationCallback d, object args, TimeSpan delay) { DispatcherTimer timer = new DispatcherTimer(priority); timer.Interval = delay; timer.Tick += delegate { timer.Stop(); d(args); }; timer.Tag = args; timer.Start(); }
/// <summary/> protected void VerifyWithinContext() { DispatcherOperationCallback callback = delegate(object foo) { // WaitForCompleteRender seems to be bogus! The real saviour is ApplicationIdle... Photographer.WaitForCompleteRender(); Verify(); return(null); }; Invoke(DispatcherPriority.ApplicationIdle, callback, null); }
/// <summary> /// 現在メッセージ待ち行列の中にある全てのUIメッセージを処理します。 /// </summary> public static void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(obj => { ((DispatcherFrame)obj).Continue = false; return(null); }); GetActiveWindow().Dispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); //GetActiveWindow().Dispatcher.BeginInvoke(new Action(() => { }), DispatcherPriority.Background); }
public MultitouchInputProvider(PresentationSource source) { this.source = source; contactsQueue = new Queue<RawMultitouchReport>(); inputManagerProcessInput = InputManagerProcessInput; contactHandler = new ContactHandler(((HwndSource)source).Handle); contactHandler.ContactMoved += HandleContact; contactHandler.ContactRemoved += HandleContact; contactHandler.NewContact += HandleContact; inputManager = InputManager.Current; multitouchLogic = MultitouchLogic.Current; }
private InputManager() { _stagingArea = new Stack(); InputDeviceEvents = new DeviceEvents[(int)InputDeviceType.Last]; for (int i = 0; i < (int)InputDeviceType.Last; i++) { InputDeviceEvents[i] = new DeviceEvents(); } _continueProcessingStagingAreaCallback = new DispatcherOperationCallback(ProcessStagingArea); _buttonDevice = new ButtonDevice(this); _touchDevice = new TouchDevice(this); _genericDevice = new GenericDevice(this); }
public GPIOButtonInputProvider(PresentationSource source, ButtonDefinition[] ButtonDefinitions) { this.RepeatDelay = 500; this.RepeatPeriod = 150; this.PresentationSource = source; this.InputSite = InputManager.CurrentInputManager.RegisterInputProvider(this); this.ReportInputFunc = new DispatcherOperationCallback( ReportInputCallback ); this.Dispatcher = Microsoft.SPOT.Dispatcher.CurrentDispatcher; this.Buttons = new GpioButtonHandler[ButtonDefinitions.Length]; for( int i = 0; i < ButtonDefinitions.Length; i++ ) { ButtonDefinition btnDef = ButtonDefinitions[i]; this.Buttons[i] = new GpioButtonHandler( this, btnDef); } }
/// <summary> /// Add the unloaded callback to the MediaContext queue /// </summary> internal static void AddUnloadedCallback(DependencyObject d, DependencyObject logicalParent) { Debug.Assert(d is FrameworkElement || d is FrameworkContentElement); DispatcherOperationCallback unloadedCallback = new DispatcherOperationCallback(BroadcastEventHelper.BroadcastUnloadedEvent); // Add the pending unloaded event information to the MediaContext's pending // LoadedOrUnloadedCallbacks list so these can be called pre render LoadedOrUnloadedOperation unloadedOp = MediaContext.From(d.Dispatcher).AddLoadedOrUnloadedCallback(unloadedCallback, d); // Post to the dispatcher queue as a backup to fire the broadcast // event in case the tree change never triggers a Layout DispatcherOperation operation = d.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, unloadedCallback, d); // Set the UnloadedPending property d.SetValue(FrameworkElement.UnloadedPendingPropertyKey, new object[]{unloadedOp, operation, logicalParent}); }
internal StylusDevice(TabletDevice tabletDevice, string sName, int id, bool fInverted, StylusButtonCollection stylusButtonCollection) { _tabletDevice = tabletDevice; _sName = sName; _id = id; _fInverted = fInverted; // For tablet devices that can go out of range default them to // being out of range until we see some events from it. _fInRange = false; // All tablets out of range by default. _stylusButtonCollection = stylusButtonCollection; #if MULTICAPTURE _overIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsEnabledChanged); _overIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsVisibleChanged); _overIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnOverIsHitTestVisibleChanged); _reevaluateStylusOverDelegate = new DispatcherOperationCallback(ReevaluateStylusOverAsync); _reevaluateStylusOverOperation = null; _captureIsEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsEnabledChanged); _captureIsVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsVisibleChanged); _captureIsHitTestVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnCaptureIsHitTestVisibleChanged); _reevaluateCaptureDelegate = new DispatcherOperationCallback(ReevaluateCaptureAsync); _reevaluateCaptureOperation = null; #endif if (_stylusButtonCollection != null) { foreach (StylusButton button in _stylusButtonCollection) { button.SetOwner(this); } } // Because the stylus device gets a steady stream of input events when it is in range, // we don't have to be so careful about responding to layout changes as we have to be // with the mouse. // InputManager.Current.HitTestInvalidatedAsync += new EventHandler(OnHitTestInvalidatedAsync); InputManager inputManager = (InputManager)Dispatcher.InputManager; _stylusLogic = inputManager.StylusLogic; _stylusLogic.RegisterStylusDeviceCore(this); }
protected KeyboardDevice(InputManager inputManager) { _inputManager = new SecurityCriticalDataClass<InputManager>(inputManager); _inputManager.Value.PreProcessInput += new PreProcessInputEventHandler(PreProcessInput); _inputManager.Value.PreNotifyInput += new NotifyInputEventHandler(PreNotifyInput); _inputManager.Value.PostProcessInput += new ProcessInputEventHandler(PostProcessInput); _isEnabledChangedEventHandler = new DependencyPropertyChangedEventHandler(OnIsEnabledChanged); _isVisibleChangedEventHandler = new DependencyPropertyChangedEventHandler(OnIsVisibleChanged); _focusableChangedEventHandler = new DependencyPropertyChangedEventHandler(OnFocusableChanged); _reevaluateFocusCallback = new DispatcherOperationCallback(ReevaluateFocusCallback); _reevaluateFocusOperation = null; // _TsfManager = new SecurityCriticalDataClass<TextServicesManager>(new TextServicesManager(inputManager)); _textcompositionManager = new SecurityCriticalData<TextCompositionManager>(new TextCompositionManager(inputManager)); }
public GPIOButtonInputProvider(PresentationSource source) { _source = source; _site = InputManager.CurrentInputManager.RegisterInputProvider(this); _callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return _site.ReportInput(args.Device, args.Report); }); Dispatcher = Dispatcher.CurrentDispatcher; ButtonPad[] buttons = new ButtonPad[] { new ButtonPad(this, Button.VK_MENU, Pins.GPIO_PORT_A_3, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_SELECT, Pins.GPIO_PORT_A_8, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_LEFT, Pins.GPIO_PORT_A_7, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_RIGHT, Pins.GPIO_PORT_A_5, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_UP, Pins.GPIO_PORT_A_4, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_DOWN, Pins.GPIO_PORT_A_6, Port.InterruptMode.InterruptEdgeBoth), }; _buttons = buttons; }
/// <summary> /// <see cref="System.Windows.Documents.DocumentPaginator.GetPageAsync(int,object)"/> /// </summary> internal void GetPageAsync(int pageNumber, object userState) { DocumentsTrace.FixedFormat.IDF.Trace(string.Format("IDP.GetPageAsync({0}, {1})", pageNumber, userState)); // Make sure that the call is in the right context. // Dispatcher.VerifyAccess(); // Page number cannot be negative. if (pageNumber < 0) { throw new ArgumentOutOfRangeException("pageNumber", SR.Get(SRID.IDPNegativePageNumber)); } if (userState == null) { throw new ArgumentNullException("userState"); } // Add to outstanding AsyncOp list GetPageAsyncRequest asyncRequest = new GetPageAsyncRequest(new RequestedPage(pageNumber/*childPaginator, childPageNumber*/), userState); _asyncOps[userState] = asyncRequest; DispatcherOperationCallback queueTask = new DispatcherOperationCallback(_GetPageAsyncDelegate); Dispatcher.BeginInvoke(DispatcherPriority.Background, queueTask, asyncRequest); }
static WPFTester() { _exitFrameCallback = OnExitFrame; }
/// <summary> /// Post a queue item at the specified priority /// </summary> internal void Post (DispatcherPriority priority) { DispatcherOperationCallback callback = new DispatcherOperationCallback (Dispatch); Dispatcher.CurrentDispatcher.BeginInvoke(priority, callback, this); }
/// <summary> /// <see cref="System.Windows.Documents.DocumentPaginator.GetPageAsync(int,object)"/> /// </summary> /// <exception cref="ArgumentOutOfRangeException">pageNumber is less than zero.</exception> /// <exception cref="ArgumentNullException">userState is NULL.</exception> internal void GetPageAsync(int pageNumber, object userState) { DocumentsTrace.FixedFormat.IDF.Trace(string.Format("IDP.GetPageAsync({0}, {1})", pageNumber, userState)); // Make sure that the call is in the right context. // Dispatcher.VerifyAccess(); // Page number cannot be negative. if (pageNumber < 0) { throw new ArgumentOutOfRangeException("pageNumber", SR.Get(SRID.IDPNegativePageNumber)); } if (userState == null) { throw new ArgumentNullException("userState"); } if (pageNumber < Pages.Count) { PageContent pc = Pages[pageNumber]; // Add to outstanding AsyncOp list GetPageAsyncRequest asyncRequest = new GetPageAsyncRequest(pc, pageNumber, userState); _asyncOps[userState] = asyncRequest; DispatcherOperationCallback queueTask = new DispatcherOperationCallback(GetPageAsyncDelegate); Dispatcher.BeginInvoke(DispatcherPriority.Background, queueTask, asyncRequest); } else { _NotifyGetPageAsyncCompleted(DocumentPage.Missing, pageNumber, null, false, userState); } }
/// <summary> /// This code runs in the worker thread when LoadStreamAsync() finishes. /// </summary> /// <param name="asyncResult"></param> private void LoadStreamCallback(IAsyncResult asyncResult) { // Now have the UI thread regain control and initialize the SoundPlayer DispatcherOperationCallback loadStreamCompletedCaller = new DispatcherOperationCallback(OnLoadStreamCompleted); Dispatcher.BeginInvoke(DispatcherPriority.Normal, loadStreamCompletedCaller, asyncResult); }
protected virtual void OnQueryFinished (object newData, Exception error, DispatcherOperationCallback completionWork, object callbackArguments) { throw new NotImplementedException (); }
private void ShowCommandWindow(PSCmdlet cmdlet, object commandViewModelObj, double windowWidth, double windowHeight, bool passThrough) { this.methodThatReturnsDialog = new DispatcherOperationCallback(delegate(object ignored) { Diagnostics.Assert(commandViewModelObj != null, "verified by caller"); this.commandViewModel = (CommandViewModel)commandViewModelObj; ShowCommandWindow showCommandWindow = new ShowCommandWindow(); this.commandViewModel.HelpNeeded += new EventHandler<HelpNeededEventArgs>(this.CommandNeedsHelp); showCommandWindow.DataContext = this.commandViewModel; this.SetupButtonEvents(showCommandWindow.Run, showCommandWindow.Copy, showCommandWindow.Cancel, passThrough); this.SetupWindow(showCommandWindow); CommonHelper.SetStartingPositionAndSize( showCommandWindow, ShowCommandSettings.Default.ShowOneCommandTop, ShowCommandSettings.Default.ShowOneCommandLeft, windowWidth != 0.0 && windowWidth > showCommandWindow.MinWidth ? windowWidth : ShowCommandSettings.Default.ShowOneCommandWidth, windowHeight != 0.0 && windowHeight > showCommandWindow.MinHeight ? windowHeight : ShowCommandSettings.Default.ShowOneCommandHeight, showCommandWindow.Width, showCommandWindow.Height, ShowCommandSettings.Default.ShowOneCommandWindowMaximized); return showCommandWindow; }); this.CallShowDialog(cmdlet); }
private void ShowAllModulesWindow(PSCmdlet cmdlet, Dictionary<string, ShowCommandModuleInfo> importedModules, IEnumerable<ShowCommandCommandInfo> commands, bool noCommonParameter, double windowWidth, double windowHeight, bool passThrough) { this.methodThatReturnsDialog = new DispatcherOperationCallback(delegate(object ignored) { Diagnostics.Assert(commands.GetEnumerator().MoveNext(), "there is always at least one command"); ShowAllModulesWindow allModulesWindow = new ShowAllModulesWindow(); this.allModulesViewModel = new AllModulesViewModel(importedModules, commands, noCommonParameter); this.SetupButtonEvents(allModulesWindow.Run, allModulesWindow.Copy, allModulesWindow.Cancel, passThrough); this.SetupWindow(allModulesWindow); this.SetupViewModel(); CommonHelper.SetStartingPositionAndSize( allModulesWindow, ShowCommandSettings.Default.ShowCommandsTop, ShowCommandSettings.Default.ShowCommandsLeft, windowWidth != 0.0 && windowWidth > allModulesWindow.MinWidth ? windowWidth : ShowCommandSettings.Default.ShowCommandsWidth, windowHeight != 0.0 && windowHeight > allModulesWindow.MinHeight ? windowHeight : ShowCommandSettings.Default.ShowCommandsHeight, allModulesWindow.Width, allModulesWindow.Height, ShowCommandSettings.Default.ShowCommandsWindowMaximized); return allModulesWindow; }); this.CallShowDialog(cmdlet); }
object StartFontCacheServiceAsync(object unused) { if (CheckAccess()) // initial call by Dispatcher? { // Do a callback to a thread-pool thread DispatcherOperationCallback cb = new DispatcherOperationCallback(StartFontCacheServiceAsync); cb.BeginInvoke(null, null, null); } else // on a thread-pool thread { // Note that an exception allowed to escape from here will be caught by the thread-pool manager. // But that's okay in this scenario. EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_StartingFontCacheServiceStart); // Getting the instance will instantiate the DWriteFactory, which will cause DWrite to start the // font cache. Text.TextInterface.Factory factory = MS.Internal.FontCache.DWriteFactory.Instance; EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordHosting | EventTrace.Keyword.KeywordPerf, EventTrace.Event.WpfHost_StartingFontCacheServiceEnd); } return null; }
// // Invoke a delegate in a try/catch. // internal object WrappedInvoke(DispatcherOperationCallback callback, object arg) { object result = null; try { result = callback(arg); } catch (Exception e) { #if TINYCLR_DEBUG_DISPATCHER // allow the debugger to break on the original exception. if (System.Diagnostics.Debugger.IsAttached) { } else #endif if (_finalExceptionHandler == null || !_finalExceptionHandler(this, e)) { throw; } } return result; }
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); }