Listing 1
public class CustomRenderer: IStylusSyncPlugin
{
private Graphics myGraphics;
public CustomRenderer(Graphics g)
{
myGraphics = g;
}
public void Packets(RealTimeStylus sender, PacketsData packets)
{
for (int i = 0; i < packets.Count;
i += packets.PacketPropertyCount)
{
Point point = new Point(packets[i], packets[i+1]);
Microsoft.Ink.Renderer renderer = new Renderer();
renderer.InkSpaceToPixel(myGraphics, ref point);
// Draw a circle corresponding to the packet
myGraphics.DrawEllipse(Pens.Blue,
point.X - 1, point.Y - 1, 2, 2);
}
}
public DataInterestMask DataInterest
{
get{return DataInterestMask.Packets; }
}
// The remaining interface methods are
//not used in this sample application.
. . .
}
Listing 2
public class Form1 : System.Windows.Forms.Form, IStylusAsyncPlugin
{
private System.Windows.Forms.GroupBox myGroupBox;
// Declare the real time stylus.
private RealTimeStylus myRealTimeStylus;
private void Form1_Load(object sender, System.EventArgs e)
{
myRealTimeStylus = new RealTimeStylus(myGroupBox, true);
myRealTimeStylus.Enabled = false;
myRealTimeStylus.AsyncPluginCollection.Add(this);
DynamicRenderer dr = new DynamicRenderer(myGroupBox);
myRealTimeStylus.SyncPluginCollection.Add(dr);
dr.Enabled = true;
myRealTimeStylus.Enabled = true;
}
#region IStylusAsyncPlugin interface implementation
...
}
Listing 3
public class InkComment : System.Windows.Forms.UserControl
{
private InkOverlay inkOverlay;
public InkComment()
{
InitializeComponent();
inkOverlay = new InkOverlay(this.Handle);
inkOverlay.Enabled = true;
}
...
}
Listing 4
private void Page_Load(object sender, System.EventArgs e)
{
int nTablet = Request.UserAgent.IndexOf("Tablet PC 1.7");
if (nTablet >= 0)
{
//use tablet controls
}
else
{
//use non tablet controls
}
}