Using Windows 7 Touch with Silverlight in Visual Basic .NET

Creating QR-Code in Visual Basic .NET Using Windows 7 Touch with Silverlight

8 Using Windows 7 Touch with Silverlight
Generating QR Code In VB.NET
Using Barcode printer for VS .NET Control to generate, create QR Code JIS X 0510 image in VS .NET applications.
www.OnBarcode.com
Reading Quick Response Code In VB.NET
Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
learned about in 7, Building Multitouch Applications in Managed Code. After you have captured the mouse input, you create a new Stroke that contains a DrawingAttributes object that defines the visual characteristics of this stroke. In the example presented here, DrawingAttributes for the stroke provide it with a Width of 2, a Height of 2, a fill color of White, and an outline color of White. The MouseEventArgs type in Silverlight supports a getStylusPoints method, as you saw earlier in this chapter, that takes the InkPresenter as its sole parameter. This method returns an instance of the StylusPointCollection type that can be used with the stroke s AddStylusPoints method. You then add the stroke to the InkPresenter s StrokesCollection. You can see the code here:
Barcode Encoder In VB.NET
Using Barcode printer for .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Bar Code Decoder In VB.NET
Using Barcode decoder for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
function inkMouseDown(sender,args) { // Capture the mouse. theInk.CaptureMouse(); // Create a new stroke. newStroke = theControl.content.createFromXaml('<Stroke/>'); // Assign a new drawing attributes element to the stroke. // This, as its name suggests, defines how the stroke will appear var da = theControl.content.CreateFromXaml('<DrawingAttributes/>'); newStroke.DrawingAttributes = da; // Now that the stroke has drawing attributes, // let's define them... newStroke.DrawingAttributes.Width = 2; newStroke.DrawingAttributes.Height = 2; newStroke.DrawingAttributes.Color = "White"; newStroke.DrawingAttributes.OutlineColor = "White";
Make Denso QR Bar Code In C#
Using Barcode printer for Visual Studio .NET Control to generate, create QR image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code 2d Barcode Generator In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
www.OnBarcode.com
newStroke.StylusPoints.AddStylusPoints(args.GetStylusPoints(theInk)); theInk.Strokes.Add(newStroke); }
QR Code 2d Barcode Creation In VS .NET
Using Barcode maker for .NET Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
www.OnBarcode.com
Code 128A Generation In Visual Basic .NET
Using Barcode creator for VS .NET Control to generate, create Code-128 image in Visual Studio .NET applications.
www.OnBarcode.com
Now, as you move the mouse over the canvas, if you are currently drawing a stroke (that is, newStroke is not null), you want to generate new points to add to this stroke, representing the track over which the mouse moved. Following is the code for this:
Generate QR Code 2d Barcode In Visual Basic .NET
Using Barcode printer for VS .NET Control to generate, create QR image in .NET framework applications.
www.OnBarcode.com
Drawing UCC - 12 In Visual Basic .NET
Using Barcode printer for Visual Studio .NET Control to generate, create GS1-128 image in .NET applications.
www.OnBarcode.com
// Add the new points to the Stroke we're working with. function inkMouseMove(sender,args) { if (newStroke != null) { newStroke.StylusPoints.AddStylusPoints(args.GetStylusPoints(theInk)); } }
Barcode Creation In VB.NET
Using Barcode generator for .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Identcode Generation In VB.NET
Using Barcode printer for Visual Studio .NET Control to generate, create Identcode image in VS .NET applications.
www.OnBarcode.com
Introducing Windows 7 for Developers Finally, the MouseLeftButtonUp event fires after you finish the stroke by releasing the mouse button (or by lifting the pen from the screen). At this point, you want to clear the stroke and release the mouse capture. When the newStroke variable has been set to null, the mouse (or pen) movement across the screen no longer collects points to add to the stroke, and the stroke output will therefore not be drawn. Here s the code:
Encoding Quick Response Code In Objective-C
Using Barcode generation for iPhone Control to generate, create QR-Code image in iPhone applications.
www.OnBarcode.com
UPC-A Supplement 2 Creation In None
Using Barcode creator for Software Control to generate, create GTIN - 12 image in Software applications.
www.OnBarcode.com
function inkMouseUp(sender,args) { // Set the stroke to null newStroke = null; // Release the mouse theInk.releaseMouseCapture(); }
UPC Code Generator In Java
Using Barcode creator for Android Control to generate, create UPC Code image in Android applications.
www.OnBarcode.com
Create Code 39 Extended In Java
Using Barcode creation for Java Control to generate, create Code39 image in Java applications.
www.OnBarcode.com
The following screen shot shows an example of an application before Ink annotation was added to it.
Code 39 Extended Creator In Java
Using Barcode printer for Android Control to generate, create Code-39 image in Android applications.
www.OnBarcode.com
Data Matrix ECC200 Recognizer In VB.NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The next screen shot shows the same application after Ink annotation has been added to it the annotation was drawn on it using a mouse or pen.
Draw GTIN - 12 In None
Using Barcode creation for Office Excel Control to generate, create UPC-A image in Office Excel applications.
www.OnBarcode.com
Bar Code Scanner In VB.NET
Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in .NET applications.
www.OnBarcode.com
8 Using Windows 7 Touch with Silverlight
The previous example showed you how to program for Ink using Silverlight and JavaScript. The good news is that you can, of course, do the same with managed code. Here s the complete code-behind for C# to be able to build the same application:
using using using using using using using using using using using System; System.Collections.Generic; System.Linq; System.Windows; System.Windows.Controls; System.Windows.Documents; System.Windows.Input; System.Windows.Media; System.Windows.Media.Animation; System.Windows.Shapes; System.Windows.Ink;
namespace NetInkSample { public partial class Page : UserControl { Stroke newStroke; public Page() { InitializeComponent();
Introducing Windows 7 for Developers
} private void inkEl_MouseLeftButtonDown( object sender, MouseButtonEventArgs e) { inkEl.CaptureMouse(); // Create a new stroke. newStroke = new Stroke(); DrawingAttributes da = new DrawingAttributes(); newStroke.DrawingAttributes = da; newStroke.DrawingAttributes.Width=2; newStroke.DrawingAttributes.Height=2; newStroke.DrawingAttributes.Color=Colors.White; newStroke.DrawingAttributes.OutlineColor=Colors.White; // Beta 2 newStroke.StylusPoints.Add( e.StylusDevice.GetStylusPoints(inkEl)); // Beta 1 //newStroke.StylusPoints.AddStylusPoints( e.GetStylusPoints(inkEl)); inkEl.Strokes.Add(newStroke); } private void inkEl_MouseMove(object sender, MouseEventArgs e) { if (newStroke != null) { //Beta 1 //newStroke.StylusPoints.AddStylusPoints( e.GetStylusPoints(inkEl)); //Beta 2 newStroke.StylusPoints.Add( e.StylusDevice.GetStylusPoints(inkEl)); } } private void inkEl_MouseLeftButtonUp( object sender, MouseButtonEventArgs e) { newStroke = null; inkEl.ReleaseMouseCapture(); } } }
In addition to showing the flexibility of Silverlight, which allows you to develop applications in either parsed JavaScript or compiled .NET languages, this example also demonstrates how straightforward it is to migrate from JavaScript to .NET. So you can see that if you have existing Silverlight applications in JavaScript, it is easy to upgrade them to Silverlight using managed code.
Copyright © OnBarcode.com . All rights reserved.