Drawing xor line on picture box. HELP!

M

Macias

Hi,
Please help me, how I can make a line drawing on PictureBox similar to
MS paint. I thinking about this: click and hold button, move mouse and
relase button.

I'm trying useing this g.DrawLine(..), but I have a lot of line.

In C++ is a parameter XORPUT, but in C# I can't find it.


Maciek
 
M

Macias

I make drawing like this:

private void pb_MouseMove(object sender, MouseEventArgs e)
{
Point CurentCoord = new Point(e.X, e.Y);
if (md)
{

using (Graphics g = Graphics.FromImage(img))
{
g.CompositingMode = CompositingMode.SourceOver;
g.CompositingQuality =
CompositingQuality.HighSpeed;
Rectangle rect = this.ClientRectangle;
using (Pen p = new Pen(ColorBox.BackColor, 2))
{
g.DrawLine(p, ClickCoord, CurentCoord);
pb.Image = img;
}
}
}

but still I've a lot of lines when I moveing mouse. But I want to have
only one.
Please correct my pice of program.

Maciek
 
C

Chris Dunaway

Hi,
Please help me, how I can make a line drawing on PictureBox similar to
MS paint. I thinking about this: click and hold button, move mouse and
relase button.

I'm trying useing this g.DrawLine(..), but I have a lot of line.

In C++ is a parameter XORPUT, but in C# I can't find it.

Maciek

Have you looked at the ControlPaint.DrawReversibleLine method?
Perhaps that will do what you need.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top