PDA

View Full Version : [CF.NET C#] Ink Drawing?



alexgeek
March 8th, 2008, 07:32 PM
I'm quite enjoying developing for my PDA at the moment but it seems a shame to have a touch screen and not use it for drawing.
Does CF have a component similar to the WPF InkCanvas? Would be interesting :)
Thnx

Templarian
March 9th, 2008, 01:09 AM
You still have paint() event you can use to draw with. I once made a small image editor with it so it can't be too complicated to make a more advanced drawing type tool.

alexgeek
March 10th, 2008, 08:53 PM
I understand that you can draw circles, lines etc with the Graphics class but can you draw straight onto a panel with the stylus? As in I drag the stylus across the panel and a line appears?

Templarian
March 10th, 2008, 10:45 PM
Yes, you have stylus input that you can use. Its just like windows form. If stylus is down while move(like mouse move) then you draw on the bitmap or graphic).

The stylus (mouse) events are probably different its been a while sense I developed for it. Draw the bitmap and then draw that to the form.

alexgeek
March 11th, 2008, 07:44 PM
Okay Im having some trouble with this code:


private int? X, Y;
private void Draw(object sender, MouseEventArgs e)
{
this.X = e.X;
this.Y = e.Y;
this.PaintPanel.Invalidate();
// MessageBox.Show("Mouse Move called, points (x, y) " + this.X.ToString() + this.Y.ToString());
}
private void DrawPixel(int x, int y, ref Graphics G)
{
G.FillRectangle(new SolidBrush(Color.Black), x, y, 1, 1);
}

private void PaintPanel_Paint(object sender, PaintEventArgs e)
{
MessageBox.Show("Paint called, hurrah");
Graphics G = e.Graphics;
if(this.X != null && this.Y != null)
this.DrawPixel((int)this.X, (int)this.Y, ref G);
G.DrawEllipse(new Pen(Color.Orange), 2, 2, 10, 10);
}


The events get called correctly but nothing is drawn.. help? thnx