![]() |
Platforms, Frameworks & Libraries »
Mobile Development »
GDI+
Intermediate
Scratchpad/Signature Capture as BMP on Pocket PCBy RajeshNayakA way to capture signature or scribble on the Pocket PC. |
C#, Windows, .NETCF, .NET1.1, .NET2.0, WinMobile2003VS.NET2003, VS2005, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||


This control class allows a user to take a colored jot down note or signature, and save it as BMP file in the Pocket PC. This easy to use code can be plugged into any .NET application to take scribbles.
Quite for a long time, I was looking for a free Signature control or some thing like that, that I could use in my own application without overloading it with bulkier codes. I was looking for some thing where I could change the pen color, width, and so on. In the internet knowledge bases, there was very few information on this, and most did not suit my needs. Later, I thought of assembling the available code and stripping down the un-needed portions, and fine-tuning the code to the level of my expectations.
Thought, may be a few people like me are still looking for this kind of a snippet and thought of sharing it. There are a few portions in this code that a programmer can even modify, like make the pen width changeable, save image as JPG or GIF etc.
Copy the Signature.cs file to any of your Pocket PC 2003 projects. Add a Panel control to the visual form. Put this code as described and get the project rolling with signature capture capability.
Here, I have added a Panel:
private System.Windows.Forms.Panel pnlSignature;
private Signature cSignature;
Later in the constructor, or in the form Load event, you can add:
cSignature = new Signature();
cSignature.Location = pnlSignature.Location;
cSignature.Size = pnlSignature.Size;
this.pnlSignature.Visible = false;
this.Controls.Add(cSignature);
Under any Button's Click event, you can write this code to save the file under your desired location with a name:
cSignature.Save(Path.Combine(AppPath, "CapturedPicture.bmp"));
Similarly, you can change the pen color by calling:
cSignature.SetPenColor(Color.Blue);
or load a previously saved picture of the same size, using:
cSignature.LoadImage(Path.Combine(AppPath,
"PreviouslyCapturedPicture.bmp"));
Visibility of the Panel to false, as we need to see the control, not the Panel. Here, the Panel is just a container.
Panel size, else it may not work. While working on this, I changed the pen width by changing the following lines of code. Obviously, there must be a better way to do this than what I did.
GraphicsHandle.DrawLine(SignaturePen, l.StartX+1,
l.StartY, l.EndX+1,l.EndY);
GraphicsHandle.DrawLine(SignaturePen, l.StartX,
l.StartY+1, l.EndX,l.EndY+1);
GraphicsHandle.DrawLine(SignaturePen, l.StartX+1,
l.StartY+1, l.EndX+1,l.EndY+1);
GraphicsHandle.DrawLine(SignaturePen, l.StartX,
l.StartY, l.EndX,l.EndY);
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 6 Sep 2006 Editor: Smitha Vijayan |
Copyright 2006 by RajeshNayak Everything else Copyright © CodeProject, 1999-2010 Web21 | Advertise on the Code Project |