示例#1
0
        private void openFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Text files (.txt)|*.txt";
            ofd.Title  = "Open a file...";
            string filename = null;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                // new text boxes for content and line numbers
                RichTextBoxEx rtb = new RichTextBoxEx();

                System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName);
                filename  = Path.GetFileName(ofd.FileName);
                rtb.Text  = sr.ReadToEnd();
                this.Text = "JNote - " + ofd.FileName;
                sr.Close();

                // genate a new tab page
                TabPage tp = new TabPage(filename);
                tp.BackColor = Color.Black;
                tp.ForeColor = Color.White;

                tp.Controls.Add(rtb);
                tp.Controls.Add(rtb.ln_txtbbox);
                tabControl.Controls.Add(tp);
                tabControl.SelectedTab = tp;

                cursorPos = GetRichTextBox().SelectionStart;
            }
        }
示例#2
0
        private RichTextBoxEx GetRichTextBox()
        {
            TabPage       tp  = tabControl.SelectedTab;
            RichTextBoxEx rtb = null;

            if (tp != null)
            {
                rtb = tp.Controls[0] as RichTextBoxEx;
            }

            return(rtb);
        }
示例#3
0
        private void newTab()
        {
            // genate a new tab page
            TabPage tp = new TabPage("New Document");

            tp.BackColor = Color.Black;
            tp.ForeColor = Color.White;

            // new text boxes for content and line numbers
            RichTextBoxEx rtb = new RichTextBoxEx();

            // set configurations
            rtb.Dock      = DockStyle.Fill;
            rtb.BackColor = Color.FromArgb(255, 16, 16, 16);
            rtb.Font      = new Font("Calibri", 12);
            rtb.ForeColor = Color.White;

            tp.Controls.Add(rtb);
            tp.Controls.Add(rtb.ln_txtbbox);
            tabControl.Controls.Add(tp);
            tabControl.SelectedTab = tp;

            cursorPos = GetRichTextBox().SelectionStart;
        }