Tablets Vista and WPF
I got sidetracked pretty bad tonight working on my tablet. Started working on a basic Inking application and I really got off track. Started out with a InkCanvas and an Image.
<InkCanvas Name="icMain"> <InkCanvas.Background><ImageBrush ImageSource="were_cuckoo.jpg"> </ImageBrush>
</InkCanvas.Background> <InkCanvas.DefaultDrawingAttributes> <DrawingAttributes Color="Blue" Width="4"/>
</InkCanvas><Button Height="23" Margin="36,0,0,9" Name="btnSave" VerticalAlignment="Bottom" Click="btnSave_Click" HorizontalAlignment="Left" Width="102">Save Drawing</Button> <Button Height="23" HorizontalAlignment="Right" Margin="0,0,60,11" Name="btnSelectColor" VerticalAlignment="Bottom" Width="108">Select Color</Button>
This alone will give you an image and an inking surface. Quickly realized that I wanted to change the colors so I added a ColorDialog. Then I just had to call OpenDialog to get the color back from the dialog box.
ColorDialog cd = null;
this.btnSave.Click += new RoutedEventHandler(btnSave_Click);
this.btnSelectColor.Click += new RoutedEventHandler(btnColorSelect_Click);
cd = new ColorDialog();
void btnSave_Click(object sender, RoutedEventArgs e)
using (FileStream fs = new FileStream("inkstrokes.isf", FileMode.Create))
void btnColorSelect_Click(object sender, RoutedEventArgs e)
System.Drawing.Color clr = cd.Color;
DrawingAttributes clr2 = new DrawingAttributes();
clr2.Color = Color.FromArgb(clr.A, clr.R, clr.G, clr.B);
icMain.DefaultDrawingAttributes.Color = clr2.Color;
Here's what results:
Very straightforward to say the least. I was going to add some gestures into it, but decided I want to give it a try with Silverlight first. Maybe I can finally start getting in front of the curve again...