frmscaling.vb

来自「Microsoft Mobile Development Handbook的代码」· VB 代码 · 共 32 行

VB
32
字号
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Drawing

Namespace CodeForChapter2
  Public Partial Class frmScaling
	  Inherits Form
	Public Sub New()
	  InitializeComponent()
	End Sub

	' run this project on both VGA and non-VGA devices
	Private Sub frmScaling_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
	  Dim left As Integer = 5, right As Integer = 5, width As Integer = 200, height As Integer = 200

	  Dim r As Rectangle = New Rectangle(CInt(Fix(left * Program.ScaleFactor)), CInt(Fix(right * Program.ScaleFactor)), CInt(Fix(width * Program.ScaleFactor)), CInt(Fix(height * Program.ScaleFactor)))

	  Dim thickness As Single = 2
	  Dim p As Pen = New Pen(Color.Red, thickness * Program.ScaleFactor)

	  e.Graphics.DrawEllipse(p, r)

	  Dim b As Brush = New SolidBrush(Color.Blue)
	  Dim x As Single = 75, y As Single = 100
	  e.Graphics.DrawString("scales well", Me.Font, b, x * Program.ScaleFactor, y * Program.ScaleFactor)

	  p.Dispose()
	  b.Dispose()
	End Sub
  End Class
End Namespace

⌨️ 快捷键说明

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