protected virtual void InitializeCursorModelsAndCursorViews() { for (int i = 0; i < Device.TrackableHandsCountMaximum; i++) { CursorViews.Add(new CursorForm()); } CameraViewUserControlModel.InitializeOnceAtStartup(Device); OnePersonBothHandsViewModel.InitializeOnceAtStartup(Device); CursorViews[0].InitializeOnceAtStartup(OnePersonBothHandsViewModel.RightHand, ImageInformationSet.CreateDefaultRightCursorImageInformationSetList()); CursorViews[1].InitializeOnceAtStartup(OnePersonBothHandsViewModel.LeftHand, ImageInformationSet.CreateDefaultLeftCursorImageInformationSetList()); }
public EgsHostOnUserControl() { Device = EgsDevice.GetDefaultEgsDevice(); CultureInfoAndDescription = new CultureInfoAndDescriptionOptions(); MouseCursorPositionUpdatedByGestureCursorMethod = new MouseCursorPositionUpdatedByGestureCursorMethodOptions(); CursorDrawingTimingMethod = new CursorDrawingTimingMethodOptions(); CameraViewBordersAndPointersAreDrawnBy = new CameraViewBordersAndPointersAreDrawnByOptions(); CameraViewUserControlModel = new CameraViewUserControlModel(); OnePersonBothHandsViewModel = new OnePersonBothHandsViewModel(); CursorViews = new List <CursorForm>(); DrawingCursorsMinimumIntervalInMilliseconds = 8; drawingCursorsStopwatch = Stopwatch.StartNew(); PrecisionLogger = new TimerPrecisionLogger(); //CultureInfoAndDescription.SelectSingleItemByPredicate(e => e.CultureInfoString == ApplicationCommonSettings.DefaultCultureInfoName); MouseCursorPositionUpdatedByGestureCursorMethod.Value = MouseCursorPositionUpdatedByGestureCursorMethods.None; CursorDrawingTimingMethod.Value = CursorDrawingTimingMethods.ByHidReportUpdatedEvent; CameraViewBordersAndPointersAreDrawnBy.Value = CameraViewBordersAndPointersAreDrawnByKind.HostApplication; WaitTimeTillMouseCursorHideOnMouseMode = TimeSpan.FromSeconds(10); ResetSettingsCommand = new SimpleDelegateCommand(); SaveSettingsToFlashCommand = new SimpleDelegateCommand(); ResetDeviceCommand = new SimpleDelegateCommand(); SendManySettingsPacketsCommand = new SimpleDelegateCommand(); ResetSettingsCommand.CanPerform = true; SaveSettingsToFlashCommand.CanPerform = false; ResetDeviceCommand.CanPerform = false; SendManySettingsPacketsCommand.CanPerform = false; ResetSettingsCommand.PerformEventHandler += delegate { if (MessageBox.Show(Resources.CommonStrings_ResetSettingsConfirmation, Resources.CommonStrings_Confirmation, MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } Reset(); }; SaveSettingsToFlashCommand.PerformEventHandler += delegate { if (MessageBox.Show(Resources.CommonStrings_SaveSettingsToFlashConfirmation, Resources.CommonStrings_Confirmation, MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } Device.SaveSettingsToFlash(); }; ResetDeviceCommand.PerformEventHandler += delegate { if (MessageBox.Show(Resources.CommonStrings_ResetDeviceConfirmation, Resources.CommonStrings_Confirmation, MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } Device.ResetDevice(); }; SendManySettingsPacketsCommand.PerformEventHandler += delegate { SendManySettingsPacketsAsync(); }; Device.IsHidDeviceConnectedChanged += Device_IsHidDeviceConnectedChanged; // NOTE: The next 2 lines are necessary. SaveSettingsToFlashCommand.CanPerform = Device.IsHidDeviceConnected; ResetDeviceCommand.CanPerform = Device.IsHidDeviceConnected; SendManySettingsPacketsCommand.CanPerform = Device.IsHidDeviceConnected; CursorDrawingTimingMethod.ValueUpdated += delegate { OnCursorDrawingTimingMethod_SelectedItemChanged(); }; CameraViewBordersAndPointersAreDrawnBy.ValueUpdated += CameraViewBordersAndPointersAreDrawnBy_SelectedItemChanged; CultureInfoAndDescription.ValueUpdated += delegate { BindableResources.Current.ChangeCulture(CultureInfoAndDescription.Value); }; // TODO: MUSTDO: When users cancel DFU, exceptions occur in Timer thread basically, // and the app cannot deal with them. // So it is necessary to attach them to event handlers. // The design of EgsDevicesManager is not completed. So I don't think this is good way. EgsDevice.DefaultEgsDevicesManager.Disposing += delegate { if (false && ApplicationCommonSettings.IsDebuggingInternal) { Debugger.Break(); } this.Dispose(); }; }