protected virtual void CloseCursorViews() { PrecisionLogger.ExportLog(); foreach (var cursorView in CursorViews) { if (cursorView != null) { cursorView.Close(); } } }
protected virtual void OnDeviceEgsGestureHidReportReportUpdated() { if (PrecisionLogger.IsToUseTimerPrecisionMonitor) { PrecisionLogger.CallBeforeUpdating(OnePersonBothHandsViewModel.RightHand.IsTouching ? "1" : "0"); } // NOTE: In multi-touch mode, when a hand "touches" once, the mouse cursor disappear, and the position of the mouse cursor becomes not to change! // Some applications can use MouseMove event, so mouse cursor position is important. // So the application can let the mouse cursor track (first found / right / left) gesture cursor. // MUSTDO: In some PCs, the position is not updated to the correct value. Should be fixed. if (MouseCursorPositionUpdatedByGestureCursorMethod.Value != MouseCursorPositionUpdatedByGestureCursorMethods.None && Device.Settings.TouchInterfaceKind.Value != TouchInterfaceKinds.Mouse && OnePersonBothHandsViewModel != null) { CursorViewModel hand = null; switch (MouseCursorPositionUpdatedByGestureCursorMethod.Value) { case MouseCursorPositionUpdatedByGestureCursorMethods.FirstFoundHand: hand = OnePersonBothHandsViewModel.FirstFoundHand; break; case MouseCursorPositionUpdatedByGestureCursorMethods.RightHand: hand = OnePersonBothHandsViewModel.RightHand; break; case MouseCursorPositionUpdatedByGestureCursorMethods.LeftHand: hand = OnePersonBothHandsViewModel.LeftHand; break; default: if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } throw new NotImplementedException(); } // NOTE: In face recognition mode, OnePersonBothHandsViewModel.FirstFoundHand is null. if (hand != null && hand.IsTracking) { // NOte: In this code, position adjustment by DPI is NOT necessary. System.Windows.Forms.Cursor.Position = new System.Drawing.Point((int)hand.PositionX, (int)hand.PositionY); } } // NOTE: In mouse mode, it must use not TrackableHandsCount but TrackableHandsCountMaximum to draw it in the correct position. for (int i = 0; i < Device.TrackableHandsCountMaximum; i++) { OnePersonBothHandsViewModel.Hands[i].UpdateByEgsGestureHidReportHand(Device.EgsGestureHidReport.Hands[i]); } if (drawingCursorsStopwatch.ElapsedMilliseconds > DrawingCursorsMinimumIntervalInMilliseconds) { // NOTE: It also must use Maximum. for (int i = 0; i < Device.TrackableHandsCountMaximum; i++) { CursorViews[i].UpdatePosition(); } drawingCursorsStopwatch.Reset(); drawingCursorsStopwatch.Start(); } if (false && ApplicationCommonSettings.IsToEmulateReportByActualMouseRawInputToDebugViews) { var m = Device.EgsGestureHidReport.Hands[0]; Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Model: {0} {1} {2} {3}", m.IsTracking, m.X, m.Y, m.IsTouching)); var vm = OnePersonBothHandsViewModel.Hands[0]; Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "ViewModel: {0} {1} {2} {3}", vm.IsTracking, vm.PositionX, vm.PositionY, vm.IsTouching)); } // NOTE: Before, the application hides cursor after a while to display desktop without large gesture cursor. // But now, in mouse mode, a device sends information about tracking by EgsGestureHidReport, so the application just needs to draw the report. // NOTE: Even if the device is disconnected, the report object is also reset, so the cursor disappears correctly. if (PrecisionLogger.IsToUseTimerPrecisionMonitor) { PrecisionLogger.CallAfterUpdated(); } }