Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
B2B (Business Integration)
BizTalk
Book Excerpts
Build and Deploy
C#
C++
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Graphics
Internet Explorer 8.0
Interviews
iPhone
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
Network
NHibernate
Object Oriented Development
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Product News
Product Reviews
Project Management
Python
Q&A
Reporting Services
REST
RIA Services
Ruby
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



CODE Training


 


QCon London


Reader rating:
Click here to read 4 comments about this article.
Article source: CoDe (2005 - Vol. 3 - Issue 1 - Tablet PC and Mobile PC)


Article Pages:  1  2 3 4 - Next >


Ink on the Web

One of the more interesting and challenging places to use Ink is in Web applications. Did I say Web applications? Yes, in fact, I did. But how can this technology, which is dependent on the physical relationship between the stylus, the digitizer, and the operating system, work over the Internet?

The trick to bringing Ink to Web applications is embedding Windows controls. Although the Tablet PC SDK has a COM API and a managed API for .NET, it is only the .NET API that allows you to bring Ink to the Internet.

This article teaches you the basics that you need to Ink-enable your Web applications, including the important concepts about security that you need to understand to make it work. The article also walks you through deploying an Ink-enabled Web application and then dives into some of the more complicated problems of what to do with the Ink that you have collected in your Web application.

It’s Just a Windows Forms Control with One Big Caveat

If you have ever embedded a Windows Forms control onto a Web page, you are already nearly a pro at Ink-enabling your Web application. Let’s look at the basics.

Start by creating a new Windows Control Library project and add a reference to the Microsoft Tablet PC API. Then you will Ink-enable the entire surface of the new User Control just the way you would in a Windows Forms application, with just one twist.

When you instantiate the InkOverlay object, one of the overrides in the constructor is to hook it up with a control, rather than a Windows handle.

Public Sub InkOverlay(ByVal attachedControl As _
Control)

This is one of the most important things to remember for using this control in a Web application. You must attach the InkOverlay object to the control itself, not its handle.

The reason for this is related to the sometimes confusing topic of Code Access Security and what an object has permission to do on your computer. This is something that Microsoft overcame with version 1.7 of the Tablet PC SDK. .NET protects your computer from all of the terrible things that Web sites might want to do to you. It does that by giving Internet Explorer only Partial Trust on your computer.

Things with Partial Trust have restricted permissions on your computer. For example, they aren’t allowed to delete a file. As you will see a little further on, your Ink-enabled control is automatically downloaded to the client computer, where it is able to interact with the digitizer. However, nothing that is served from Internet Explorer will ever have a trust level higher than its host (Internet Explorer).

A Windows handle is part of the Win32 API, which is, of course, unmanaged code. Unmanaged code requires Full Trust. Because of Internet Explorer’s Partial Trust restriction, it is not allowed to serve up components requiring Full Trust and therefore, if your Windows Forms control contains something that requires Full Trust, its compiled assembly will also require Full Trust and Internet Explorer will be unable to serve the Ink enabled control to your computer. If the attached control’s window gets re-created, it can be automatically re-connected to the new Window. (.NET controls can re-create their windows unpredictably.)

By linking the InkOverlay to the control rather than its unmanaged Window handle, you are removing the requirement for Full Trust. As long as you don’t put anything else in your project that requires Full Trust, the compiled dll will run under Partial Trust and be deployed to the client computer. That is why it is so very important to remember to choose the overload of the control when you are constructing the InkOverlay object.

Remember: you created a simple control and have Ink-enabled its entire surface. The code for your Windows control, therefore, should look like this

Imports Microsoft.Ink
Namespace InkontheWeb
  Public Class MyInkControl
  Inherits System.Windows.Forms.UserControl
    [Region: Windows Form Designer generated code]
    Dim inko As InkOverlay
    Private Sub InkControl_Load (ByVal sender As 

    Object, ByVal e As System.EventArgs) Handles _
    MyBase.Load
      inko = New InkOverlay(Me)
      inko.Enabled = True
   End Sub
 End Class
End Namespace

There will be some default code for the control hidden inside of the Windows Form Designer generated code region. The most important code in there is the code that explicitly disposes the control. Be sure not to remove that code!

Protected Overloads Overrides Sub Dispose _
(ByVal disposing As Boolean)
  If disposing Then
    If Not (components Is Nothing) Then
      components.Dispose()
    End If
  End If
  MyBase.Dispose(disposing)
End Sub
&

By: Julia Lerman

Julie Lerman is a Microsoft MVP, .NET mentor and consultant who lives in the hills of Vermont. You can find Julie presenting on data access and other topics at user groups and conferences around the world. Julie blogs at thedatafarm.com/blog and is the author of the highly acclaimed Programming Entity Framework (O’Reilly Media). Follow Julie on twitter at julielermanvt.

jlerman@thedatafarm.com

Fast Facts

The Tablet PC SDK makes it easy to get Ink onto your Web page, but then what? This article walks you through the easy part and then dives into some of the trickier stuff such as when (and how) to put the UI functionality into the control or onto the page, and how to get the Ink data from the page and over to the server side for sending it to a database. Additionally, you’ll learn some of the concepts behind the functionality that will be not only be beneficial for troubleshooting but will also help you sound like a real guru at your next geek gathering.



Article Pages:  1  2 3 4 - Next Page: 'Why a Custom Control?' >>

Page 1: Ink on the Web
Page 2: Why a Custom Control?
Page 3: Add Format and Functionality
Page 4: Saving the Ink

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.6 out of 5

25 people have rated this article.

      CODE TRAINING

 

QCon London