Exemple #1
0
 /// <summary>
 /// Shows the wizard.
 /// </summary>
 /// <returns>The Dialog result of the wizard.</returns>
 /// <remarks>Documented by Dev05, 2007-12-14</remarks>
 private DialogResult ShowWizard()
 {
     CreateListViewSnapshot(settingsPage.listViewElements);
     Wizard wizard = new Wizard();
     wizard.HelpFile = HelpFile;
     wizard.Text = Resources.WIZARD_HEADER;
     wizard.Pages.Add(settingsPage);
     wizard.ShowInTaskbar = false;
     wizard.ShowDialog();
     if (wizard.DialogResult == DialogResult.Cancel)
     {
         RestoreListViewSnapshot(settingsPage.listViewElements);
         RefreshSettingsPageListView();
     }
     return wizard.DialogResult;
 }
Exemple #2
0
		private void CreateNewLearningModule()
		{
			try
			{
				if (LearningModulesIndex.WritableConnections.Count <= 0)
					throw new NoWritableConnectionAvailableException();

				//Close the current learning module
				if (LearnLogic.LearningModuleLoaded)
					if (!LearnLogic.CloseLearningModule())
						return;

				//Create the wizard
				Wizard dicWizard = new Wizard();
				dicWizard.HelpFile = MLifter.Classes.Help.HelpPath;
				dicWizard.Text = Resources.NEWDIC_CAPTION;

				SourceSelectionPage sourceSelectionPage = null;
				WelcomePage welcomePage = new WelcomePage();
				SideSettingsPage sideSettingsPage = new SideSettingsPage();

				// only one connection available?
				if (LearningModulesIndex.WritableConnections.Count <= 0)
					throw new NoWritableConnectionAvailableException();
				else if (LearningModulesIndex.WritableConnections.Count > 1)
				{
					sourceSelectionPage = new SourceSelectionPage();
					dicWizard.Pages.Add(sourceSelectionPage);
				}
				dicWizard.Pages.Add(welcomePage);
				dicWizard.Pages.Add(sideSettingsPage);

				//Show the Wizards
				if (dicWizard.ShowDialog() == DialogResult.OK)
				{
					try
					{
						newLM = true;
						IConnectionString connectionString;
						if (sourceSelectionPage != null)
							connectionString = sourceSelectionPage.ConnectionString;
						else
							connectionString = LearningModulesIndex.WritableConnections[0];

						string dicName = welcomePage.DictionaryName;

						if (!LearningModulesIndex.ConnectionUsers.ContainsKey(connectionString))
						{
							FolderIndexEntry folderEntry = new FolderIndexEntry(connectionString is UncConnectionStringBuilder ? connectionString.ConnectionString : string.Empty,
								connectionString.Name, connectionString, null, Setup.SyncedModulesPath, LearnLogic.GetLoginDelegate, LearnLogic.DataAccessErrorDelegate);
							LearningModulesIndex.ConnectionUsers[connectionString] = folderEntry.CurrentUser;
						}
						LearnLogic.User.SetBaseUser(LearningModulesIndex.ConnectionUsers[connectionString]);
						ConnectionStringStruct connectionStringStruct;
						using (MLifter.DAL.Interfaces.IDictionary newDic = LearnLogic.User.CreateLearningModule(welcomePage.DictionaryCategory.Id, welcomePage.DictionaryName))
						{
							newDic.Author = welcomePage.DictionaryAuthor;
							newDic.Category = welcomePage.DictionaryCategory;
							newDic.Description = welcomePage.DictionaryDescription;

							newDic.DefaultSettings.AnswerCaption = sideSettingsPage.AnswerTitle;
							newDic.DefaultSettings.QuestionCaption = sideSettingsPage.QuestionTitle;
							newDic.DefaultSettings.AnswerCulture = sideSettingsPage.AnswerCulture;
							newDic.DefaultSettings.QuestionCulture = sideSettingsPage.QuestionCulture;
							newDic.Save();

							connectionStringStruct = new ConnectionStringStruct(connectionString.ConnectionType == DatabaseType.Unc ? DatabaseType.MsSqlCe : connectionString.ConnectionType,
								newDic.Connection, newDic.Id, LearnLogic.User.SessionId);
							connectionStringStruct.LearningModuleFolder = connectionString.ConnectionString;
						}
						LearningModulesIndexEntry entry = new LearningModulesIndexEntry();
						entry.ConnectionString = connectionStringStruct;
						entry.Author = welcomePage.DictionaryAuthor;
						entry.DisplayName = welcomePage.DictionaryName;
						entry.Description = welcomePage.DictionaryDescription;
						entry.Connection = connectionString;
						entry.User = LearningModulesIndex.ConnectionUsers[connectionString];

						OpenLearningModule(entry);

						LearnLogic.SaveLearningModule();
						this.Activate(); //[ML-763] Window is not focused after creation of a new dictionary
						OnLMOptionsChanged();

						newLM = false;
					}
					catch (Exception exp)
					{
						Trace.WriteLine(exp.ToString());
						TaskDialog.MessageBox(Resources.NEW_DICT_CAPTION, Resources.NEW_DICT_CAPTION, Resources.NEW_DICT_TEXT, exp.ToString(),
							string.Empty, string.Empty, TaskDialogButtons.OK, TaskDialogIcons.Error, TaskDialogIcons.Error);
					}
				}
				else
					ShowLearningModulesPage();
			}
			catch (NoWritableConnectionAvailableException)
			{
				TaskDialog.MessageBox(Resources.NEW_DIC_NO_CONNECTION_CAPTION, Resources.NEW_DIC_NO_CONNECTION_CAPTION, Resources.NEW_DIC_NO_CONNECTION_TEXT, TaskDialogButtons.OK, TaskDialogIcons.Error);
			}
		}
