Tablets Vista and WPF

Published 27 May 7 5:24 AM | William

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.

<Grid>

 <InkCanvas Name="icMain">

   <InkCanvas.Background><ImageBrush ImageSource="were_cuckoo.jpg">  </ImageBrush>

 

 </InkCanvas.Background>

    <InkCanvas.DefaultDrawingAttributes>         <DrawingAttributes Color="Blue" Width="4"/>

    </InkCanvas.DefaultDrawingAttributes>

 </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>

</Grid>

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;
public Window1()
{
InitializeComponent();
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))
  {
    icMain.Strokes.Save(fs);
    fs.Close();
   }
}
void btnColorSelect_Click(object sender, RoutedEventArgs e)
{
   cd.ShowDialog();
   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:

Ink Tablet PC And this: Ink Tablet PC

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...

Filed under: , ,

Search

This Blog

Tags

Community

Archives

News

  • William G Ryan William Ryan Bill Ryan W.G. Ryan Charles Mark Carroll Charles M Carroll
    My Blog Juice Microsoft MVP
    Bill Ryan W.G. Ryan William Ryan
    Cuckooz' MySpace Page View Bill Ryan's profile on LinkedIn
    My Profile on Twitter
    Please note that this is my personal blog and the opinions expressed are my own. Also, comment moderation is about one of the least important things in my life so please keep that in mind. I can't vouch for the authenticity of any of the posters so please don't hold me accountable. And whatever you do, don't pretend to be Noted Option Strict Off expert and AspFriend Charles Mark Carroll when you post. Doing so will lead him to become apoplectic and write absurd accusatory posts about me that are as coherent and thought out as they are factually correct. He does a stellar job proving his reputation is well deserved and he doesn't need any help from you making himself look foolish. If I have to listen to him banging his spoon off of his high chair one more time, I'm going to burst into flames so please don't make that happen!

    My other sites

    Cool Stuff

    Book Stuff

    Security

    ORM

    Data Access

    Funny Stuff

    Compact Framework Stuff

    Web Casts

    My KnowledgeBase Articles

    My MVP Profile

    Design Patterns

    Performance

    Debugging

    Remoting

    My Fellow Authors

    My Books

    LINQ

    Misc

    Speech

    Syndication

    Email Notifications