Programmatically Creating "About" dialog (with email functionality)




// ----------------------------------------------------------------------------
//                                      DTT 1.2.1.3  (c)2010 FSL - FreeSoftLand
// Title: About Dialog (with email link) Created Programmatically
//
// Date : 9/10/2010
// By   : kyrathaba
// ----------------------------------------------------------------------------

//assumes your form is frmMain
//assumes you've embedded a jpg/png resource "me_small" (a pic of yourself)

        private void ShowAboutForm() {
            Form frmAbout = new Form();
            frmAbout.Size = new Size(400, 250);
            frmAbout.StartPosition = FormStartPosition.CenterScreen;
            frmAbout.BackColor = Color.White;
            frmAbout.Text = "About";
            frmAbout.MaximizeBox = false;
            frmAbout.MinimizeBox = false;
            frmAbout.BackgroundImageLayout = ImageLayout.None;
            frmAbout.BackgroundImage = Character_Creator.Properties.Resources.me_small;
            //position cursor over "X" so single mouse-click will close "About" form, without user having to
            //move the cursor with the mouse
            Cursor.Position = new Point(this.Left + 575, this.Top + 175);
            TextBox txtAbout = new TextBox();
            txtAbout.Multiline = true;
            txtAbout.ReadOnly = true;
            txtAbout.BackColor = Color.White;
            txtAbout.BorderStyle = BorderStyle.None;
            txtAbout.Size = new Size(frmAbout.Width - 150, frmAbout.Height - 85);
            frmAbout.Controls.Add(txtAbout);
            txtAbout.Location = new Point(frmAbout.Left + 125, frmAbout.Top + 5);
            Font myFnt = new Font("Verdana", 10, FontStyle.Regular);
            txtAbout.Font = myFnt;
            //sMsg is a form-level variable
            sMsg = "Character Creator " + sVersion + Environment.NewLine;
            sMsg += " 2010 by Crocusoft" + Environment.NewLine + Environment.NewLine;
            sMsg += "For use with:" + Environment.NewLine + string.Empty.PadLeft(5);
            sMsg += "\"Kyrian Cycle\" roleplaying game" + Environment.NewLine;
            sMsg += string.Empty.PadLeft(5) + "(see URL link below)" + Environment.NewLine + Environment.NewLine;
            sMsg += "Click picture to email me.";
            sMsg += string.Empty.PadRight(1000);
            txtAbout.Text = sMsg;
            txtAbout.SelectionStart = txtAbout.Text.Length;
            txtAbout.SelectionLength = 0;
            LinkLabel lnkAbout = new LinkLabel();
            lnkAbout.AutoSize = true;
            lnkAbout.Text = sGameURL;
            lnkAbout.Location = new Point(frmAbout.Left + 50, frmAbout.Bottom - 60);
            frmAbout.Controls.Add(lnkAbout);
            lnkAbout.Click += new EventHandler(lnkAbout_Click);
            frmAbout.Click += new EventHandler(frmAbout_Click);
            frmAbout.Closed += new EventHandler(frmAbout_Closed);
            frmAbout.Show();
        }

        private void frmAbout_Click(object sender, EventArgs e) {
            //this.Text = Cursor.Position.ToString();
            //if user clicked in the area of the picture of Yours Truly, launch default email client so user can send me a message
            if (Cursor.Position.X >= 500) {
                if (Cursor.Position.X <= 600) {
                    if (Cursor.Position.Y >= 330) {
                        if (Cursor.Position.Y <= 410) {
                            Process procMail = new Process();
                            sMsg = "mailto:wmmiller@duo-county.com";
                            sMsg += "?Subject=regarding Character Creator " + sVersion;
                            sMsg += "&body=Regarding your program:" + Environment.NewLine + Environment.NewLine;
                            procMail.StartInfo.FileName = sMsg;
                            procMail.StartInfo.UseShellExecute = true;
                            procMail.StartInfo.RedirectStandardOutput = false;
                            procMail.Start();
                            procMail.Dispose();
                        }
                    }
                }
            }
        }


        private void frmAbout_Closed(object sender, EventArgs e) {
            //MessageBox.Show("frmAbout Closed!");

            //anything you want to happen when About "box" is closed

        }