Esempio n. 1
0
        private void QuickImport_Click(object sender, EventArgs e)
        {
            CloseAllPanels();
            string name   = "";
            string toshow = "Availible QuickImport Keys: ";

            foreach (FileInfo file in currentdirectory.GetFiles())
            {
                if (file.Extension == ".key")
                {
                    toshow += file.Name.Replace(".key", "") + ", ";
                }
            }

            if (InputBox.Show("QuickStudyGuider", toshow, ref name) == DialogResult.OK)
            {
                try
                {
                    answerKey = new AnswerKey(Environment.CurrentDirectory + "\\" + name + ".key", "<ans>", "<new>");
                }
                catch
                {
                    MessageBox.Show("There was an error loading in the key");
                }
            }
        }
Esempio n. 2
0
 private void ImportKeyLabel_Click(object sender, EventArgs e)
 {
     CloseAllPanels();
     openFileDialog.FileName = "";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             if (answerKey == null)
             {
                 answerKey = new AnswerKey(openFileDialog.FileName, defaultsplitkey, defaultnewline);
             }
             else
             {
                 if (MessageBox.Show("An answer key has already been imported. Would you like to join the 2 keys for more answers or overide the current key?", "QuickStudyGuider", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     answerKey.AppendKey(new AnswerKey(openFileDialog.FileName, defaultsplitkey, defaultnewline));
                 }
                 else
                 {
                     answerKey = new AnswerKey(openFileDialog.FileName, defaultsplitkey, defaultnewline);
                 }
             }
         }
         catch
         {
             MessageBox.Show("File is corrupted. The data in the file may not be valid for a key file.");
             answerKey = null;
         }
     }
 }
Esempio n. 3
0
        private void ChangeSplit_Click(object sender, EventArgs e)
        {
            CloseAllPanels();
            string value = defaultsplitkey;

            if (InputBox.Show("QuickStudyGuider", "Enter a split pattern between definitions and terms.", ref value) == DialogResult.OK)
            {
                string value2 = defaultnewline;
                if (InputBox.Show("QuickStudyGuider", "Enter a split pattern between rows.", ref value2) == DialogResult.OK)
                {
                    if (answerKey != null)
                    {
                        try
                        {
                            answerKey = new AnswerKey(answerKey.filepath, value, value2);
                        }
                        catch
                        {
                            MessageBox.Show("The split change for this key is invalid. Dumping key.");
                            answerKey = null;
                        }
                    }
                    defaultsplitkey = value;
                    defaultnewline  = value2;
                }
            }
        }
Esempio n. 4
0
 private void DumpKeyLabel_Click(object sender, EventArgs e)
 {
     CloseAllPanels();
     if (MessageBox.Show("Are you sure you would like to dump this key? Any modifications will be lost. If want to keep modifications, click save key and then dump key.", "QuickStudyGuider", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         answerKey = null;
     }
 }
Esempio n. 5
0
 private void SaveKeyLabel_Click(object sender, EventArgs e)
 {
     CloseAllPanels();
     if (answerKey == null)
     {
         MessageBox.Show("Please import an key to work with.");
     }
     else
     {
         AnswerKey.ExportKey(answerKey, answerKey.filepath);
     }
 }
        public static void ExportKey(AnswerKey key, string filepath)
        {
            List <string> list = new List <string>();

            foreach (Answer answer in key.answers)
            {
                string line = answer.question + key.splitkey + answer.answer;
                list.Add(line);
            }
            string towrite = string.Join(key.newlinesplit, list);

            File.WriteAllText(filepath, towrite);
        }
Esempio n. 7
0
 private void ExportKeyLabel_Click(object sender, EventArgs e)
 {
     CloseAllPanels();
     openFileDialog.FileName = "";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         if (answerKey == null)
         {
             MessageBox.Show("Please import an key to work with.");
         }
         else
         {
             AnswerKey.ExportKey(answerKey, openFileDialog.FileName);
         }
     }
 }
 public void AppendKey(AnswerKey extrakey)
 {
     this.answers.AddRange(extrakey.answers);
 }