private void InitApplication() { // prevent some application crash //WpfCommands.DisableWpfTabletSupport(); Dispatcher.Invoke(new Action(ServiceProvider.Configure)); ServiceProvider.Settings = new Settings(); ServiceProvider.Settings = ServiceProvider.Settings.Load(); ServiceProvider.Branding = Branding.LoadBranding(); ServiceProvider.ActionManager.Actions = new AsyncObservableCollection <IMenuAction> { //new CmdFocusStackingCombineZP(), //new CmdEnfuse(), // new CmdToJpg(), //new CmdExpJpg() }; if (ServiceProvider.Settings.DisableNativeDrivers && MessageBox.Show(TranslationStrings.MsgDisabledDrivers, "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ServiceProvider.Settings.DisableNativeDrivers = false; } ServiceProvider.Settings.LoadSessionData(); TranslationManager.LoadLanguage(ServiceProvider.Settings.SelectedLanguage); ServiceProvider.PluginManager.CopyPlugins(); Dispatcher.Invoke(new Action(InitWindowManager)); ServiceProvider.Trigger.Start(); ServiceProvider.Analytics.Start(); Dispatcher.Invoke(new Action(delegate { try { // event handlers ServiceProvider.Settings.SessionSelected += Settings_SessionSelected; ServiceProvider.DeviceManager.CameraConnected += DeviceManager_CameraConnected; ServiceProvider.DeviceManager.CameraSelected += DeviceManager_CameraSelected; ServiceProvider.DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected; //------------------- ServiceProvider.DeviceManager.DisableNativeDrivers = ServiceProvider.Settings.DisableNativeDrivers; if (ServiceProvider.Settings.AddFakeCamera) { ServiceProvider.DeviceManager.AddFakeCamera(); } ServiceProvider.DeviceManager.ConnectToCamera(); } catch (Exception exception) { Log.Error("Unable to initialize device manager", exception); if (exception.Message.Contains("0AF10CEC-2ECD-4B92-9581-34F6AE0637F3")) { MessageBox.Show( "Unable to initialize device manager !\nMissing some components! Please install latest Windows Media Player! "); Application.Current.Shutdown(1); } } StartApplication(); if (_startUpWindow != null) { _startUpWindow.Close(); } })); }
private void InitApplication() { try { // prevent some application crash //WpfCommands.DisableWpfTabletSupport(); Dispatcher.Invoke(new Action(ServiceProvider.Configure)); ServiceProvider.Settings = new Settings(); ServiceProvider.Settings = ServiceProvider.Settings.Load(); ServiceProvider.Branding = Branding.LoadBranding(); if (ServiceProvider.Settings.DisableNativeDrivers && MessageBox.Show(TranslationStrings.MsgDisabledDrivers, "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { ServiceProvider.Settings.DisableNativeDrivers = false; } ServiceProvider.Settings.LoadSessionData(); TranslationManager.LoadLanguage(ServiceProvider.Settings.SelectedLanguage); ServiceProvider.PluginManager.CopyPlugins(); Dispatcher.Invoke(new Action(InitWindowManager)); ServiceProvider.Trigger.Start(); ServiceProvider.Analytics.Start(); BitmapLoader.Instance.MetaDataUpdated += Instance_MetaDataUpdated; Dispatcher.Invoke(new Action(delegate { try { // event handlers ServiceProvider.Settings.SessionSelected += Settings_SessionSelected; ServiceProvider.DeviceManager.CameraConnected += DeviceManager_CameraConnected; ServiceProvider.DeviceManager.CameraSelected += DeviceManager_CameraSelected; ServiceProvider.DeviceManager.CameraDisconnected += DeviceManager_CameraDisconnected; //------------------- ServiceProvider.DeviceManager.DisableNativeDrivers = ServiceProvider.Settings.DisableNativeDrivers; if (ServiceProvider.Settings.AddFakeCamera) { ServiceProvider.DeviceManager.AddFakeCamera(); } ServiceProvider.DeviceManager.LoadWiaDevices = ServiceProvider.Settings.WiaDeviceSupport; ServiceProvider.DeviceManager.DetectWebcams = ServiceProvider.Settings.WebcamSupport; ServiceProvider.DeviceManager.ConnectToCamera(); if (ServiceProvider.Settings.DisableHardwareAccelerationNew) { OpenCL.IsEnabled = false; } } catch (Exception exception) { Log.Error("Unable to initialize device manager", exception); if (exception.Message.Contains("0AF10CEC-2ECD-4B92-9581-34F6AE0637F3")) { MessageBox.Show( "Unable to initialize device manager !\nMissing some components! Please install latest Windows Media Player! "); Application.Current.Shutdown(1); } } })); ServiceProvider.Database.StartEvent(EventType.App); } catch (Exception ex) { Log.Error("Fatal error ", ex); } Dispatcher.Invoke(new Action(delegate { StartApplication(); if (_startUpWindow != null) { _startUpWindow.Close(); } })); }