⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmeditor.vb

📁 一个简单的文本编辑器。
💻 VB
📖 第 1 页 / 共 4 页
字号:

Imports System.IO
Imports System.Drawing.Printing

'文件格式常数
Public Enum DocumentType
    TXTDocument
    RTFDocument
End Enum

Public Class frmEditor
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化
        Init()

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileNew As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileOpen As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileSave As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileSaveAs As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileExit As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem33 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuViewToolBar As System.Windows.Forms.MenuItem
    Friend WithEvents mnuViewStatusBar As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem14 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem13 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEditSelectAll As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEditClear As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem16 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEditCut As System.Windows.Forms.MenuItem
    Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem20 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem23 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem25 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem26 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem29 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem30 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
    Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
    Friend WithEvents btnNew As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnOpen As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnSave As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnCopy As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnCut As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnPaste As System.Windows.Forms.ToolBarButton
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents StatusBarPanel1 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel2 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel3 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents mnuFormatFont As System.Windows.Forms.MenuItem
    Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog
    Friend WithEvents btnBold As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnItalic As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnUnderLine As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog
    Friend WithEvents mnuFormatColor As System.Windows.Forms.MenuItem
    Friend WithEvents btnFontSizeUp As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnFontSizeDown As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnFontColor As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnBullet As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnHangIndentUp As System.Windows.Forms.ToolBarButton
    Friend WithEvents mnuIndentUp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuIndentDown As System.Windows.Forms.MenuItem
    Friend WithEvents mnuHangingIndentUp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuHangingIndentDown As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem27 As System.Windows.Forms.MenuItem
    Friend WithEvents btnIndentDown As System.Windows.Forms.ToolBarButton
    Friend WithEvents mnuSetCharOffsetUp As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSetCharOffsetDown As System.Windows.Forms.MenuItem
    Friend WithEvents mnuCancelCharOffset As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem17 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem15 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuLeftAligment As System.Windows.Forms.MenuItem
    Friend WithEvents mnuRightAligment As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAligmentMiddle As System.Windows.Forms.MenuItem
    Friend WithEvents btnAligmentLeft As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnAligmentRight As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnAligmentMiddle As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
    Friend WithEvents mnuPrintPreview As System.Windows.Forms.MenuItem
    Friend WithEvents mnuPrintSetup As System.Windows.Forms.MenuItem
    Friend WithEvents mnuPrint As System.Windows.Forms.MenuItem
    Friend WithEvents btnUndo As System.Windows.Forms.ToolBarButton
    Friend WithEvents mnuFind As System.Windows.Forms.MenuItem
    Friend WithEvents btnFind As System.Windows.Forms.ToolBarButton
    Friend WithEvents mnuViewZoom As System.Windows.Forms.MenuItem
    Friend WithEvents mnuZoomIn As System.Windows.Forms.MenuItem
    Friend WithEvents mnuZoomOut As System.Windows.Forms.MenuItem
    Friend WithEvents btnZoomIn As System.Windows.Forms.ToolBarButton
    Friend WithEvents btnZoomOut As System.Windows.Forms.ToolBarButton
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents mnuInsertLineNum As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
    Friend WithEvents btnLineNum As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton4 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton5 As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarButton6 As System.Windows.Forms.ToolBarButton
    Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmEditor))
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.mnuFile = New System.Windows.Forms.MenuItem
        Me.mnuFileNew = New System.Windows.Forms.MenuItem
        Me.mnuFileOpen = New System.Windows.Forms.MenuItem
        Me.mnuFileSave = New System.Windows.Forms.MenuItem
        Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem
        Me.MenuItem5 = New System.Windows.Forms.MenuItem
        Me.mnuPrintPreview = New System.Windows.Forms.MenuItem
        Me.mnuPrintSetup = New System.Windows.Forms.MenuItem
        Me.mnuPrint = New System.Windows.Forms.MenuItem
        Me.MenuItem11 = New System.Windows.Forms.MenuItem
        Me.mnuFileExit = New System.Windows.Forms.MenuItem
        Me.MenuItem33 = New System.Windows.Forms.MenuItem
        Me.mnuViewToolBar = New System.Windows.Forms.MenuItem
        Me.mnuViewStatusBar = New System.Windows.Forms.MenuItem
        Me.MenuItem14 = New System.Windows.Forms.MenuItem
        Me.mnuViewZoom = New System.Windows.Forms.MenuItem
        Me.mnuZoomIn = New System.Windows.Forms.MenuItem
        Me.mnuZoomOut = New System.Windows.Forms.MenuItem
        Me.MenuItem13 = New System.Windows.Forms.MenuItem
        Me.mnuEditSelectAll = New System.Windows.Forms.MenuItem
        Me.mnuEditClear = New System.Windows.Forms.MenuItem
        Me.MenuItem16 = New System.Windows.Forms.MenuItem
        Me.mnuEditCopy = New System.Windows.Forms.MenuItem
        Me.mnuEditCut = New System.Windows.Forms.MenuItem
        Me.mnuEditPaste = New System.Windows.Forms.MenuItem
        Me.MenuItem20 = New System.Windows.Forms.MenuItem
        Me.mnuFind = New System.Windows.Forms.MenuItem
        Me.MenuItem23 = New System.Windows.Forms.MenuItem
        Me.MenuItem25 = New System.Windows.Forms.MenuItem
        Me.MenuItem26 = New System.Windows.Forms.MenuItem
        Me.mnuFormatFont = New System.Windows.Forms.MenuItem
        Me.mnuFormatColor = New System.Windows.Forms.MenuItem
        Me.MenuItem29 = New System.Windows.Forms.MenuItem
        Me.MenuItem30 = New System.Windows.Forms.MenuItem
        Me.mnuIndentUp = New System.Windows.Forms.MenuItem
        Me.mnuIndentDown = New System.Windows.Forms.MenuItem
        Me.MenuItem27 = New System.Windows.Forms.MenuItem
        Me.mnuHangingIndentUp = New System.Windows.Forms.MenuItem
        Me.mnuHangingIndentDown = New System.Windows.Forms.MenuItem
        Me.MenuItem17 = New System.Windows.Forms.MenuItem
        Me.mnuSetCharOffsetUp = New System.Windows.Forms.MenuItem
        Me.mnuSetCharOffsetDown = New System.Windows.Forms.MenuItem
        Me.mnuCancelCharOffset = New System.Windows.Forms.MenuItem
        Me.MenuItem15 = New System.Windows.Forms.MenuItem
        Me.mnuLeftAligment = New System.Windows.Forms.MenuItem
        Me.mnuRightAligment = New System.Windows.Forms.MenuItem
        Me.mnuAligmentMiddle = New System.Windows.Forms.MenuItem
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.mnuInsertLineNum = New System.Windows.Forms.MenuItem
        Me.MenuItem4 = New System.Windows.Forms.MenuItem
        Me.mnuAbout = New System.Windows.Forms.MenuItem
        Me.ToolBar1 = New System.Windows.Forms.ToolBar
        Me.btnNew = New System.Windows.Forms.ToolBarButton
        Me.btnOpen = New System.Windows.Forms.ToolBarButton
        Me.btnSave = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
        Me.btnCopy = New System.Windows.Forms.ToolBarButton
        Me.btnCut = New System.Windows.Forms.ToolBarButton
        Me.btnPaste = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
        Me.btnBold = New System.Windows.Forms.ToolBarButton
        Me.btnItalic = New System.Windows.Forms.ToolBarButton
        Me.btnUnderLine = New System.Windows.Forms.ToolBarButton
        Me.btnFontSizeUp = New System.Windows.Forms.ToolBarButton
        Me.btnFontSizeDown = New System.Windows.Forms.ToolBarButton
        Me.btnFontColor = New System.Windows.Forms.ToolBarButton
        Me.btnBullet = New System.Windows.Forms.ToolBarButton
        Me.btnLineNum = New System.Windows.Forms.ToolBarButton
        Me.btnHangIndentUp = New System.Windows.Forms.ToolBarButton
        Me.btnIndentDown = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton
        Me.btnUndo = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton
        Me.btnAligmentLeft = New System.Windows.Forms.ToolBarButton
        Me.btnAligmentRight = New System.Windows.Forms.ToolBarButton
        Me.btnAligmentMiddle = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton
        Me.btnFind = New System.Windows.Forms.ToolBarButton
        Me.ToolBarButton6 = New System.Windows.Forms.ToolBarButton
        Me.btnZoomIn = New System.Windows.Forms.ToolBarButton
        Me.btnZoomOut = New System.Windows.Forms.ToolBarButton
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.StatusBar1 = New System.Windows.Forms.StatusBar
        Me.StatusBarPanel1 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel2 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel3 = New System.Windows.Forms.StatusBarPanel
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.FontDialog1 = New System.Windows.Forms.FontDialog
        Me.ColorDialog1 = New System.Windows.Forms.ColorDialog
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
        CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel3, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.MenuItem33, Me.MenuItem13, Me.MenuItem26, Me.MenuItem1, Me.MenuItem4})
        '
        'mnuFile
        '
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFileNew, Me.mnuFileOpen, Me.mnuFileSave, Me.mnuFileSaveAs, Me.MenuItem5, Me.mnuPrintPreview, Me.mnuPrintSetup, Me.mnuPrint, Me.MenuItem11, Me.mnuFileExit})
        Me.mnuFile.Text = "文件"
        '
        'mnuFileNew
        '
        Me.mnuFileNew.Index = 0
        Me.mnuFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN
        Me.mnuFileNew.Text = "新建文档(Ctrl-N)"
        '
        'mnuFileOpen
        '
        Me.mnuFileOpen.Index = 1
        Me.mnuFileOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlN
        Me.mnuFileOpen.Text = "打开文档(Ctrl-O)"
        '
        'mnuFileSave
        '
        Me.mnuFileSave.Index = 2
        Me.mnuFileSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS
        Me.mnuFileSave.Text = "保存文档(Ctrl-S)"
        '
        'mnuFileSaveAs
        '
        Me.mnuFileSaveAs.Index = 3
        Me.mnuFileSaveAs.Text = "另存为…"
        '
        'MenuItem5
        '
        Me.MenuItem5.Index = 4
        Me.MenuItem5.Text = "-"
        '
        'mnuPrintPreview
        '
        Me.mnuPrintPreview.Index = 5
        Me.mnuPrintPreview.Text = "打印预览"
        '
        'mnuPrintSetup
        '
        Me.mnuPrintSetup.Index = 6
        Me.mnuPrintSetup.Text = "打印设置"
        '
        'mnuPrint
        '
        Me.mnuPrint.Index = 7
        Me.mnuPrint.Text = "打  印…"
        '
        'MenuItem11
        '
        Me.MenuItem11.Index = 8
        Me.MenuItem11.Text = "-"
        '
        'mnuFileExit
        '
        Me.mnuFileExit.Index = 9
        Me.mnuFileExit.Text = "退    出"
        '
        'MenuItem33
        '
        Me.MenuItem33.Index = 1
        Me.MenuItem33.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuViewToolBar, Me.mnuViewStatusBar, Me.MenuItem14, Me.mnuViewZoom})
        Me.MenuItem33.Text = "视图"
        '
        'mnuViewToolBar
        '
        Me.mnuViewToolBar.Checked = True
        Me.mnuViewToolBar.Index = 0
        Me.mnuViewToolBar.Text = "工具栏"
        '
        'mnuViewStatusBar
        '
        Me.mnuViewStatusBar.Checked = True
        Me.mnuViewStatusBar.Index = 1
        Me.mnuViewStatusBar.Text = "状态条"
        '
        'MenuItem14
        '
        Me.MenuItem14.Index = 2
        Me.MenuItem14.Text = "-"
        '
        'mnuViewZoom
        '
        Me.mnuViewZoom.Index = 3
        Me.mnuViewZoom.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuZoomIn, Me.mnuZoomOut})
        Me.mnuViewZoom.Text = "缩放"
        '
        'mnuZoomIn
        '
        Me.mnuZoomIn.Index = 0
        Me.mnuZoomIn.Text = "放大"
        '
        'mnuZoomOut
        '
        Me.mnuZoomOut.Index = 1
        Me.mnuZoomOut.Text = "缩小"
        '
        'MenuItem13
        '
        Me.MenuItem13.Index = 2
        Me.MenuItem13.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditSelectAll, Me.mnuEditClear, Me.MenuItem16, Me.mnuEditCopy, Me.mnuEditCut, Me.mnuEditPaste, Me.MenuItem20, Me.mnuFind, Me.MenuItem23, Me.MenuItem25})
        Me.MenuItem13.Text = "编辑"
        '
        'mnuEditSelectAll
        '
        Me.mnuEditSelectAll.Index = 0
        Me.mnuEditSelectAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA
        Me.mnuEditSelectAll.Text = "全选(Ctrl-A)"
        '
        'mnuEditClear
        '
        Me.mnuEditClear.Index = 1
        Me.mnuEditClear.Text = "清空"
        '
        'MenuItem16
        '
        Me.MenuItem16.Index = 2
        Me.MenuItem16.Text = "-"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -