PenAlignment Illustration : Pen Alignment « 2D Graphics « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
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
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » 2D Graphics » Pen Alignment 
15. 60. 1. PenAlignment Illustration
PenAlignment Illustration
 

Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Drawing2D

public class PenAlignmentComboBox
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private penColor As Color = Color.Red
    Dim penWidth As Integer = 5

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

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

        'Add any initialization after the InitializeComponent() call

    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 Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents numericUpDown1 As System.Windows.Forms.NumericUpDown
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents ColorBtn As System.Windows.Forms.Button
    Friend WithEvents Draw As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.numericUpDown1 = New System.Windows.Forms.NumericUpDown
        Me.Label3 = New System.Windows.Forms.Label
        Me.ColorBtn = New System.Windows.Forms.Button
        Me.Draw = New System.Windows.Forms.Button
        CType(Me.numericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(816)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(8023)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Pen Alignment"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(856)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(7223)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "Pen Width"
        '
        'ComboBox1
        '
        Me.ComboBox1.Location = New System.Drawing.Point(9616)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(12121)
        Me.ComboBox1.TabIndex = 2
        Me.ComboBox1.Text = "ComboBox1"
        '
        'numericUpDown1
        '
        Me.numericUpDown1.Location = New System.Drawing.Point(9656)
        Me.numericUpDown1.Name = "numericUpDown1"
        Me.numericUpDown1.Size = New System.Drawing.Size(3220)
        Me.numericUpDown1.TabIndex = 7
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(13656)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(5623)
        Me.Label3.TabIndex = 8
        Me.Label3.Text = "Pen Color"
        '
        'ColorBtn
        '
        Me.ColorBtn.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(0, Byte), CType(0, Byte))
        Me.ColorBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ColorBtn.Location = New System.Drawing.Point(19256)
        Me.ColorBtn.Name = "ColorBtn"
        Me.ColorBtn.Size = New System.Drawing.Size(2416)
        Me.ColorBtn.TabIndex = 9
        '
        'Draw
        '
        Me.Draw.Location = New System.Drawing.Point(56104)
        Me.Draw.Name = "Draw"
        Me.Draw.Size = New System.Drawing.Size(12040)
        Me.Draw.TabIndex = 10
        Me.Draw.Text = "DrawGraphics"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(360349)
        Me.Controls.Add(Me.Draw)
        Me.Controls.Add(Me.ColorBtn)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.numericUpDown1)
        Me.Controls.Add(Me.ComboBox1)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Pen Alignment and Pen Types Sample"
        CType(Me.numericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgsHandles MyBase.Load
        AddPenAlignments()
    End Sub

    Private Sub AddPenAlignments()
        comboBox1.Items.Add(PenAlignment.Center)
        comboBox1.Text = PenAlignment.Center.ToString()
        comboBox1.Items.Add(PenAlignment.Inset)
        comboBox1.Items.Add(PenAlignment.Left)
        comboBox1.Items.Add(PenAlignment.Outset)
        comboBox1.Items.Add(PenAlignment.Right)
    End Sub 'AddPenAlignments

    Private Sub Draw_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Draw.Click
        Dim As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        Dim pn1 As New Pen(Color.Blue, 3)
        pn1.Width = CSng(numericUpDown1.Value)
        pn1.Color = ColorBtn.BackColor
        Dim str As String = ComboBox1.Text
        Select Case str
            Case "Center"
                pn1.Alignment = PenAlignment.Center
            Case "Inset"
                pn1.Alignment = PenAlignment.Inset
            Case "Left"
                pn1.Alignment = PenAlignment.Left
            Case "Outset"
                pn1.Alignment = PenAlignment.Outset
            Case "Right"
                pn1.Alignment = PenAlignment.Right
            Case Else
        End Select
        g.DrawRectangle(pn1, 80150150150)
        Dim brush As New LinearGradientBrush(New Rectangle(10102020), Color.Blue, Color.Green, 45.0F)
        g.FillRectangle(brush, 90160130130)
        pn1.Dispose()
        g.Dispose()

    End Sub
End Class

        
15. 60. Pen Alignment
15. 60. 1. PenAlignment IllustrationPenAlignment Illustration
15. 60. 2. List all Pen AlignmentList all Pen Alignment
w_w___w_.__j___a__v___a__2___s__.c___o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.