Use Scroll Bar to set rotate, X position and repaint : ScrollBar « GUI « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VB.Net » GUI » ScrollBarScreenshots 
Use Scroll Bar to set rotate, X position and repaint
Use Scroll Bar to set rotate, X position and repaint

Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text
Imports System.Drawing.Imaging

Public Class MainClass

  Shared Sub Main()
     Dim form1 As Form1 = new Form1
     Application.Run(form1)
  End Sub
  
End Class


Public Class Form1
  Inherits System.Windows.Forms.Form

  Dim XlateY As Int32
  Dim Angle As Single
  Dim DrawingRect As Rectangle = New Rectangle(2525225225)

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    Angle = 0
    Xlatey = 0
    xlate.Minimum = -50
    xlate.Maximum = 50
    xlate.SmallChange = 1
    xlate.LargeChange = 5
    xlate.Value = 0

    rotate.Minimum = -180
    rotate.Maximum = 180
    rotate.SmallChange = 1
    rotate.LargeChange = 10
    rotate.Value = 0

    Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
    Me.SetStyle(ControlStyles.DoubleBuffer, True)
    Me.SetStyle(ControlStyles.UserPaint, True)

  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 NothingThen
        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 xlate As System.Windows.Forms.VScrollBar
  Friend WithEvents rotate As System.Windows.Forms.HScrollBar
  <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
    Me.xlate = New System.Windows.Forms.VScrollBar()
    Me.rotate = New System.Windows.Forms.HScrollBar()
    Me.SuspendLayout()
    '
    'xlate
    '
    Me.xlate.Location = New System.Drawing.Point(26432)
    Me.xlate.Name = "xlate"
    Me.xlate.Size = New System.Drawing.Size(16200)
    Me.xlate.TabIndex = 0
    '
    'rotate
    '
    Me.rotate.Location = New System.Drawing.Point(8240)
    Me.rotate.Name = "rotate"
    Me.rotate.Size = New System.Drawing.Size(24016)
    Me.rotate.TabIndex = 1
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(513)
    Me.ClientSize = New System.Drawing.Size(292273)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.rotate, Me.xlate})
    Me.MaximizeBox = False
    Me.MinimizeBox = False
    Me.Name = "Form1"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Form1"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub Form1_Load(ByVal sender As System.Object, _
                         ByVal e As System.EventArgs_
                         Handles MyBase.Load

  End Sub

  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    Dim As Graphics = e.Graphics

    G.SmoothingMode = SmoothingMode.AntiAlias

    ' Create a graphics path, add a rectangle, set colors
    Dim Path As New GraphicsPath()
    Path.AddRectangle(New Rectangle(7510010075))
    Dim Pts As PointF() = Path.PathPoints
    Dim As New PathGradientBrush(Pts)

    'translate the brush
    Dim As New Matrix()
    m.Translate(0, Xlatey, MatrixOrder.Append)
    m.RotateAt(Angle, B.CenterPoint, MatrixOrder.Append)
    B.MultiplyTransform(m, MatrixOrder.Append)
    G.FillRectangle(B, DrawingRect)

  End Sub

  Private Sub xlate_Scroll(ByVal sender As System.Object, _
                           ByVal e As System.Windows.Forms.ScrollEventArgs_
                           Handles xlate.Scroll

    Xlatey = xlate.Value
    Me.Invalidate(DrawingRect)

  End Sub

  Private Sub rotate_Scroll(ByVal sender As System.Object, _
                            ByVal e As System.Windows.Forms.ScrollEventArgs_
                            Handles rotate.Scroll

    Angle = rotate.Value
    Me.Invalidate(DrawingRect)

  End Sub
End Class

           
       
Related examples in the same category
1. Get Value from Vertical Scroll BarGet Value from Vertical Scroll Bar
2. Get HScrollBar ValueGet HScrollBar Value
3. ScrollBar Demo: get valueScrollBar Demo: get value
ww__w___.__j_a__v_a2__s_.co___m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.