Beispiel #1
0
        /// <summary>
        /// Removes a quiz from the list
        /// </summary>
        public void RemoveQuiz(Guid quizGuid, bool save = true)
        {
            QuizCore.QuizAccessTimes.Remove(quizGuid);

            if (save)
            {
                QuizCore.SaveQuizAccessData();
            }

            foreach (var c in flp_lastQuizzes.Controls.OfType <RecentQuiz>())
            {
                if (c.QuizIdentity.QuizGuid == quizGuid)
                {
                    flp_lastQuizzes.Controls.Remove(c);
                    c.Dispose();
                    break;
                }
            }

            foreach (var c in pnl_quizOverview.Controls.OfType <QuizOverview>())
            {
                if (c.Quiz.GUID == quizGuid)
                {
                    pnl_quizOverview.Controls.Remove(c);
                    c.Dispose();
                    break;
                }
            }
        }
Beispiel #2
0
        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();
                }
            }
        }
Beispiel #3
0
        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();
            }
        }
Beispiel #4
0
        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();
            }
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var renameForm = new RenameQuiz(Path.GetFileNameWithoutExtension(QuizIdentity.FindQuizPath()));

            if (renameForm.ShowDialog() == DialogResult.OK)
            {
                QuizIdentity.RenameQuiz(renameForm.NewName);
                QuizCore.QuizIdentities[QuizIdentity.QuizGuid] = QuizIdentity;
                QuizCore.SaveQuizAccessData();
                lbl_name.Text = Path.GetFileNameWithoutExtension(QuizIdentity.LastKnownPath);

                if (Program.frmDashboard.LoadedQuiz != null && Program.frmDashboard.LoadedQuiz.QuizIdentity.QuizGuid == QuizIdentity.QuizGuid)
                {
                    Program.frmDashboard.LoadedQuiz.QuizIdentity = QuizIdentity;
                    Program.frmDashboard.PopulateQuizList();
                    Program.frmDashboard.UpdateQuizOverview();
                }
            }
        }
Beispiel #7
0
        private void clearRecentQuizzesListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var msg = MessageBox.Show($"Are you sure you want to clear the recent quizzes list? The quiz files will not be removed.",
                                      "Clear Recent Quizzes - SteelQuiz", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (msg != DialogResult.Yes)
            {
                return;
            }

            var recentQuizzes = flp_lastQuizzes.Controls.Cast <RecentQuiz>().Select(x => x.QuizIdentity.QuizGuid).ToList();

            foreach (var quizGuid in recentQuizzes)
            {
                RemoveQuiz(quizGuid, false);
            }

            QuizCore.SaveQuizAccessData();
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        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();
        }
Beispiel #10
0
        /// <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);
            }
        }
Beispiel #11
0
        private void Cmb_order_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cmb_order.SelectedItem)
            {
            case "Success Rate":
                Quiz.ProgressData.CardsDisplayOrder = CardsOrderBy.SuccessRate;
                break;

            case "Quiz Order":
                Quiz.ProgressData.CardsDisplayOrder = CardsOrderBy.QuizOrder;
                break;

            case "Alphabetical Front":
                Quiz.ProgressData.CardsDisplayOrder = CardsOrderBy.AlphabeticalTerm1;
                break;

            case "Alphabetical Back":
                Quiz.ProgressData.CardsDisplayOrder = CardsOrderBy.AlphabeticalTerm2;
                break;
            }

            switch (cmb_orderAscendingDescending.SelectedItem)
            {
            case "Ascending":
                Quiz.ProgressData.CardsDisplayOrderOrder = CardsOrderByOrder.Ascending;
                break;

            case "Descending":
                Quiz.ProgressData.CardsDisplayOrderOrder = CardsOrderByOrder.Descending;
                break;
            }

            QuizCore.SaveQuizProgress(Quiz);

            LoadCards();
        }
Beispiel #12
0
        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();
            }
        }