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

Home
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.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » 2D Graphics » Pen Alignment 
17.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
17.60.Pen Alignment
17.60.1.PenAlignment IllustrationPenAlignment Illustration
17.60.2.List all Pen AlignmentList all Pen Alignment
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.