Exemple #1
0
        /// <summary>
        /// Gets the error message
        /// </summary>
        /// <param name="aErr">the Error code</param>
        /// <param name="aSuppressPopup">true to not pop up error message</param>
        /// <returns>the Error Message</returns>
        private string getError(Error aErr, bool aSuppressPopup = false)
        {
            string message = MadLib.getError(aErr);
            bool   popup   = false;

            switch (aErr)
            {
            case Error.UnknownException:
                popup = true;
                break;

            case Error.Create_IllegalTags:
                popup = true;
                break;

            case Error.Create_TooSmall:
                popup = true;
                break;

            default:
                break;
            }
            if (!string.IsNullOrEmpty(message))
            {
                if (popup && !aSuppressPopup)
                {
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(message);
        }
Exemple #2
0
 /// <summary>
 /// Create Madlib from a text file
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCreateFile_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult theResult = DialogOpen.ShowDialog();
         if (theResult == DialogResult.OK)
         {
             if (File.Exists(DialogOpen.FileName))
             {
                 madLib = new MadLib(File.ReadAllText(DialogOpen.FileName));
                 getError(madLib.create());
                 StoryBox.Text = madLib.MadLibText;
             }
         }
     }
     catch
     {
         getError(Error.UnknownException);
     }
 }
Exemple #3
0
 /// <summary>
 /// Create Madlib from a text file
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCreateText_Click(object sender, EventArgs e)
 {
     madLib = new MadLib(StoryBox.Text);
     getError(madLib.create());
     StoryBox.Text = madLib.MadLibText;
 }