.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
VB.NET实现PhotoShop的流动选取框

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

大家好,本人第一次发表文章(激动中),看了开发高手连续几篇谈到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编译通过

有不对的地方请指点




相关文章

相关软件