private void Dashboard_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var files = ((string[])e.Data.GetData(DataFormats.FileDrop)).Where(x => x.EndsWith(".steelquiz")); if (!files.Any()) { return; } bool anySuccess = false; foreach (var file in files) { if ((LoadedQuiz = QuizCore.LoadQuiz(file)) != null) { anySuccess = true; } } if (anySuccess) { PopulateQuizList(); UpdateQuizOverview(); } } }
private void btn_loadQuiz_Click(object sender, EventArgs e) { // The ShowDialog is performance intensive, so skip animation to prevent lag SkipAddQuizButtonsExpandedAnimation = true; AddQuizButtonsExpanded = false; if (ofd_loadQuiz.ShowDialog() == DialogResult.OK) { LoadedQuiz = QuizCore.LoadQuiz(ofd_loadQuiz.FileName); PopulateQuizList(); UpdateQuizOverview(); } }
private void btn_importQuizFromSite_Click(object sender, EventArgs e) { AddQuizButtonsExpanded = false; var import = new QuizImportGuide(); if (import.ShowDialog() == DialogResult.OK) { LoadedQuiz = QuizCore.LoadQuiz(import.QuizPath); PopulateQuizList(); UpdateQuizOverview(); } }
private void Lbl_name_Click(object sender, EventArgs e) { var quizPath = QuizIdentity.FindQuizPath(); if (quizPath == null) { return; } var quiz = QuizCore.LoadQuiz(quizPath); if (quiz == null) { return; } (ParentForm as Dashboard).LoadedQuiz = quiz; (ParentForm as Dashboard).UpdateQuizOverview(); }
private void ResetProgressDataToolStripMenuItem_Click(object sender, EventArgs e) { var msg = MessageBox.Show($"Are you sure you want to start over learning the quiz '{QuizIdentity.GetLastKnownName()}'? This action cannot be undone.", "Reset Quiz Progress data - SteelQuiz", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (msg != DialogResult.Yes) { return; } var quizPath = QuizIdentity.FindQuizPath(); if (quizPath == null) { return; } var quiz = QuizCore.LoadQuiz(quizPath); if (quiz == null) { return; } // Ensure we are not resetting the wrong progress data SAssert.Assert(quiz.ProgressData.QuizGUID == QuizIdentity.QuizGuid); SAssert.Assert(quiz.GUID == QuizIdentity.QuizGuid); quiz.ProgressData = new QuizProgress(quiz); QuizCore.SaveQuizProgress(quiz); var quizProgressInfo = Program.frmDashboard.FindQuizProgressInfo(QuizIdentity.QuizGuid); if (quizProgressInfo != null) { quizProgressInfo.Quiz = quiz; quizProgressInfo.UpdateLearningProgress(true); } (ParentForm as Dashboard).LoadedQuiz = quiz; (ParentForm as Dashboard).UpdateQuizOverview(); }
private void exportQuizToolStripMenuItem_Click(object sender, EventArgs e) { var quizPath = QuizIdentity.FindQuizPath(); if (quizPath == null) { return; } var quiz = QuizCore.LoadQuiz(quizPath); if (quiz == null) { return; } var quizExport = new QuizExport(quiz); quizExport.ShowDialog(); }
/// <summary> /// Processes a WndProc message sent from other instances of SteelQuiz. This method may only be called ONCE per message! /// </summary> /// <param name="m">The message sent.</param> /// <param name="form">The form that received the message.</param> public static void ProcessWndProcMessage(ref Message m, Form form) { if (m.Msg == NativeMethods.WM_SHOW_ME) { ShowMe(form); } else if (m.Msg == NativeMethods.WM_LOAD_QUIZ) { if (frmQuizPractise != null) { frmQuizPractise.Close(); frmDashboard.Show(); } else if (QuizEditorsOpen > 0) { ShowMe(openQuizEditors.Last()); MessageBox.Show("Please close all quiz editors first to load the quiz.", "SteelQuiz", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } object quizPath = null; using (var key = Registry.CurrentUser.OpenSubKey(@"Software\SteelQuiz\Communication", true)) { if (key == null) { throw new Exception("WM_LOAD_QUIZ message received but HKCU\\Software\\SteelQuiz\\Communication does not exist"); } quizPath = key.GetValue("QuizToLoadPath", null); if (quizPath == null) { throw new Exception("WM_LOAD_QUIZ message received but QuizToLoadPath value does not exist"); } key.DeleteValue("QuizToLoadPath"); } frmDashboard.LoadedQuiz = QuizCore.LoadQuiz((string)quizPath); frmDashboard.UpdateQuizOverview(); ShowMe(frmDashboard); } }
public Dashboard() { InitializeComponent(); QuizCore.LoadQuizAccessData(); btn_createQuiz_locationDelta = btn_createQuiz.Location.Subtract(btn_addQuiz.Location); btn_loadQuizFromFile_locationDelta = btn_loadQuizFromFile.Location.Subtract(btn_addQuiz.Location); btn_importQuiz_locationDelta = btn_importQuiz.Location.Subtract(btn_addQuiz.Location); btn_preferences_locationDelta = btn_preferences.Location.Subtract(btn_addQuiz.Location); if (MetaData.PRE_RELEASE) { this.Text += $" v{Application.ProductVersion} PRE-RELEASE"; } SetControlStates(); ofd_loadQuiz.InitialDirectory = ConfigManager.Config.StorageConfig.DefaultQuizSaveFolder; if (Util.WinVer.WindowsVersion().Major >= 10) // if user runs Windows 10 { if (ConfigManager.Config.SyncWin10Theme) { if (!PullWin10Theme()) { SetTheme(); } } else { SetTheme(); } themeMonitor = new RegistryMonitor(RegistryHive.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); themeMonitor.RegChanged += ThemeMonitor_RegChanged; themeMonitor.Error += ThemeMonitor_Error; themeMonitor.Start(); } else { SetTheme(); } Updater.Update(Updater.UpdateMode.Normal); ConfigManager.GetThingsReady(); UpdateCfg(); QuizCore.LoadQuizAccessData(); if (Program.Args.Length > 0 && File.Exists(Program.Args[0]) && Program.Args[0].EndsWith(".steelquiz")) { string path = Program.Args[0]; LoadedQuiz = QuizCore.LoadQuiz(path); PopulateQuizList(); UpdateQuizOverview(); } else { PopulateQuizList(); } }