VB.NET實現PhotoShop的流動選取框

來源:互聯網
上載者:User
 

VB.NET實現PhotoShop的流動選取框   大家好,本人第一次發表文章(激動中),看了開發高手連續幾篇談到PhotoShop中流動選取框的文章,其實實現並不難,在這裡我就用VB.NET實現,在.NET中提供了功能十分強大的GDI+,前篇C#用的也是GDI+,我這裡也用上!其實沒有什麼區別!希望對學VB.NET的人有協助,下面是源碼:建立一個新的VB應用程式,一個視窗中添加一個時間(Timer)組件,Interval設定為50微妙,Imports System.Drawing.Drawing2D
Imports System.Drawing.Graphics
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private pen As pen                                 '建立一個畫筆對象
    Private GPath As New GraphicsPath                  '執行個體化路徑對象
    Private Dpattern() As Single = {5.0, 7.0}          '實線的長度和虛線長度
    Private offset As Single = 0.0                     '位移值#Region " Windows 表單設計器產生的程式碼 "    Public Sub New()
        MyBase.New()        '該調用是 Windows 表單設計器所必需的。
        InitializeComponent()        '在 InitializeComponent() 調用之後添加任何初始化    End Sub    '表單重寫 dispose 以清理組件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
            GPath.Dispose()
            pen.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub    'Windows 表單設計器所必需的
    Private components As System.ComponentModel.IContainer    '注意: 以下過程是 Windows 表單設計器所必需的
    '可以使用 Windows 表單設計器修改此過程。
    '不要使用代碼編輯器修改它。
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        '
        'Timer1
        '
        Me.Timer1.Enabled = True
        Me.Timer1.Interval = 50
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(416, 166)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Photo For VB.NET"    End Sub#End Region     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Refresh()            '重新整理視窗
    End Sub    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        pen.DashOffset = offset                 '設定位移值
        e.Graphics.DrawPath(pen, GPath)         '畫路徑        '改變位移值的量
        offset += 1.0
        If offset / 100 = 1 Then
            offset = 0.0
        End If    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GPath.AddString("電腦", _
                        New FontFamily("幼圓"), _
                        FontStyle.Bold + FontStyle.Italic, _
                        120.0F, _
                        New PointF(30.0F, 20.0F), _
                        New StringFormat)        '添加一個字元路徑
        pen = New Pen(Color.Black)               '構造畫筆
        pen.DashPattern = Dpattern               '自訂的短劃線和空白地區
        pen.DashStyle = DashStyle.Custom         '此屬性的 DashStyle.Custom 值指定:由 DashPattern 屬性定義的短劃線和空白地區的自訂圖案
    End Sub
End Class
在WINXP+SP1+VS.NET2003編譯通過

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.