public static void ClearAllSurfaceDragCursor(this SurfaceWindow _window) { foreach (SurfaceDragCursor cursor in SurfaceDragDrop.GetAllCursors(_window)) { SurfaceDragDrop.CancelDragDrop(cursor); } }
// Find the root SurfaceWindow by recrusively search upwards // in the visual tree private static SurfaceWindow GetSurfaceWindow(DependencyObject target) { if (_surfaceWindow != null) return _surfaceWindow; else if (target == null) return null; else if (target is SurfaceWindow) { _surfaceWindow = target as SurfaceWindow; return _surfaceWindow; } else return GetSurfaceWindow(VisualTreeHelper.GetParent(target)); }
public EditorWndCtx(Canvas canv, DistributedInkCanvas inkCanv, Palette palette, InkPalette inkPalette, SurfaceWindow keyboardWnd, int topicId, int discussionId) { _canv = canv; _inkCanv = inkCanv; _palette = palette; _inkPalette = inkPalette; _keyboardWnd = keyboardWnd; mgr = new SceneManager(canv, inkCanv, palette, inkPalette, topicId, discussionId); touchTimer = new ContactTimer(DevDownAsMouse, 0.05, false); SetListeners(true); }
public SurfaceTwoTouchInputProvider(SurfaceWindow window) { _window = window; }
/// <summary> /// Stops the listening for raw input. /// </summary> /// <param name="window">The window.</param> private static void StopListeningForRawInput(SurfaceWindow window) { // Start listening to the FrameReceived event DisableRawImage(contactTarget); }
/// <summary> /// Stops the listening for contact down. /// </summary> /// <param name="window">The window.</param> private static void StopListeningForContactDown(SurfaceWindow window) { bool useExplicitCapture = GetUseExplicitCapture(window); if (!useExplicitCapture) { // Start listening for the ContactDown attached event window.RemoveHandler(Contacts.ContactDownEvent, new ContactEventHandler(OnContactDown)); } }
/// <summary> /// Starts the listening for raw input. /// </summary> /// <param name="window">The window.</param> private static void StartListeningForRawInput(SurfaceWindow window) { // Get the hWnd for the SurfaceWindow object after it has been loaded. IntPtr hwnd = new WindowInteropHelper(window).Handle; contactTarget = new ContactTarget(hwnd); // Set up the ContactTarget object for the entire SurfaceWindow object. contactTarget.EnableInput(); // Start listening to the FrameReceived event EnableRawImage(contactTarget); }
/// <summary> /// Begins the raw image capture operations asynchronously on the target SurfaceWindow. /// </summary> /// <param name="sourceWindow">The source window.</param> /// <param name="cropTo">The crop to.</param> /// <param name="callback">The callback.</param> public static void CaptureRawImageAsync(SurfaceWindow sourceWindow, Rect cropTo, Action<RawImageCapturedResult> callback) { string saveTo = GetSaveTo(sourceWindow); lastContactAt = DateTime.Now; // Wait briefly and then capture a raw IR image BackgroundWorker imageWorker = new BackgroundWorker(); imageWorker.DoWork += (newSender, newArgs) => { // Remark: This sleep timeout should be configurable... Thread.Sleep(4000); Rectangle cropToLegacy = new Rectangle((int)cropTo.X, (int)cropTo.Y, (int)cropTo.Width, (int)cropTo.Height); RawImageCapturedResult args = NotifyRawImageCaptured(sourceWindow, saveTo, cropToLegacy); Action executeCallback = new Action(() => callback(args)); if (!dispatcher.CheckAccess() && callback != null) { dispatcher.Invoke(executeCallback); } else if(callback != null) { executeCallback(); } }; imageWorker.RunWorkerAsync(); }