Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class TrackBarScale
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayScale.Scroll
DrawingArea.Invalidate()
End Sub
Private Sub DrawingArea_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DrawingArea.Paint
Dim titleFont As Font
Dim mainFont As Font
Dim titleArea As Rectangle
Dim textArea As Rectangle
Dim titleFormat As StringFormat
Const MainTitle As String = "www.java2s.com"
titleFont = New Font("Arial", 16, FontStyle.Bold)
mainFont = New Font("Arial", 12, FontStyle.Regular)
titleArea = New Rectangle(0, 0, DrawingArea.ClientRectangle.Width, titleFont.Height)
textArea = New Rectangle(0, titleFont.Height * 1.4, DrawingArea.ClientRectangle.Width, DrawingArea.ClientRectangle.Height - (titleFont.Height * 1.4))
e.Graphics.ScaleTransform(DisplayScale.Value, DisplayScale.Value)
titleFormat = New StringFormat()
titleFormat.Alignment = StringAlignment.Center
e.Graphics.DrawString(MainTitle, titleFont, Brushes.Black, titleArea, titleFormat)
titleFormat.Dispose()
mainFont.Dispose()
titleFont.Dispose()
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.LabelText = New System.Windows.Forms.Label
Me.DisplayText = New System.Windows.Forms.TextBox
Me.LabelScale = New System.Windows.Forms.Label
Me.DisplayScale = New System.Windows.Forms.TrackBar
Me.ActDisplay = New System.Windows.Forms.Button
Me.DrawingArea = New System.Windows.Forms.PictureBox
CType(Me.DisplayScale, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DrawingArea, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'LabelText
'
Me.LabelText.AutoSize = True
Me.LabelText.Location = New System.Drawing.Point(8, 8)
Me.LabelText.Name = "LabelText"
Me.LabelText.Size = New System.Drawing.Size(31, 13)
Me.LabelText.TabIndex = 0
Me.LabelText.Text = "&Text:"
'
'LabelScale
'
Me.LabelScale.AutoSize = True
Me.LabelScale.Location = New System.Drawing.Point(8, 144)
Me.LabelScale.Name = "LabelScale"
Me.LabelScale.Size = New System.Drawing.Size(37, 13)
Me.LabelScale.TabIndex = 2
Me.LabelScale.Text = "&Scale:"
'
'DisplayScale
'
Me.DisplayScale.Location = New System.Drawing.Point(48, 136)
Me.DisplayScale.Maximum = 5
Me.DisplayScale.Minimum = 1
Me.DisplayScale.Name = "DisplayScale"
Me.DisplayScale.Size = New System.Drawing.Size(104, 45)
Me.DisplayScale.TabIndex = 3
Me.DisplayScale.Value = 1
'
'DrawingArea
'
Me.DrawingArea.BackColor = System.Drawing.Color.White
Me.DrawingArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.DrawingArea.Location = New System.Drawing.Point(192, 8)
Me.DrawingArea.Name = "DrawingArea"
Me.DrawingArea.Size = New System.Drawing.Size(328, 208)
Me.DrawingArea.TabIndex = 5
Me.DrawingArea.TabStop = False
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(532, 227)
Me.Controls.Add(Me.DrawingArea)
Me.Controls.Add(Me.DisplayScale)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Text = "Displaying Scaled Content"
CType(Me.DisplayScale, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DrawingArea, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents LabelText As System.Windows.Forms.Label
Friend WithEvents DisplayText As System.Windows.Forms.TextBox
Friend WithEvents LabelScale As System.Windows.Forms.Label
Friend WithEvents DisplayScale As System.Windows.Forms.TrackBar
Friend WithEvents ActDisplay As System.Windows.Forms.Button
Friend WithEvents DrawingArea As System.Windows.Forms.PictureBox
End Class