WindowsPhoneGeek

WPAppInfo

Login | Join (Why?)

rss rss rss
logo

WP7 DrawingBoard sample: Drawing (Ink) made easy

published on: 7/7/2011 | Views: N/A | Tags: Drawing UI

by John Simmons

A while ago I made this class to make it easy to draw on your phone, using an InkPresenter. It is very easy to use. All it requires is an InkPresenter control on your page, and 2 lines of code. You can also add code to edit color, size, and switch from 'draw mode' to 'erase mode'.

Tip80-0

public partial class MainPage : PhoneApplicationPage  
{  
    // Constructor  
    SimzzDev.DrawingBoard myBoard;  
    public MainPage()  
    {  
      InitializeComponent();  
      myBoard = new SimzzDev.DrawingBoard(ink);  
    }  
}

And that will give you basic drawing functionality. You can also add code like this to change Drawing Attributes:

private void redBtn_Click(object sender, RoutedEventArgs e)  
{  
  //Change the color to red.  
  myBoard.MainColor = Colors.Red;  
  myBoard.OutlineColor = Colors.Red;  
}  
private void blackBtn_Click(object sender, RoutedEventArgs e)  
{  
  //Change the color to black.  
  myBoard.MainColor = Colors.Black;  
  myBoard.OutlineColor = Colors.Black;  
}  
private void penBtn_Click(object sender, RoutedEventArgs e)  
{  
  //Change it to 'draw mode'.  
  myBoard.InkMode = SimzzDev.DrawingBoard.PenMode.pen;  
}  
private void eraseBtn_Click(object sender, RoutedEventArgs e)  
{  
  //Change it to 'erase mode'.  
  myBoard.InkMode = SimzzDev.DrawingBoard.PenMode.erase;  
}  


Hopefully this helps anyone that sees this. A sample and the library can be downloaded at:

Drawingboard

(http://simzz.com/)

You can also follow us on Twitter @winphonegeek


John Simmons


About the author:

Comments

Add comment to 'WP7 DrawingBoard sample: Drawing (Ink) made easy'

Comment

Our Top Articles & Free books

Our Top Tips & Samples