/// <summary>
 /// Creates a new instance of the <see cref="WebBrowserTabPage" /> class and displays the specified <b>WebBrowser</b> control.
 /// </summary>
 /// <param name="browser">
 /// The <b>WebBrowser</b> control to display on the page.
 /// </param>
 public RichTextBoxTabPage(RichTextBoxCore richTextBox)
 {
     richTextBox.Dock = DockStyle.Fill;
     this.Controls.Add(richTextBox);
     this._richTextBox = richTextBox;
     Text = richTextBox.fileName;
 }
Beispiel #2
0
        private void tabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.currentTextBox = tabs.SelectedRichTextBox;
            this.DisplayFileTitle();

            currentTextBox.Focus();

            // Enable the Close Tab command if and only if there is more than one tab.
            if (this.tabs.TabCount == 2)
            {
                this.closeTabButton.Enabled = false;
                closeTabTSMI.Enabled        = false;
            }
            else
            {
                this.closeTabButton.Enabled = true;
                closeTabTSMI.Enabled        = true;
            }

            saveButton.Enabled = currentTextBox.textChanged;

            filePathTSMI.Enabled = fileNameTSMI.Enabled = Path.GetDirectoryName(currentTextBox.fileName) != "";
            Debug.WriteLine(Path.GetExtension(currentTextBox.fileName));
            if (Path.GetExtension(currentTextBox.fileName) != ".rtf")
            {
                this.currentTextBox.Font = this.fontDialog.Font;
            }

            undoTSMI.Enabled  = currentTextBox.CanUndo;
            redoTSMI.Enabled  = currentTextBox.CanRedo;
            CutTSMI.Enabled   = CopyTSMI.Enabled = DeleteTSMI.Enabled = SearchTSMI.Enabled = currentTextBox.SelectedText.Length > 0;
            PasteTSMI.Enabled = currentTextBox.CanPaste(DataFormats.GetFormat(DataFormats.Text));

            lblStatus.Text = currentTextBox.StatusText;
        }
Beispiel #3
0
 private void NewTab()
 {
     tabs.AddTab();
     this.currentTextBox              = this.tabs.SelectedRichTextBox;
     currentTextBox.TextChanged      += currentTextBox_TextChanged;
     currentTextBox.SelectionChanged += currentTextBox_SelectionChanged;
     currentTextBox.MouseEnter       += currentTextBox_MouseEnter;
     currentTextBox.MouseLeave       += currentTextBox_MouseLeave;
     currentTextBox.GotFocus         += currentTextBox_GotFocus;
     currentTextBox.LostFocus        += currentTextBox_LostFocus;
     currentTextBox.ContextMenuStrip  = cmsGeneral;
     lblStatus.Text = currentTextBox.StatusText;
 }
Beispiel #4
0
        /// <summary>
        /// Starts a dialog that allows the user to change the font, font style and font size of the text box.
        /// Is called by the corresponding menu item or by a keyboard shortcut.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void fontTSMI_Click(object sender, EventArgs e)
        {
            if (this.fontDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (TabPage tab in tabs.TabPages)
                {
                    if (tab != addTabButton)
                    {
                        RichTextBoxCore rtb = ((RichTextBoxTabPage)tab).TextBox;

                        if (Path.GetExtension(rtb.fileName) != ".rtf")
                        {
                            rtb.Font = this.fontDialog.Font;
                        }
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Checks if a keyboard shortcut is used.
        /// When a known keyboard shortcut is entered, the corresponding command is executed.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="k">The event arguments.</param>
        private void MainWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.O)
            {
                this.OpenFile();
            }

            if (e.Control && e.KeyCode == Keys.S)
            {
                this.SaveFile(false);
            }

            if (e.Control && e.Shift && e.KeyCode == Keys.S)
            {
                this.SaveFile(true);
            }

            if (e.Control && e.KeyCode == Keys.F)
            {
                if (this.fontDialog.ShowDialog() == DialogResult.OK)
                {
                    foreach (TabPage tab in tabs.TabPages)
                    {
                        if (tab != addTabButton)
                        {
                            RichTextBoxCore rtb = ((RichTextBoxTabPage)tab).TextBox;

                            if (Path.GetExtension(rtb.fileName) != ".rtf")
                            {
                                rtb.Font = this.fontDialog.Font;
                            }
                        }
                    }
                }
            }

            if (e.Control && e.KeyCode == Keys.P)
            {
                if (printDialog.ShowDialog() == DialogResult.OK)
                {
                    printDocument.Print();
                }
            }
        }