ARTICLE

Setting Ink Overlay Properties in Tablet PC

Posted by Mahesh Chand Articles | Visual Basic 2010 May 29, 2004
In this article, I will write an application that allows us to set the Ink Overlay properties such as height, width, and color of the ink dynamically based on the values selected by the user.
Download Files:
 
Reader Level:

In this article, I will write an application that allows us to set the Ink Overlay properties dynamically based on the values selected by the user. The application looks like the following figure, where user can enter width and height of the overlay and select a color by clicking the Select Pen Color button. The Apply button applies the settings to the overlay.



If you don't want to download the attached project, you need to create a Windows Forms application and add reference to Microsoft Tablet PC API.

Now define the following private variables:

Private selectedColor As Color = System.Drawing.Color.Blue
Private inkOverlay As InkOverlay = Nothing

The Select Pen Color button code looks like following:

Private
Sub PenColorBtn_Click(sender As Object, e As System.EventArgs)
Dim colorDlg As New ColorDialog()
If colorDlg.ShowDialog() = DialogResult.OK Then
selectedColor = colorDlg.Color
End If
End
Sub 'PenColorBtn_Click

The Apply button click code looks like the following:

Private Sub ApplyBtn_Click(sender As Object, e As System.EventArgs)
' Make sure to dispose the existing InkOverlay
' object before creating a new one
If Not (inkOverlay Is Nothing) Then
inkOverlay.Dispose()
inkOverlay =
Nothing
End
If
' Create DrawingAttributes with the width, height, and color
Dim attributes As New DrawingAttributes()
attributes.Height = Convert.ToInt32(textBox1.Text)
attributes.Width = Convert.ToInt32(textBox2.Text)
attributes.Color = selectedColor
RefreshView(attributes)
End Sub 'ApplyBtn_Click

RefreshView method:

Private Sub RefreshView(da As DrawingAttributes)
' Create new InkOverlay object
inkOverlay = New InkOverlay()
' Set DefaultDrawingAttributes
inkOverlay.DefaultDrawingAttributes = da
' Tell the surface is the form
inkOverlay.Handle = Me.Handle
' Enable overlay
inkOverlay.Enabled = True
End
Sub 'RefreshView

Other Properties:

DrawingAttributes object provides few more useful properties. You can use AntiAliased property to anti-aliasing of the ink and PenTip property to change the tip of the pen.

The Transparency property allows you to set the transparency of the ink.

attributes.Transparency = 120.

Download source code for more details.

share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor