Exemplo n.º 1
0
            protected override void OnCreateMainForm()
            {
                switch (GuiConfiguration.StartupAction)
                {
                case "Practice":
                    MainForm =
                        new Forms.PracticeWindow(DataStore.Database.GetSuggestedPracticeItems(GuiConfiguration.PracticeDefaultCount),
                                                 PracticeMode.Learn);
                    break;

                case "Dictionary":
                    string dict = GuiConfiguration.StartupDictionary;
                    if (string.IsNullOrEmpty(dict))
                    {
                        break;
                    }

                    Exception error = null;

                    try {
                        DictionaryInfo info = new SimpleDictionary.Info(dict);
                        MainForm = new Forms.LookupForm(info);
                    } catch (System.IO.IOException e) {
                        // TODO: Access/permission exceptions?
                        error = e;
                    } catch (DictionaryLoadException e) {
                        error = e;
                        // Maybe there should be some UI for this (it's there, but not loadable?)...
                    }

                    if (error != null)
                    {
                        ProgramLog.Default.AddMessage(LogType.Error, "Could not load dictionary {0}: {1}", dict, error.Message);
                    }
                    break;
                }

                if (MainForm == null)
                {
                    MainForm = new Forms.StartPage();
                }
            }
Exemplo n.º 2
0
			protected override void OnCreateMainForm() {
				switch (GuiConfiguration.StartupAction) {
					case "Practice":
						MainForm =
							new Forms.PracticeWindow(DataStore.Database.GetSuggestedPracticeItems(GuiConfiguration.PracticeDefaultCount),
							                         PracticeMode.Learn);
						break;

					case "Dictionary":
						string dict = GuiConfiguration.StartupDictionary;
						if (string.IsNullOrEmpty(dict))
							break;

						Exception error = null;

						try {
							DictionaryInfo info = new SimpleDictionary.Info(dict);
							MainForm = new Forms.LookupForm(info);
						} catch (System.IO.IOException e) {
							// TODO: Access/permission exceptions?
							error = e;
						} catch (DictionaryLoadException e) {
							error = e;
							// Maybe there should be some UI for this (it's there, but not loadable?)...
						}

						if (error != null)
							ProgramLog.Default.AddMessage(LogType.Error, "Could not load dictionary {0}: {1}", dict, error.Message);
						break;
				}

				if (MainForm == null)
					MainForm = new Forms.StartPage();
			}