Exemple #3
0
		/// <summary>
		/// Handles the Click event of the printToolStripMenuItem control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		/// <remarks>Documented by Dev02, 2008-04-25</remarks>
		private void printToolStripMenuItem_Click(object sender, EventArgs e)
		{
			DialogResult result = DialogResult.None;

			do
			{
				if (result == DialogResult.Ignore)
					Settings.Default.UsePrintWizard = !Settings.Default.UsePrintWizard;

				if (Settings.Default.UsePrintWizard)
				{
					//new print wizard
					Wizard printWizard = new Wizard();
					printWizard.Text = Resources.PRINT_WIZARD_TITLE;
					printWizard.HelpFile = MLifter.Classes.Help.HelpPath;

					Controls.Wizards.Print.WelcomePage wPage = new MLifter.Controls.Wizards.Print.WelcomePage();
					(wPage.IndividualPage as Controls.Wizards.Print.IndividualSelectionPage).Dictionary = LearnLogic.Dictionary;
					(wPage.ChapterPage as Controls.Wizards.Print.ChapterSelectionPage).Dictionary = LearnLogic.Dictionary;
					(wPage.BoxPage as Controls.Wizards.Print.BoxSelectionPage).Dictionary = LearnLogic.Dictionary;
					printWizard.Pages.Add(wPage);

					Controls.Wizards.Print.PrintPage pPage = new MLifter.Controls.Wizards.Print.PrintPage();
					pPage.StyleHandler = MainForm.styleHandler;
					pPage.Dictionary = LearnLogic.Dictionary;
					printWizard.Pages.Add(pPage);

					printWizard.ShowDialog();
					result = printWizard.DialogResult;
				}
				else
				{
					//old print dialog
					PrintForm PrintForm = new PrintForm();
					PrintForm.ShowDialog();
					result = PrintForm.DialogResult;
				}
			}
			while (result == DialogResult.Ignore);
		}
Exemple #4
0
		/// <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();
			}
		}