Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Graphic Display Scrolling
Author:
Michel Renaud
Submitted:
4/1/2012
Version:
VB 2010
Compatibility:
VB 2010
Category:
Graphics
Views:
8677
Graphic Display Scrolling using system drawing drawing2d.
Declarations:
Imports System.Drawing.Drawing2D
Code:
Imports System.Drawing.Drawing2D Public Class Form1 Dim g As Graphics = Me.CreateGraphics Dim offsetvalue As Integer = 150 Dim x, y, cx, cy As Integer Dim rd As New Random Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click Application.Exit() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Me.CenterToParent() Me.Timer1.Start() ret = 10 x = rd.Next(0, Me.Width) y = rd.Next(0, Me.Height) cx = rd.Next(5, 10) cy = rd.Next(5, 10) End Sub Dim ret As Integer ' Dim angle As Integer Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim g As Graphics = e.Graphics g.Clear(Color.Black) Static angle As Integer x += cx y += cy If x > Me.Width - 150 Then cx = -cx ElseIf x < 0 Then cx = -cx End If If y > Me.Height - 150 Then cy = -cy ElseIf y < 0 Then cy = -cy End If Dim path As GraphicsPath = New GraphicsPath() Dim rect As RectangleF = New RectangleF(x, y, 160, 100) Dim format As StringFormat = New StringFormat() format.Alignment = StringAlignment.Center format.LineAlignment = StringAlignment.Center path.AddRectangle(rect) path.AddString("Michel Renaud", Me.Font.FontFamily, CInt(Me.Font.Style), Me.Font.Height + 15, rect, format) angle += ret If angle > 360 Then ret = -ret ElseIf angle < 0 Then ret = -ret End If g.DrawPath(New Pen(Brushes.Black, 4), path) g.FillPath(Brushes.Azure, path) ' Me.Region = New Region(path) Dim matrix As Matrix = New Matrix() matrix.Translate(0, 0) matrix.RotateAt(angle, New PointF(Me.Width / 2 + (50), Me.Height / 2 - (50 / 2))) path.Transform(matrix) g.DrawPath(New Pen(Brushes.Red, 4), path) g.FillPath(Brushes.Yellow, path) g.DrawPath(Pens.Black, path) 'Me.Region = New Region(path) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Invalidate() End Sub End Class
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement