NotePad 2009

The UI of Notepad 2009 looks like following:

Notepad 2009.JPG

NOTEPAD 2009 ____

 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (r.Modified == true)
            {
                System.Windows.Forms.DialogResult answer;
                answer = MessageBox.Show("Save this document before closing?", "Unsaved Document", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (answer == System.Windows.Forms.DialogResult.Yes)
                {
                    if (currentFile == string.Empty)
                    {
                        saveAsToolStripMenuItem_Click(this, e);
                        return;
                    }


                    {
                        string strExt;
                        strExt = System.IO.Path.GetExtension(currentFile);
                        strExt = strExt.ToUpper();
                        if (strExt == ".RTF")
                        {
                            r.SaveFile(currentFile);
                        }
                        else
                        {
                            System.IO.StreamWriter txtWriter;
                            txtWriter = new System.IO.StreamWriter(currentFile);
                            txtWriter.Write(r.Text);
                            txtWriter.Close();
                            txtWriter = null;
                            r.SelectionStart = 0;
                            r.SelectionLength = 0;
                        }

                        this.Text = "NotePad 2009: " + currentFile.ToString();
                        r.Modified = false;

                    }
                }
                else
                {
                    r.Modified = false;
                    Application.Exit();
                }
            }
            else
            {
                r.Modified = false;
                Application.Exit();
            }
        }
           
 private void savedata()//create this function
        {
            if (filename == "")
            {
                saveFileDialog1.Filter = "Text Files|*.txt|HTML Files|*.htm|All Files|*.*";
                DialogResult res = saveFileDialog1.ShowDialog();
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                filename = saveFileDialog1.FileName;
                MessageBox.Show(filename);
            }
            StreamWriter sw = new StreamWriter(filename);
            sw.WriteLine(r.Text);
            sw.Flush();
            sw.Close();
        }

 

Download the attached project and open in Visual Studio 2005 to learn more about this application.

 

Up Next
    Ebook Download
    View all
    Learn
    View all