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

📄 notepadform.vb

📁 Pocket Image Editor v0.1源码(.NET源码)
💻 VB
字号:
'
' A basic Notepad application for Smartphone to demonstrate file handling dialogs
'
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms

'/ <summary>
'/ A basic text file viewer
'/ </summary>
Namespace OpenNETCF.Applications

    Public Class NotepadForm
        Inherits System.Windows.Forms.Form
        Private txtContents As System.Windows.Forms.TextBox
        Private WithEvents mnuOpen As System.Windows.Forms.MenuItem
        Private mainMenu1 As System.Windows.Forms.MainMenu
        Private mnuMenu As System.Windows.Forms.MenuItem
        Private WithEvents mnuQuit As System.Windows.Forms.MenuItem

        'create an open file dialog
        Private ofd As SmartphoneDialogs.OpenNETCF.Windows.Forms.OpenFileDialog

        '/ <summary>
        '/ </summary>
        Public Sub New()
            '
            ' Required for Windows Form Designer support
            '
            InitializeComponent()

            '
            ' TODO: Add any constructor code after InitializeComponent call
            '
            ofd = New SmartphoneDialogs.OpenNETCF.Windows.Forms.OpenFileDialog
        End Sub 'New


        '/ <summary>
        '/ Clean up any resources being used.
        '/ </summary>
        Protected Overloads Sub Dispose(ByVal disposing As Boolean)
            MyBase.Dispose(disposing)
        End Sub 'Dispose
#Region "Windows Form Designer generated code"

        '/ <summary>
        '/ Required method for Designer support - do not modify
        '/ the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()
            Me.mainMenu1 = New System.Windows.Forms.MainMenu
            Me.mnuOpen = New System.Windows.Forms.MenuItem
            Me.txtContents = New System.Windows.Forms.TextBox
            Me.mnuMenu = New System.Windows.Forms.MenuItem
            Me.mnuQuit = New System.Windows.Forms.MenuItem
            ' 
            ' mainMenu1
            ' 
            Me.mainMenu1.MenuItems.Add(Me.mnuOpen)
            Me.mainMenu1.MenuItems.Add(Me.mnuMenu)
            ' 
            ' mnuOpen
            ' 
            Me.mnuOpen.Text = "Open"
            ' 
            ' txtContents
            ' 
            Me.txtContents.AcceptsReturn = True
            Me.txtContents.AcceptsTab = True
            Me.txtContents.Multiline = True
            Me.txtContents.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
            Me.txtContents.Size = New System.Drawing.Size(176, 176)
            Me.txtContents.Text = ""
            ' 
            ' mnuMenu
            ' 
            Me.mnuMenu.MenuItems.Add(Me.mnuQuit)
            Me.mnuMenu.Text = "Menu"
            ' 
            ' mnuQuit
            ' 
            Me.mnuQuit.Text = "Quit"
            ' 
            ' NotepadForm
            ' 
            Me.ControlBox = False
            Me.Controls.Add(txtContents)
            Me.MaximizeBox = False
            Me.Menu = Me.mainMenu1
            Me.MinimizeBox = False
            Me.Text = "Notepad"
        End Sub 'InitializeComponent 
#End Region

        '/ <summary>
        '/ The main entry point for the application.
        '/ </summary>
        Shared Sub Main()
            Application.Run(New NotepadForm)
        End Sub 'Main

        Private Sub mnuOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuOpen.Click
            ofd.Reset()

            'set dialog to display only text files
            ofd.Filter = "Text Files|*.txt;*.xml;*.htm"
            ofd.FilterIndex = 1

            'show dialog to user
            If ofd.ShowDialog() = DialogResult.OK Then
                'open stream to file
                Dim sr As StreamReader = File.OpenText(ofd.FileName)
                'read entire file into textbox
                txtContents.Text = sr.ReadToEnd()
                'close streamreader
                sr.Close()
            End If
        End Sub 'mnuOpen_Click

        Private Sub mnuQuit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuQuit.Click
            'close application
            Application.Exit()
        End Sub 'mnuQuit_Click
    End Class 'NotepadForm
End Namespace

⌨️ 快捷键说明

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