示例#1
0
        protected virtual void btnGenerate_Click(object sender, EventArgs e)
        {
            rtfOutGenerated.ReadOnly = false;
            if (!capitalizeFirstLetter())
            {
                rtfOutGenerated.Text     = "Invalid Fields";
                rtfOutGenerated.ReadOnly = true;
                return;                 // Stop progression
            }
            ;
            rtfOutGenerated.Text = txtInAuthorLN.Text + ", ";
            // Get Initials
            try {
                string[] firstNames = txtInAuthorFN.Text.Split();
                initialsCount = firstNames.Length;
                for (int i = 0; i < firstNames.Length; i++)
                {
                    rtfOutGenerated.AppendText(firstNames[i].Substring(0, 1).ToUpper() + ".");
                }
            }
            catch {
                MessageBox.Show("Author Names cannot be blank.");
                rtfOutGenerated.Text     = "Invalid Fields";
                rtfOutGenerated.ReadOnly = true;
                return;                 // Stop progression
            }

            rtfOutGenerated.AppendText(" " + txtInYear.Text + ". ");
            FieldOps.AppendAsItalic(rtfOutGenerated, txtInTitle.Text);

            //If Book
            if (medium == (int)Mediums.Book)
            {
                rtfOutGenerated.AppendText(". " + txtInCity.Text + ", " + txtInState.Text.ToUpper() + ": " + txtInPublisher.Text + ".");
            }
            //If ebook
            else if (medium == (int)Mediums.eBook)
            {
                rtfOutGenerated.AppendText(" [E-Reader Version]. Retrieved from " + txtInUrl.Text);
            }
        }
示例#2
0
        protected override void btnGenerate_Click(object sender, EventArgs e)
        {
            rtfOutGenerated.ReadOnly = false;
            txtInTitle.Text          = FieldOps.CapLetter(txtInTitle.Text, 0);
            txtInCity.Text           = FieldOps.CapLetter(FieldOps.GetFieldText(txtInCity, "Unknown City"), 0);
            txtInAuthorFN.Text       = FieldOps.CapLetter(txtInAuthorFN.Text, 0);
            txtInAuthorLN.Text       = FieldOps.CapLetter(FieldOps.GetFieldText(txtInAuthorLN, "Unknown"), 0);
            txtInPublisher.Text      = FieldOps.CapLetter(FieldOps.GetFieldText(txtInPublisher, "Unknown Pubisher"), 0);
            txtInState.Text          = FieldOps.GetFieldText(txtInState, "Unknown State").ToUpper();

            if (txtInYear.Text.Length == 0)
            {
                MessageBox.Show("Year number cannot be blank.");
                rtfOutGenerated.Text     = "Invalid Fields";
                rtfOutGenerated.ReadOnly = true;
                return;                 // Stop progression
            }

            if (txtInTitle.Text.Length == 0)
            {
                MessageBox.Show("Title cannot be blank.");
                rtfOutGenerated.Text     = "Invalid Fields";
                rtfOutGenerated.ReadOnly = true;
                return;                 // Stop progression
            }

            /*
             *
             * if (!capitalizeFirstLetter ()) {
             *      rtfOutGenerated.Text = "Invalid Fields";
             *      rtfOutGenerated.ReadOnly = true;
             *      return; // Stop progrlastession
             * };
             */

            rtfOutGenerated.Text = txtInAuthorLN.Text;
            if (txtInAuthorFN.Text.Length > 0)
            {
                rtfOutGenerated.AppendText(", ");                  // only add comma if fname is defined
            }
            // Capitalize first letter of each name
            try
            {
                string[] firstNames = txtInAuthorFN.Text.Split();
                for (int i = 0; i < firstNames.Length; i++)
                {
                    rtfOutGenerated.AppendText(FieldOps.CapLetter(firstNames[i], 0));
                    if (i != firstNames.Length - 1)
                    {
                        rtfOutGenerated.AppendText(" ");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Author Names cannot be blank.");
                rtfOutGenerated.Text     = "Invalid Fields";
                rtfOutGenerated.ReadOnly = true;
                return;                 // Stop progression
            }

            rtfOutGenerated.AppendText(". ");
            FieldOps.AppendAsItalic(rtfOutGenerated, txtInTitle.Text);
            rtfOutGenerated.AppendText(". " + txtInCity.Text + ": " + txtInPublisher.Text + ", " + txtInYear.Text);

            if (medium == (int)Mediums.Book)
            {
                rtfOutGenerated.AppendText(". Print.");
            }
            else if (medium == (int)Mediums.eBook)
            {
                rtfOutGenerated.AppendText(". Digital File.");
            }
        }
示例#3
0
 protected void btnCopy_Click(object sender, EventArgs e)
 {
     FieldOps.CopyRTBtoClipboard(rtfOutGenerated);
     MessageBox.Show("Copied to Clipboard!");
 }