/// <summary> /// Loads main Form (loads INI settings from registry, plays startup sound, hides and disposes splashscreen, /// checks registration, loads files in the command line, shows news window) /// </summary> /// <param name="sender">Sender of object</param> /// <param name="e">Contains event data</param> /// <returns>No return value</returns> /// <exception cref="ex"></exceptions> /// <remarks>Documented by Dev00, 2007-07-26</remarks> private void MainForm_Load(object sender, System.EventArgs e) { //[ML-551] Main window not in foreground //It is important to focus MainForm once - otherwise, the SplashScreen has focus (because it was here first). //SplashScreen closed => Windows focused the last used program Activate(); //refresh show in taskbar state to ensure that the window gets shown if (ShowInTaskbar) { SuspendLayout(); ShowInTaskbar = false; ShowInTaskbar = true; ResumeLayout(); } PlayStartupEndSound(false, false); //moved to the top to avoid DirectX audio freeze LearnLogic.CountDownTimerMinimum = Properties.Settings.Default.TIMER_MinSeconds; LearnLogic.SlideShow = Properties.Settings.Default.Slideshow; LearnLogic.IgnoreOldLearningModuleVersion = Properties.Settings.Default.IgnoreOldDics; LearnLogic.SynonymInfoMessage = Properties.Settings.Default.SynonymPromt; //load stylehandler styleHandler = new MLifter.Components.StyleHandler( Path.Combine(Application.StartupPath, Properties.Settings.Default.AppDataFolderDesigns), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Path.Combine(Properties.Settings.Default.AppDataFolder, Properties.Settings.Default.AppDataFolderDesigns)), Properties.Resources.ResourceManager, OnStickMode); //load extensions stuff Extensions.Restore(Setup.InstalledExtensionsFilePath); Extensions.SkinPath = styleHandler.StylesPath; Extensions.ExecuteExtension += new Extensions.ExtensionEventHandler(Extensions_ExecuteExtension); Extensions.InformUser += new Extensions.ExtensionEventHandler(Extensions_InformUser); LoadStyle(); RefreshStyleMenu(); RefreshLanguageMenu(); NoDictionaryLoaded(); LoadWindowSettings(); BringToFront(); TopMost = true; TopMost = false; bool firstUse = false; if (Settings.Default.FirstUse) { Wizard startupWizard = new Wizard(MLifter.Classes.Help.HelpPath); startupWizard.StartPosition = FormStartPosition.CenterParent; startupWizard.Text = Resources.FIRSTSTART_CAPTION; startupWizard.Pages.Add(new Controls.Wizards.Startup.DictionaryPathPage(Setup.DictionaryParentPath, Properties.Resources.DICPATH_DEFAULTNAME, Properties.Resources.DICPATH_DEFAULTNAME_OLD)); startupWizard.ShowDialog(); Controls.Wizards.Startup.DictionaryPathPage dictionaryPathPage = startupWizard.Pages[0] as Controls.Wizards.Startup.DictionaryPathPage; Setup.InitializeProfile(dictionaryPathPage.CopyDemoDictionary, dictionaryPathPage.DictionaryPath); Properties.Settings.Default.DicDir = dictionaryPathPage.DictionaryPath; ConnectionStringHandler.CreateUncConnection(Resources.DEFAULT_CONNECTION_NAME, Settings.Default.DicDir, Setup.UserConfigPath, Resources.DEFAULT_CONNECTION_FILE, true, OnStickMode); Settings.Default.FirstUse = false; Settings.Default.Save(); firstUse = true; } Setup.CheckDicDir(); toolStripMenuItemCheckForBetaUpdates.Checked = Settings.Default.CheckForBetaUpdates; while (!Program.UpdateChecked) Thread.Sleep(10); Program.SuspendIPC = false; //re-enable remote services / signal ready //check for unsent error reports Classes.ErrorReportGenerator.ProcessPendingReports(); if (MainformLoadedEvent != null) { LearningModulesIndex index = new LearningModulesIndex(Setup.GlobalConfigPath, Setup.UserConfigPath, LoginForm.OpenLoginForm, delegate { return; }, Setup.SyncedModulesPath); OnMainformLoaded(); } else if (Settings.Default.ShowStartPage && CommandLineParam == string.Empty) { ShowLearningModulesPage(firstUse); } else { LearningModulesIndex index = new LearningModulesIndex(Setup.GlobalConfigPath, Setup.UserConfigPath, LoginForm.OpenLoginForm, delegate { return; }, Setup.SyncedModulesPath); //check for news MLifter.Controls.News news = new MLifter.Controls.News(); news.Prepare(true); //open most recent LM CheckAndLoadStartUpDic(); } }
internal void LoadLearningModules() { SyncedModulesIndex.Restore(Path.Combine(SyncedLearningModulePath, Settings.Default.SyncedModulesFile)); lmIndex = new LearningModulesIndex(GeneralConfigurationPath, UserConfigurationPath, (GetLoginInformation)GetUser, DataAccessError, SyncedLearningModulePath); lmIndex.FolderContentLoading += new EventHandler(lmIndex_ContentLoading); lmIndex.FolderContentLoaded += new EventHandler(lmIndex_FolderContentLoaded); lmIndex.FolderAdded += new EventHandler<FolderAddedEventArgs>(lmIndex_FolderAdded); lmIndex.LearningModuleAdded += new EventHandler<LearningModuleAddedEventArgs>(lmIndex_LearningModuleAdded); lmIndex.LearningModuleDetailsLoading += new EventHandler(lmIndex_LearningModuleDetailsLoading); lmIndex.LearningModuleUpdated += new LearningModuleUpdatedEventHandler(lmIndex_LearningModuleUpdated); lmIndex.LearningModuleDetailsLoaded += new EventHandler(lmIndex_LearningModuleDetailsLoaded); lmIndex.LoadingFinished += new EventHandler(lmIndex_LoadingFinished); lmIndex.ServersOffline += new LearningModulesIndex.ServersOfflineEventHandler(lmIndex_ServersOffline); learningModulesTreeViewControl.SetConnectionStringList(LearningModulesIndex.ConnectionsHandler.ConnectionStrings); learningModulesTreeViewControl.SetFeedList(LearningModulesIndex.ConnectionsHandler.Feeds); foreach (UncConnectionStringBuilder con in LearningModulesIndex.ConnectionsHandler.ConnectionStrings.FindAll(c => c is UncConnectionStringBuilder)) GetFolderOfConnection(con); FolderIndexEntry entry = GetFolderOfConnection(LearningModulesIndex.ConnectionsHandler.ConnectionStrings.Find(c => c.IsDefault)); if (entry != null) { actualItems = entry.GetContainingEntries(learningModulesTreeViewControl.ShowLearningModulesOfSubFolder); LoadLearningModulesList(actualItems, false); learningModulesTreeViewControl.SetSelectedFolder(entry); } listViewLearningModules.Groups.AddRange(LearningModulesIndex.Groups.ToArray()); if (!Directory.Exists(SyncedLearningModulePath)) Directory.CreateDirectory(SyncedLearningModulePath); }
public Facade() { AppSettings settings = new AppSettings(); string globalConfig = Path.Combine(Application.Current.StartupUri.AbsolutePath, settings.ConfigPath); string userConfig = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Properties.Settings.Default.ConfigurationFolder); /**** Omicron ***********************************************************************/ LearningModules = new LearningModulesIndex(globalConfig, userConfig, GetUser, DataAccessError, String.Empty); List<IConnectionString> connectionStrings = LearningModulesIndex.ConnectionsHandler.ConnectionStrings.FindAll(c => c.ConnectionType == MLifter.DAL.DatabaseType.PostgreSQL); try { if (connectionStrings.Count > 0) { try { ConnectionString = connectionStrings[0]; FolderIndexEntry entry = LearningModules.GetFolderOfConnection(ConnectionString); CurrentUser = LearningModulesIndex.ConnectionUsers[ConnectionString]; if (!CurrentUser.HasPermission(CurrentUser.List(), PermissionTypes.IsAdmin)) throw new PermissionException(); SecurityFramework = MLifter.DAL.Security.SecurityFramework.GetDataAdapter(ConnectionString.ConnectionString); } catch (PermissionException) { CurrentUser.Logout(); MessageBox.Show(Resources.CONNECTION_ERROR_PERMISSION_TEXT, Resources.CONNECTION_ERROR_PERMISSION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Warning); throw; } catch (Exception e) { //MessageBox.Show(Resources.CONNECTION_ERROR_FAILURE_TEXT, Resources.CONNECTION_ERROR_FAILURE_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error); TaskDialog.MessageBox(Resources.CONNECTION_ERROR_FAILURE_CAPTION, Resources.CONNECTION_ERROR_FAILURE_TEXT, string.Empty, e.ToString(), string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error); throw; } } else { TaskDialog.MessageBox(Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_CAPTION, Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_TEXT, String.Format(Resources.CONNECTION_ERROR_NO_CONNECTION_AVAILABLE_DETAILS, Settings.Default.ConfigurationFolder), TaskDialogButtons.OK, TaskDialogIcons.Error); throw new Exception(); } } catch { Environment.Exit(-1); } /**** Omicron ***********************************************************************/ AddNewGroupCommand = new DelegateCommand<object>(ExecuteAddNewGroupCommand, CanAddNewGroupCommand); RemoveGroupCommand = new DelegateCommand<Group>(ExecuteRemoveGroupCommand, CanRemoveGroupCommand); AddNewUserCommand = new DelegateCommand<object>(ExecuteAddNewUserCommand, CanAddNewUserCommand); RemoveUserCommand = new DelegateCommand<UserInfo>(ExecuteRemoveUserCommand, CanRemoveUserCommand); ResetTypePermissionCommand = new DelegateCommand<TypeInformation>(ExecuteResetTypePermissionCommand, CanResetTypePermissionCommand); ResetObjectPermissionCommand = new DelegateCommand<ObjectInformation>(ExecuteResetObjectPermissionCommand, CanResetObjectPermissionCommand); RenameGroupCommand = new DelegateCommand<Group>(ExecuteRenameGroupCommand, CanRenameGroupCommand); RenameUserCommand = new DelegateCommand<UserInfo>(ExecuteRenameUserCommand, CanRenameUserCommand); ChangeUserPasswordCommand = new DelegateCommand<UserInfo>(ExecuteChangeUserPasswordCommand, CanChangeUserPasswordCommand); ImportNewUserCommand = new DelegateCommand<object>(ExecuteImportNewUserCommand, CanImportNewUserCommand); RemoveGroupFromUserCommand = new DelegateCommand<GroupMembershipInfo>(ExecuteRemoveGroupFromUserCommand, CanRemoveGroupFromUserCommand); RemoveUserFromActualGroupCommand = new DelegateCommand<UserInfo>(ExecuteRemoveUserFromActualGroupCommand, CanRemoveUserFromActualGroupCommand); AddUserToActualGroupCommand = new DelegateCommand<object>(ExecuteAddUserToActualGroupCommand, CanAddUserToActualGroupCommand); }