private void TabbedNotepad_MouseDown(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < this.TabbedNotepad.TabPages.Count; i++)
            {
                Rectangle r = TabbedNotepad.GetTabRect(i);

                Rectangle closeButton = new Rectangle(r.Right - 15, r.Top + 4, 9, 7);
                if (closeButton.Contains(e.Location))
                {
                    CloseTabAt(i);
                    break;
                }
            }
        }
        private void Runtime_Tick(object sender, EventArgs e)
        {
            try
            {
                if (TabbedNotepad.TabCount == 0)
                {
                    NewToolStripMenuItem_Click(sender, e);
                }

                int textLen = notepadPages[TabbedNotepad.SelectedIndex].Text.Length;
                int lineLen = notepadPages[TabbedNotepad.SelectedIndex].Lines.Length;

                TextLengthLabel.Text = "Length: " + textLen;

                if (lineLen > 0)
                {
                    LineTotalLabel.Text = "Lines: " + lineLen;
                }
                else
                {
                    LineTotalLabel.Text = "Lines: 1";
                }

                string TabTitle, TabToolTip;
                if (notepadPages[TabbedNotepad.SelectedIndex].Saved)
                {
                    try
                    {
                        TabTitle = notepadPages[TabbedNotepad.SelectedIndex].FileName.Substring(0, 11).TrimEnd(' ', '.') + "...";
                    }
                    catch
                    {
                        TabTitle = notepadPages[TabbedNotepad.SelectedIndex].FileName;
                    }

                    TabToolTip = notepadPages[TabbedNotepad.SelectedIndex].FileName;
                    this.Text  = String.Format("{0} - SimpleNotepad", notepadPages[TabbedNotepad.SelectedIndex].FileName);
                }
                else
                {
                    try
                    {
                        TabTitle = ("(*) " + notepadPages[TabbedNotepad.SelectedIndex].FileName).Substring(0, 11).TrimEnd(' ', '.') + "...";
                    }
                    catch
                    {
                        TabTitle = ("(*) " + notepadPages[TabbedNotepad.SelectedIndex].FileName);
                    }
                    TabToolTip = "(Unsaved) " + notepadPages[TabbedNotepad.SelectedIndex].FileName;
                    this.Text  = String.Format("(*) {0} - SimpleNotepad", notepadPages[TabbedNotepad.SelectedIndex].FileName);
                }

                if (TabTitle != null && TabToolTip != null && notepadPages[TabbedNotepad.SelectedIndex].TabTitle != TabTitle || notepadPages[TabbedNotepad.SelectedIndex].TabToolTip != TabToolTip)
                {
                    notepadPages[TabbedNotepad.SelectedIndex].TabTitle   = TabTitle;
                    notepadPages[TabbedNotepad.SelectedIndex].TabToolTip = TabToolTip;

                    TabbedNotepad.Refresh();
                    notepadPages[TabbedNotepad.SelectedIndex].Focus();
                }

                EncodingLabel.Text = notepadPages[TabbedNotepad.SelectedIndex].EncodingString.ToUpper();

                if (notepadPages[TabbedNotepad.SelectedIndex].Encoding == Encoding.Default && !ANSIToolStripMenuItem.Checked)
                {
                    SetEncodingToolStripMenuItem_Click(ANSIToolStripMenuItem, e);
                }
                else if (notepadPages[TabbedNotepad.SelectedIndex].Encoding == Encoding.ASCII && !ASCIIToolStripMenuItem.Checked)
                {
                    SetEncodingToolStripMenuItem_Click(ASCIIToolStripMenuItem, e);
                }
                else if (notepadPages[TabbedNotepad.SelectedIndex].Encoding == Encoding.UTF8 && !UTF8ToolStripMenuItem.Checked)
                {
                    SetEncodingToolStripMenuItem_Click(UTF8ToolStripMenuItem, e);
                }
            }
            catch { }
        }