示例#1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                base.OnStartup(e);

                // Initialize SettingsManager.
                SettingsManager.Settings = MiniUML.Properties.Settings.Default;

                // Load theme.
                ThemeLoader.LoadThemeAssembly(MiniUML.Properties.Settings.Default.ThemeAssembly);
                DocumentViewModel.LoadThemeAssemblyDelegate = new LoadThemeAssemblyDelegate(ThemeLoader.LoadThemeAssembly);

                // Initialize models.
                vm_WindowViewModel = new MainWindowViewModel();

                // Load plugins.
                PluginLoader.LoadPlugins(MiniUML.Properties.Settings.Default.PluginDirectory, vm_WindowViewModel);

                // Create and show main window.
                IFactory mainWindowFactory = Application.Current.Resources["MainWindowFactory"] as IFactory;
                Window   mainWindow        = mainWindowFactory.CreateObject() as Window;
                mainWindow.DataContext = vm_WindowViewModel;
                mainWindow.Show();

                // If exceptions occured while loading, show them now.
                ExceptionManager.ShowErrorDialog(true);
            }
            catch (NotImplementedException ex)
            {
                // Catch and show unhandled exceptions before killing the process.
                ExceptionManager.RegisterCritical(ex,
                                                  "An error occured while starting the program.");
            }
        }