public AppRunningView([NotNull] AppRunningViewModel appRunningViewModel, [NotNull] WurmAssistantLiteSettings wurmAssistantLiteSettings) : this() { if (appRunningViewModel == null) throw new ArgumentNullException("appRunningViewModel"); if (wurmAssistantLiteSettings == null) throw new ArgumentNullException("wurmAssistantLiteSettings"); this.appRunningViewModel = appRunningViewModel; this.wurmAssistantLiteSettings = wurmAssistantLiteSettings; //todo: dedicated view var moduleManager = appRunningViewModel.ModuleManagerViewModel; foreach (var c in moduleManager.ModuleControlViewModels) { var control = c; Button btn = new Button(); btn.Size = new Size(80, 80); btn.Click += (sender, args) => control.Open(); btn.Text = c.Name; moduleButtonBar.Controls.Add(btn); } }
public Configurator([NotNull] WurmAssistantLiteSettings wurmAssistantLiteSettings) { if (wurmAssistantLiteSettings == null) throw new ArgumentNullException("wurmAssistantLiteSettings"); this.wurmAssistantLiteSettings = wurmAssistantLiteSettings; }
public void Bootstrap() { var marshaller = new WinFormsMainThreadEventMarshaller(mainForm); try { dataDirectory = new SharedDataDirectory(); } catch (LockFailedException) { // must have exclusive lock on data directory, else most likely another app instance is using it //mainForm.Close(); Application.Exit(); return; } persistentLibrary = new PersistentCollectionsLibrary(new FlatFilesPersistenceStrategy( Path.Combine(dataDirectory.FullName, "WurmAssistantLiteSettings"))); var globalSettings = new WurmAssistantLiteSettings( persistentLibrary.DefaultCollection.GetObject<GlobalSettingsEntity>("GlobalSettings")) { DataDirectoryFullPath = dataDirectory.FullName }; var configurator = new Configurator(globalSettings); var valid = configurator.ExecConfig(); if (!valid) { // stopping construction and exiting //mainForm.Close(); Application.Exit(); return; } var wurmAssistantConfig = configurator.BuildWurmAssistantConfig(); // bind app specific dependencies kernel.Bind<WurmAssistantLiteSettings>().ToConstant(globalSettings); kernel.Bind<IWurmAssistantConfig, WurmAssistantConfig>().ToConstant(wurmAssistantConfig); kernel.Bind<IEventMarshaller, WinFormsMainThreadEventMarshaller>().ToConstant(marshaller); kernel.Bind<IEnvironment, Environment>().ToConstant(environment); kernel.Bind<ILogSearcherModuleGui>().To<LogSearcherForm>(); // bootstrap core coreBootstrapper = new CoreBootstrapper(kernel); var appStartViewModel = coreBootstrapper.GetAppStartViewModel(); var appStartView = new AppStartView(appStartViewModel); mainForm.SetAppCoreView(appStartView); var logOutputViewModel = appStartViewModel.LogOutputViewModel; var logOutputTempView = new LogOutputView(logOutputViewModel); mainForm.SetLogOutputView(logOutputTempView); coreBootstrapper.BootstrapRuntime(); globalLogger = kernel.Get<LoggerFactory>().Create("WA-Lite"); globalLogger.Info("Core bootstrapping completed"); globalLogger.Info("Resolving application runtime"); var appRunningViewModel = coreBootstrapper.GetAppRunningViewModel(); var appRunningView = new AppRunningView(appRunningViewModel, globalSettings); mainForm.SetAppCoreView(appRunningView); globalLogger.Info("Application runtime resolved"); Bootstrapped = true; // save last, so if configuration causes bootstrap crash, it does not get saved SaveSettings(); globalLogger.Info("Settings saved"); }