| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> VB.Net实例分析 >> 外接设备编程 >> 实例分析正文
最新推荐 更多内容
自定义数据控件(VB2010实例)
自定义数据控件(VB2010实例)
作者:Akyao    来源:乐博网收集     更新时间:2011-4-18

本文演示对控制绘制墨迹视觉样式的特性(包括大小、形状、颜色和位置)进行操作的常用方式,来自乐博网。

如果你想下载本文的源代码RAR压缩集合包  请访问
VB2010源代码集合包(芋头糕)    http://www.lob.cn/code/utility/2795.shtml
特别感谢网友 芋头糕 将此资源提供乐博网分享,欢迎加入 40797788 的.Net超级qq群交流。

对控制绘制墨迹视觉样式的特性(包括大小、形状、颜色和位置)进行操作的常用方式的实例代码如下:

Imports Microsoft.Ink

Public Class Form1
    Dim myInkOverlay As InkOverlay


    Sub New()

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

        'Place the various raster operations in the group box
        InitializeRasterOperations()
    End Sub

    'Handle the form loading event by wiring up ink collection
    Sub FormLoadHandler(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        'Create and enable the ink collecting Control
        myInkOverlay = New InkOverlay(Panel1)
        myInkOverlay.Enabled = True

        'Set the attributes of the ink collector
        SetAttributes()
    End Sub


    'Creates controls for selecting raster operation
    Sub InitializeRasterOperations()
        'Add all the types of Raster Operations to the groupbox for possible selection
        For Each rasterOpName As String In System.Enum.GetNames(GetType(RasterOperation))
            'Create a new radio button
            Dim rasterButton As New RadioButton()
            rasterButton.Text = rasterOpName

            'Default raster op is "Copy Pen"
            If rasterOpName = "CopyPen" Then
                rasterButton.Checked = True
            End If

            'Add it to the flow layout panel
            FlowLayoutPanel1.Controls.Add(rasterButton)

            'Add a handler to it
            AddHandler rasterButton.CheckedChanged, AddressOf RasterOpChosenHandler
        Next
    End Sub

    'Handles selections of raster operation
    Sub RasterOpChosenHandler(ByVal sender As Object, ByVal e As EventArgs)
        'Who has been chosen?
        Dim chosenButton As RadioButton = CType(sender, RadioButton)
        'This will be called if checked or unchecked, so only assign on checked
        If chosenButton.Checked Then
            'What's the RasterOperation value of selected button?
            Dim rasterOp = System.Enum.Parse(GetType(RasterOperation), chosenButton.Text)
            'Set attribute  '更多.net源代码 来自乐博网lob.cn
            myInkOverlay.DefaultDrawingAttributes.RasterOperation = rasterOp
        End If
    End Sub

    Sub SetAttributesHandler(ByVal sender As Object, ByVal e As EventArgs) Handles antiAliasCheckbox.CheckedChanged, pressureSensitiveCheckbox.CheckedChanged, penTipRectangle.CheckedChanged, penTipEllipse.CheckedChanged, widthUpDown.ValueChanged, transparencyUpDown.ValueChanged, heightUpDown.ValueChanged
        'Can be called prior to myInkOverlay being initialized, so check if that's the case
        If myInkOverlay Is Nothing Then
            Return
        End If
        SetAttributes()
    End Sub

    'Sets the major attributes of the ink overlay (minus color, raster op, and some rare properties
    Sub SetAttributes()
        'Anti-aliasing
        If antiAliasCheckbox.Checked = True Then
            myInkOverlay.DefaultDrawingAttributes.AntiAliased = True
        Else
            myInkOverlay.DefaultDrawingAttributes.AntiAliased = False
        End If

        'Pressure sensitivity
        If pressureSensitiveCheckbox.Checked = True Then
            myInkOverlay.DefaultDrawingAttributes.IgnorePressure = False
        Else
            myInkOverlay.DefaultDrawingAttributes.IgnorePressure = True
        End If

        'Pen Tip
        If penTipRectangle.Checked = True Then
            myInkOverlay.DefaultDrawingAttributes.PenTip = PenTip.Rectangle
        Else
            myInkOverlay.DefaultDrawingAttributes.PenTip = PenTip.Ball
        End If

        'Transparency
        myInkOverlay.DefaultDrawingAttributes.Transparency = transparencyUpDown.Value

        'Height
        myInkOverlay.DefaultDrawingAttributes.Height = heightUpDown.Value
        'Width
        myInkOverlay.DefaultDrawingAttributes.Width = widthUpDown.Value
    End Sub

    'Handles "color" button
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Create a standard dialog
        Dim colorDialog As New ColorDialog()

        'Set color to current color
        colorDialog.Color = myInkOverlay.DefaultDrawingAttributes.Color

        'Show it
        If colorDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            'Set color to chosen
            myInkOverlay.DefaultDrawingAttributes.Color = colorDialog.Color
        End If
    End Sub
End Class

  • 上一篇:

  • 下一篇:
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    管理计算机电源状态的类(VB2010实例)
    Tablet PC 上可用的文本识别选项(VB2010实例)
    Tablet PC 2005 中对笔势的系统识别(VB2010实例)
    Tablet PC 2005 的区分上下文功能(VB2010实例)
    响应数字化仪触笔背面的橡皮擦(VB2010实例)
    WMI编程实例(VB2010实例)
    系统服务管理实例(VB2010实例)
    进程管理(VB2010实例)
    显示进程组成模块(VB2010实例)
    任务管理器编程(VB2010实例)
    性能计数器编程(VB2010实例)
    消息队列MSMQListener(VB2010实例)
    消息队列MSMQClient(VB2010实例)
    写入事件日志(VB2010实例)
    读取事件日志(VB2010实例)
    创建和删除事件日志(VB2010实例)

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]