Imports System.Drawing.Drawing2D
Public Class Form1
Dim Minute1 As Bitmap
Dim Second1 As Bitmap
Dim HourP As Bitmap
Dim Height1, Width1 As Integer
Friend WithEvents PictureBox1 As New System.Windows.Forms.PictureBox
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(316, 338)
Me.Timer1.Interval = 1000
Me.Timer1.Enabled = True
Me.PictureBox1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
Me.PictureBox1.Location = New System.Drawing.Point(-1, 0)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(300, 300)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
Me.PictureBox1.BackColor = Color.White
Me.Controls.Add(PictureBox1)
Me.Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Height1 = PictureBox1.Size.Height
Width1 = PictureBox1.Size.Width
Dim TM As Bitmap = New Bitmap(Height1, Width1)
Dim G As Graphics = Graphics.FromImage(TM)
PictureBox1.Controls.Clear()
Dim x1 As Integer = Height1 / 2
Dim y1 As Integer = Width1 / 2
G.TranslateTransform(x1, y1)
'หน้าปัด
Dim PenBlack As New Pen(Brushes.Red, 5)
Dim PenGreen As New Pen(Brushes.Green, 4)
For i As Integer = 1 To 60
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.RotateTransform(i * 6)
G.DrawLine(PenGreen, 0, -131, 0, -135)
Next
For i As Integer = 1 To 12
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.RotateTransform(i * 30)
G.DrawLine(PenBlack, 0, -115, 0, -145)
Next
Dim HPen As New Pen(Color.Blue, 15) 'เข็มสั้น
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.RotateTransform(((Now.Hour * 30) + (Now.Minute * 0.5)))
G.DrawLine(HPen, 0, 20, 0, -100)
Dim MinPen As New Pen(Color.Black, 10) 'เข็มยาว
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.RotateTransform((((Now.Minute * 60) + Now.Second) * 0.1))
G.DrawLine(MinPen, 0, 20, 0, -120)
Dim SecPen As New Pen(Color.Red, 2) 'เข็มวินาที
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.RotateTransform((Now.Second * 6))
G.DrawLine(SecPen, 0, 20, 0, -138)
Dim PointPen As New Pen(Color.Black, 2) 'หมุด
Dim PointPenRed As New Pen(Color.Red, 12)
G.ResetTransform()
G.TranslateTransform(x1, y1)
G.DrawEllipse(PointPenRed, -2, -2, 4, 4)
G.DrawEllipse(PointPen, -2, -2, 4, 4)
PictureBox1.Image = TM
' it is other coding
Dim p As New System.Drawing.Pen(Color.Red, 10)
Dim s As System.Drawing.Graphics
PictureBox1.Refresh()
s = PictureBox1.CreateGraphics
s.DrawEllipse(p, 5, 5, 290, 290)
End Sub
End Class
Subscribe to:
Post Comments (Atom)
Create Analog Clock In Vb.Net >>>>> Download Now
ReplyDelete>>>>> Download Full
Create Analog Clock In Vb.Net >>>>> Download LINK
>>>>> Download Now
Create Analog Clock In Vb.Net >>>>> Download Full
>>>>> Download LINK He