コード例 #1
0
 WpfCommands GetCommands(Guid guid)
 {
     WpfCommands c;
     if (!toWpfCommands.TryGetValue(guid, out c))
         toWpfCommands.Add(guid, c = new WpfCommands(guid));
     return c;
 }
コード例 #2
0
        private void InitApplication()
        {
            // prevent some application crash
            WpfCommands.DisableWpfTabletSupport();

            ServiceProvider.Configure();

            ServiceProvider.Settings = new Settings();
            ServiceProvider.Settings = ServiceProvider.Settings.Load();
            ServiceProvider.Branding = ServiceProvider.Settings.LoadBranding();
            if (!string.IsNullOrEmpty(ServiceProvider.Branding.StartupScreenImage) && File.Exists(ServiceProvider.Branding.StartupScreenImage))
            {
                BitmapImage bi = new BitmapImage();
                // BitmapImage.UriSource must be in a BeginInit/EndInit block.
                bi.BeginInit();
                bi.UriSource = new Uri(ServiceProvider.Branding.StartupScreenImage);
                bi.EndInit();
                background.Source = bi;
            }
            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.WindowsManager = new WindowsManager();
            ServiceProvider.WindowsManager.Add(new FullScreenWnd());
            ServiceProvider.WindowsManager.Add(new LiveViewManager());
            ServiceProvider.WindowsManager.Add(new MultipleCameraWnd());
            ServiceProvider.WindowsManager.Add(new CameraPropertyWnd());
            ServiceProvider.WindowsManager.Add(new BrowseWnd());
            ServiceProvider.WindowsManager.Add(new TagSelectorWnd());
            ServiceProvider.WindowsManager.Add(new DownloadPhotosWnd());
            ServiceProvider.WindowsManager.Add(new BulbWnd());
            ServiceProvider.WindowsManager.Add(new AstroLiveViewWnd());
            ServiceProvider.WindowsManager.Add(new ScriptWnd());
            ServiceProvider.WindowsManager.Event += WindowsManager_Event;
            ServiceProvider.WindowsManager.ApplyTheme();
            ServiceProvider.WindowsManager.RegisterKnowCommands();
            ServiceProvider.Settings.SyncActions(ServiceProvider.WindowsManager.WindowCommands);

            ServiceProvider.Trigger.Start();
            ServiceProvider.PluginManager.CopyPlugins();
            ServiceProvider.PluginManager.LoadPlugins(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Plugins"));
            _basemainwindow = new MainWindow();
            ServiceProvider.PluginManager.MainWindowPlugins.Add(_basemainwindow);
            ServiceProvider.PluginManager.ToolPlugins.Add(new ScriptWnd());
            // 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();
            }
            try
            {
                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);
                }
            }
            Thread.Sleep(500);
            Dispatcher.Invoke(new Action(Hide));
            StartApplication();
        }