VB.Net by API/System.Drawing.Drawing2D/LineCap

Материал из VB Эксперт
Версия от 12:51, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

LineCap.ArrowAnchor

  
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LineCapAllStyles
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim x As Integer = 5
        Dim y As Integer = 17
        Dim the_pen As New Pen(Color.Black, 10)
        DrawLine(e.Graphics, x, y, Drawing2D.LineCap.AnchorMask)
        DrawLine(e.Graphics, x, y, Drawing2D.LineCap.ArrowAnchor)
        DrawLine(e.Graphics, x, y, Drawing2D.LineCap.DiamondAnchor)
        DrawLine(e.Graphics, x, y, Drawing2D.LineCap.Flat)
    End Sub
    Private Sub DrawLine(ByVal gr As Graphics, ByRef x As Integer, ByRef y As Integer, ByVal style As Drawing2D.LineCap)
        Dim the_pen As New Pen(Color.Black, 10)
        the_pen.EndCap = style
        gr.DrawString(style.ToString, Me.Font, Brushes.Black, x, y - 5)
        gr.DrawLine(the_pen, x + 100, y, x + 150, y)
        y += 25
    End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class


LineCap.Triangle

  
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GetCapStyles
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        Dim blackPen As New Pen(Color.Black, 10)
        blackPen.StartCap = LineCap.Triangle
        blackPen.EndCap = LineCap.Triangle
        g.DrawLine(blackPen, 20, 10, 200, 10)
        blackPen.StartCap = LineCap.Square
        blackPen.EndCap = LineCap.Square
        g.DrawLine(blackPen, 20, 30, 200, 30)
        blackPen.StartCap = LineCap.ArrowAnchor
        blackPen.EndCap = LineCap.ArrowAnchor
        g.DrawLine(blackPen, 20, 50, 200, 50)
        blackPen.StartCap = LineCap.DiamondAnchor
        blackPen.EndCap = LineCap.DiamondAnchor
        g.DrawLine(blackPen, 20, 70, 200, 70)
        blackPen.StartCap = LineCap.Flat
        blackPen.EndCap = LineCap.Flat
        g.DrawLine(blackPen, 20, 90, 200, 90)
        blackPen.StartCap = LineCap.Round
        blackPen.EndCap = LineCap.Round
        g.DrawLine(blackPen, 20, 110, 200, 110)
        blackPen.StartCap = LineCap.RoundAnchor
        blackPen.EndCap = LineCap.RoundAnchor
        g.DrawLine(blackPen, 20, 130, 200, 130)
        blackPen.StartCap = LineCap.Square
        blackPen.EndCap = LineCap.Square
        g.DrawLine(blackPen, 20, 150, 200, 150)
        blackPen.StartCap = LineCap.SquareAnchor
        blackPen.EndCap = LineCap.SquareAnchor
        g.DrawLine(blackPen, 20, 170, 200, 170)
        blackPen.StartCap = LineCap.Flat
        blackPen.EndCap = LineCap.Flat
        g.DrawLine(blackPen, 20, 190, 200, 190)
        " Dispose
        blackPen.Dispose()
        g.Dispose()
  End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class