Imports System
Imports System.Data
Imports System.Collections
Imports System.Windows.Forms
Public Class MainClass
Shared Sub Main()
Dim form1 As Form = New TextEditor()
Application.Run(form1)
End Sub
End Class
Public Class TextEditor
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents statusBar As System.Windows.Forms.StatusBar
Friend WithEvents toolbar As System.Windows.Forms.ToolBar
Friend WithEvents toolbarClear As System.Windows.Forms.ToolBarButton
Friend WithEvents toolbarRed As System.Windows.Forms.ToolBarButton
Friend WithEvents toolbarBlue As System.Windows.Forms.ToolBarButton
Friend WithEvents toolbarUppercase As System.Windows.Forms.ToolBarButton
Friend WithEvents toolbarLowercase As System.Windows.Forms.ToolBarButton
Friend WithEvents toolbarHelpAbout As System.Windows.Forms.ToolBarButton
Friend WithEvents imglstToolbar As System.Windows.Forms.ImageList
Friend WithEvents txtEdit As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
' Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(TextEditor))
Me.statusBar = New System.Windows.Forms.StatusBar()
Me.toolbar = New System.Windows.Forms.ToolBar()
Me.toolbarClear = New System.Windows.Forms.ToolBarButton()
Me.toolbarRed = New System.Windows.Forms.ToolBarButton()
Me.toolbarBlue = New System.Windows.Forms.ToolBarButton()
Me.toolbarUppercase = New System.Windows.Forms.ToolBarButton()
Me.toolbarLowercase = New System.Windows.Forms.ToolBarButton()
Me.toolbarHelpAbout = New System.Windows.Forms.ToolBarButton()
Me.imglstToolbar = New System.Windows.Forms.ImageList(Me.components)
Me.txtEdit = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'statusBar
'
Me.statusBar.Location = New System.Drawing.Point(0, 397)
Me.statusBar.Name = "statusBar"
Me.statusBar.Size = New System.Drawing.Size(584, 16)
Me.statusBar.TabIndex = 2
'
'toolbar
'
Me.toolbar.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.toolbarClear, Me.toolbarRed, Me.toolbarBlue, Me.toolbarUppercase, Me.toolbarLowercase, Me.toolbarHelpAbout})
Me.toolbar.DropDownArrows = True
Me.toolbar.ImageList = Me.imglstToolbar
Me.toolbar.Name = "toolbar"
Me.toolbar.ShowToolTips = True
Me.toolbar.Size = New System.Drawing.Size(584, 39)
Me.toolbar.TabIndex = 1
'
'toolbarClear
'
Me.toolbarClear.ImageIndex = 4
Me.toolbarClear.Text = "Clear"
Me.toolbarClear.ToolTipText = "Clear the text box"
'
'toolbarRed
'
Me.toolbarRed.ImageIndex = 2
Me.toolbarRed.Text = "Red"
Me.toolbarRed.ToolTipText = "Make the text red"
'
'toolbarBlue
'
Me.toolbarBlue.ImageIndex = 3
Me.toolbarBlue.Text = "Blue"
Me.toolbarBlue.ToolTipText = "Make the text blue"
'
'toolbarUppercase
'
Me.toolbarUppercase.ImageIndex = 0
Me.toolbarUppercase.Text = "Uppercase"
Me.toolbarUppercase.ToolTipText = "Make the text uppercase"
'
'toolbarLowercase
'
Me.toolbarLowercase.ImageIndex = 1
Me.toolbarLowercase.Text = "Lowercase"
Me.toolbarLowercase.ToolTipText = "Make the toolbar lowercase"
'
'toolbarHelpAbout
'
Me.toolbarHelpAbout.ImageIndex = 5
Me.toolbarHelpAbout.Text = "About"
Me.toolbarHelpAbout.ToolTipText = "Display the About box"
'
'imglstToolbar
'
Me.imglstToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
Me.imglstToolbar.ImageSize = New System.Drawing.Size(16, 16)
' Me.imglstToolbar.ImageStream = CType(resources.GetObject("imglstToolbar.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.imglstToolbar.TransparentColor = System.Drawing.Color.Transparent
'
'txtEdit
'
Me.txtEdit.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtEdit.Location = New System.Drawing.Point(8, 48)
Me.txtEdit.Multiline = True
Me.txtEdit.Name = "txtEdit"
Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtEdit.Size = New System.Drawing.Size(568, 340)
Me.txtEdit.TabIndex = 1
Me.txtEdit.Text = ""
'
'TextEditor
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(584, 413)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtEdit, Me.toolbar, Me.statusBar})
Me.Name = "TextEditor"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Public Property StatusText() As String
Get
Return statusBar.Text
End Get
Set(ByVal Value As String)
statusBar.Text = Value
End Set
End Property
Public Property EditText() As String
Get
Return txtEdit.Text
End Get
Set(ByVal Value As String)
txtEdit.Text = Value
End Set
End Property
Public Sub ClearEditBox()
EditText = ""
txtEdit.ForeColor = System.Drawing.Color.Black
StatusText = "Text box cleared"
End Sub
Private Sub txtEdit_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEdit.TextChanged
StatusText = "Ready"
End Sub
Private Sub toolbar_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles toolbar.ButtonClick
If e.Button Is toolbarClear Then
ClearEditBox()
End If
If e.Button Is toolbarRed Then
RedText()
End If
If e.Button Is toolbarBlue Then
BlueText()
End If
If e.Button Is toolbarUppercase Then
UppercaseText()
End If
If e.Button Is toolbarLowercase Then
LowercaseText()
End If
If e.Button Is toolbarHelpAbout Then
ShowAboutBox()
End If
End Sub
Public Sub UppercaseText()
EditText = EditText.ToUpper
StatusText = "The text is all uppercase"
End Sub
Public Sub LowercaseText()
EditText = EditText.ToLower
StatusText = "The text is all lowercase"
End Sub
Public Sub RedText()
txtEdit.ForeColor = System.Drawing.Color.Red
StatusText = "The text is red"
End Sub
Public Sub BlueText()
txtEdit.ForeColor = System.Drawing.Color.Blue
StatusText = "The text is blue"
End Sub
Public Sub ShowAboutBox()
MessageBox.Show("About")
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
|