internal virtual void OnHidAccessPropertyUpdated(HidAccessPropertyUpdatedEventArgs e) { var t = HidAccessPropertyUpdated; if (t != null) { t(this, e); } }
void EgsDeviceSettings_HidAccessPropertyUpdated(object sender, HidAccessPropertyUpdatedEventArgs e) { if (e.UpdatedProperty == Settings.IsToDetectFacesOnDevice) { Update_IsDetectingFaces_IsDetectingHands_IsTracking(); } else if (e.UpdatedProperty == Settings.IsToDetectHandsOnDevice) { Update_IsDetectingFaces_IsDetectingHands_IsTracking(); } else if (e.UpdatedProperty == Settings.IsToSendTouchScreenHidReport) { IsSendingTouchScreenHidReport = Settings.IsToSendTouchScreenHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.IsToSendHoveringStateOnTouchScreenHidReport) { IsSendingHoveringStateOnTouchScreenHidReport = Settings.IsToSendHoveringStateOnTouchScreenHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.IsToSendEgsGestureHidReport) { IsSendingEgsGestureHidReport = Settings.IsToSendEgsGestureHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.CameraViewImageSourceBitmapSize) { bool isToDetectFacesPrevious = Settings.IsToDetectFaces.Value; if (Settings.IsToDetectFaces.Value != false) { Settings.IsToDetectFaces.Value = false; } ResetHidReportObjects(); // NOTE: Maybe necessary! System.Threading.Thread.Sleep(1000); if (Settings.IsToDetectFaces.Value != isToDetectFacesPrevious) { Settings.IsToDetectFaces.Value = isToDetectFacesPrevious; } } else if (e.UpdatedProperty == Settings.CaptureFps) { switch (Settings.CaptureFps.Value) { case CaptureFpsKind.Auto: case CaptureFpsKind.Fps100: EgsGestureHidReport.FramesPerSecond = 100.0; break; case CaptureFpsKind.Fps120: EgsGestureHidReport.FramesPerSecond = 120.0; break; default: if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } throw new NotImplementedException(); } } try { if (IsHidDeviceConnected && e.UpdatedProperty.IsReadOnly == false) { SetHidAccessPropertyBySetHidFeatureReport(e.UpdatedProperty); } } catch (Exception ex) { Debug.WriteLine(ex.Message); if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } } }
void EgsDeviceSettings_HidAccessPropertyUpdated(object sender, HidAccessPropertyUpdatedEventArgs e) { if (e.UpdatedProperty == Settings.IsToDetectFacesOnDevice) { Update_IsDetectingFaces_IsDetectingHands_IsTracking(); } else if (e.UpdatedProperty == Settings.IsToDetectHandsOnDevice) { Update_IsDetectingFaces_IsDetectingHands_IsTracking(); } else if (e.UpdatedProperty == Settings.IsToSendTouchScreenHidReport) { IsSendingTouchScreenHidReport = Settings.IsToSendTouchScreenHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.IsToSendHoveringStateOnTouchScreenHidReport) { IsSendingHoveringStateOnTouchScreenHidReport = Settings.IsToSendHoveringStateOnTouchScreenHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.IsToSendEgsGestureHidReport) { IsSendingEgsGestureHidReport = Settings.IsToSendEgsGestureHidReport.Value && IsHidDeviceConnected; } else if (e.UpdatedProperty == Settings.CameraViewImageSourceBitmapSize) { StopFaceDetectionAndRestartUvcAndRestartFaceDetection(); } else if (e.UpdatedProperty == Settings.CaptureFps) { switch (Settings.CaptureFps.Value) { case CaptureFpsKind.Auto: case CaptureFpsKind.Fps100: EgsGestureHidReport.FramesPerSecond = 100.0; break; case CaptureFpsKind.Fps120: EgsGestureHidReport.FramesPerSecond = 120.0; break; default: if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } throw new NotImplementedException(); } } bool hr = false; try { if (IsHidDeviceConnected && e.UpdatedProperty.IsReadOnly == false) { hr = SetHidAccessPropertyBySetHidFeatureReport(e.UpdatedProperty); } } catch (Exception ex) { Debug.WriteLine(ex.Message); if (ApplicationCommonSettings.IsDebugging) { Debugger.Break(); } } #if ApplicationCommonSettings_CanChangeDeviceUsage // TODO: MUSTDO: test and debug if (e.UpdatedProperty == Settings.DeviceUsage) { // TODO: MUSTDO: think again about specification if (Settings.DeviceUsage.Value == DeviceUsages.RemoteTouch) { Settings.IsToDetectFaces.Value = true; } else if (Settings.DeviceUsage.Value == DeviceUsages.MotionControl) { Settings.IsToDetectFaces.Value = false; } ResetHidReportObjects(); } #endif }
internal void AttachInternalEventHandlers() { foreach (var item in HidAccessPropertyList) { item.ValueUpdated += delegate { if (CurrentConnectedEgsDevice == null) { return; } HidAccessPropertyUpdatedEventArgs e = new HidAccessPropertyUpdatedEventArgs(item); OnHidAccessPropertyUpdated(e); }; } CaptureExposureMode.ValueUpdated += delegate { OnPropertyChanged(nameof(IsCaptureExposureModeManual)); }; FaceDetectionMethod.ValueUpdated += delegate { OnPropertyChanged(nameof(IsFaceDetectionMethodDefaultProcessOnEgsDevice)); OnPropertyChanged(nameof(IsFaceDetectionMethodDefaultProcessOnEgsHostApplication)); }; TouchInterfaceKind.ValueUpdated += (sender, e) => { switch (TouchInterfaceKind.Value) { case PropertyTypes.TouchInterfaceKinds.MultiTouch: TrackableHandsCount.Value = 2; break; case PropertyTypes.TouchInterfaceKinds.SingleTouch: TrackableHandsCount.Value = 1; break; case PropertyTypes.TouchInterfaceKinds.Mouse: TrackableHandsCount.Value = 1; break; default: Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "TouchInterfaceKind: {0}", TouchInterfaceKind.Value)); break; } if (CurrentConnectedEgsDevice != null) { CurrentConnectedEgsDevice.ResetHidReportObjects(); } }; CursorSpeedAndPrecisionMode.ValueUpdated += (sender, e) => { // TODO: test switch (CursorSpeedAndPrecisionMode.Value) { case CursorSpeedAndPrecisionModes.Beginner: case CursorSpeedAndPrecisionModes.Standard: FastMovingHandsGestureMode.Value = FastMovingHandsGestureModes.None; break; case CursorSpeedAndPrecisionModes.FruitNinja: FastMovingHandsGestureMode.Value = FastMovingHandsGestureModes.Touch; break; default: Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "CursorSpeedAndPrecisionMode: {0}", CursorSpeedAndPrecisionMode.Value)); break; } if (CurrentConnectedEgsDevice != null) { CurrentConnectedEgsDevice.ResetHidReportObjects(); } }; CaptureImageSize.ValueUpdated += delegate { OnImageSizeRelatedPropertiesUpdated(); }; CameraViewImageSourceBitmapSize.ValueUpdated += delegate { OnImageSizeRelatedPropertiesUpdated(); }; // NOTE: this property depends on CaptureImageSize and CameraViewImageSourceBitmapSize. So ValueUpdate event handler is unnecessary. if (false) { CameraViewImageSourceRectInCaptureImage.ValueUpdated += delegate { OnImageSizeRelatedPropertiesUpdated(); }; } OnImageSizeRelatedPropertiesUpdated(); }