Imagine the process we write on paper, we need a piece of paper and a pen, and then we start writing the first word of a stroke, brushwork in the process we can according to the intensity of the stroke line to control the severity of the final pen. Then write down a stroke ....
In Silverlight2 this piece of paper is the InkPresenter control, the InkPresenter control as a set of strokes (Stroke) of the container for the real ink, Ink refers to the pen, touch screen and mouse input handwriting or the content of the painting. The Ink in Silverlight consists of StrokeCollection objects, strokecollection objects consist of different stroke objects. Each stroke corresponds to the press, move, and lift sequence of a pen. Stroke can be a point, a straight line, or even a curve. Each stroke consists of a StylusPointCollection object that has a different styluspoint composition. The StylusPoint object is a collection when the pen touches and moves with the digital converter. We can set the color, width, contour color and so on by the DrawingAttributes property of the object.
The following figure illustrates the structure of the InkPresenter:
InkPresenter does not support the use of stroke,strokecollection tags within the control. You can only control it in a programmatic way. Here's a simple example to illustrate. The more critical event in the InkPresenter control is MouseLeftButtonDown, Mousemove,mouseleftbuttonup, when InkPresenter receives the MouseLeftButtonDown event, You need to create a new stroke in memory and add it to the StrokeCollection, and when MouseMove we will styluspoints to stroke. End stroke in MouseLeftButtonUp event. We create a Silverlight project and add the following code to the Page.xaml:
<UserControl x:Class="SilverlightApplication2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Rectangle x:Name="inkBorder" Width="346" Height="234" Stroke="#FF000000"
Canvas.Top="25" Canvas.Left="25" RadiusX="25" RadiusY="25"/>
<InkPresenter x:Name="inkP" Width="344" Height="232" Canvas.Left="25" Canvas.Top="34"
MouseLeftButtonDown="inkP_MouseLeftButtonDown" MouseLeftButtonUp="inkP_MouseLeftButtonUp"
MouseMove="inkP_MouseMove" Background="LightBlue">
</InkPresenter>
</Grid>
</UserControl>