Exemplo n.º 1
0
        private void btRefresh_Click(object sender, EventArgs e)
        {
            string name = MyConfig.GetSetting(MyConfig.Key_StudentName);

            if (string.IsNullOrEmpty(name))
            {
                FormSetup f = new FormSetup();
                f.ShowDialog();
            }

            if (string.IsNullOrEmpty(MyConfig.GetSetting(MyConfig.Key_StudentName).Trim()))
            {
                MessageBox.Show("Name must be set to use the program", "Empty Name", MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk);
                Environment.Exit(0);
            }

            string hash = MyConfig.GetSetting(MyConfig.Key_StudentHash);

            if (hash != MyConfig.GetHashFromName(name))
            {
                hash = MyConfig.GetHashFromName(name);
                MyConfig.SetSetting(MyConfig.Key_StudentHash, hash);
            }

            MyFileHelper.CopyExerciseFolders();
            MyFileHelper.GenerateEmptyFilesFromList();

            SetTitle();
            LoadFileLists();
            lvCompulsory.SelectedItems.Clear();
            lvAdditional.SelectedItems.Clear();
            UpdateWithListItem();
        }
Exemplo n.º 2
0
        private void btSetName_Click(object sender, EventArgs e)
        {
            string strNewName = tbName.Text.Trim();

            if (strNewName.ToLower() != strName.ToLower() && !string.IsNullOrEmpty(strName))
            {
                DialogResult dialogResult =
                    MessageBox.Show("Updating name will reset all completed exercises. Continue?",
                                    "Update Name", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            // Save name and hash to configSetting
            MyConfig.SetSetting(MyConfig.Key_StudentName, strNewName);
            MyConfig.SetSetting(MyConfig.Key_StudentHash, MyConfig.GetHashFromName(strNewName.ToLower()));

            // Copy all exercises
            MyFileHelper.CopyExerciseFolders();
            MyFileHelper.GenerateEmptyFilesFromList();

            btSetName.Enabled = false;

            Application.Restart();
        }