Esempio n. 1
0
        }     // End QuestionAndAnswerForm_Load

        /// <summary>
        /// This method is called if the QA form's open QA file menu option is clicked
        /// It uses an open file dialog to get the file path to the desired qa file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openQAFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = @"C:\Users\Owner\OneDrive\Documents\Learning\_CSharpQAFiles\QAFiles";
            // Open qa File if it has data and create the qaDictionary
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                qaFilePath = ofd.FileName;
                AnswerQuestionsDataModel.setQAFilePath(qaFilePath);
                // Determine if the file exists
                if (File.Exists(qaFilePath))
                {
                    // Determine if there are data in the file and if so read it into the dictionary
                    var  fil    = new FileInfo(qaFilePath);
                    long length = fil.Length;
                    if (length != 0)
                    {
                        // Load File into dictionary
                        AnswerQuestionsDataModel.loadQAFileIntoDictionary(qaFilePath);
                        // Get dictionary
                        qaDictionary = AnswerQuestionsDataModel.QandADictionary;
                    }
                    else
                    {
                        // If the file exists, but is blank
                        // Get a blank dictionary
                        qaDictionary             = AnswerQuestionsDataModel.QandADictionary;
                        questionNumberValue.Text = qaDictionary.Count.ToString();
                        questionValue.Select();
                    }
                } // EndOpen qa File if it has data and create the qaDictionary
            }     // End Open file dialogue
        }         // End openQAFileToolStripMenuItem_Click
Esempio n. 2
0
        //--------------------------EVENT METHODS----------------------------------//

        /// <summary>
        /// This Method: 1) Opens a local copy of the qaDictionary
        ///     1.  If it is called as a result of using the QA Tree form's Create/Edit button
        ///         then the qaFileNameString is the file name.
        ///         a.  If the retrieved qaFilePath is blank and new dictionary is called else
        ///         b.  The dictionary associated with an extant qaFile is loadee
        ///     2.  If it is called by Openeing the form from the dashboard then the qaFileNameString
        ///         is blank and the method is skipped
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void QuestionAndAnswerForm_Load(object sender, EventArgs e)
        {
            string qaFileNameString = AnswerQuestionsDataModel.getQAFileNameStr();

            if (qaFileNameString != "")
            {
                string qaFilePath = AnswerQuestionsDataModel.getQAFilePath();
                if (qaFilePath == "")
                {
                    // Get a blank dictionary
                    qaDictionary             = AnswerQuestionsDataModel.QandADictionary;
                    questionNumberValue.Text = qaDictionary.Count.ToString();
                    questionValue.Select();
                    return;
                }
                AnswerQuestionsDataModel.loadQAFileIntoDictionary(AnswerQuestionsDataModel.getQAFilePath());
                qaDictionary = AnswerQuestionsDataModel.QandADictionary;
                selectEditTypeLable.Visible = true;
            } //End if (qaFileNameString != "")
        }     // End QuestionAndAnswerForm_Load
Esempio n. 3
0
        /// <summary>
        /// This form can be called from the QATreeForm's
        /// takeQAFileTestButton_Click( method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnswerQuestionsForm_Load(object sender, EventArgs e)
        {
            string qaFilePath = AnswerQuestionsDataModel.getQAFilePath();
            // Get the int value at the end of the name
            string tempQAFilePathName = qaFilePath.Substring(0, qaFilePath.Length - 4);

            char[] tempQAFilePathNameArray = tempQAFilePathName.ToCharArray();
            keyIntStr = "";
            char lastChar = tempQAFilePathNameArray[tempQAFilePathNameArray.Length - 1];

            while (Char.IsDigit(lastChar))
            {
                keyIntStr = lastChar + keyIntStr;
                Array.Resize(ref tempQAFilePathNameArray, tempQAFilePathNameArray.Length - 1);
                lastChar = tempQAFilePathNameArray[tempQAFilePathNameArray.Length - 1];
            }
            // Convert this value to an integer
            keyToQAFileNameScoresDictionary = Int32.Parse(keyIntStr);

            AnswerQuestionsDataModel.loadQAFileIntoDictionary(qaFilePath);
            // Call initializeVariables() to initialize local variables
            initializeVariables();
        }// End void AnswerQuestionsForm_Load(