473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Create an outline area

Hi I am creating a form for vieweing and editing faxes. I read the fax
tiff file into the picturebox. And I have two problems:
1.I want to add a function for the users to be able to select an area
in the picture box and clear it. I am using the Graphics.DrawRectangle
method but the rectangle stays behind the cursor when is moved quickly
eventhough it does draw when releasing the mouse. In the code below I
have the methods used.
2. I would also to create an erase tool like the one in paint any ideas

on how to implement this?
private void peImage_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
//Check if cursor is cross
if(this.peImage.Cursor ==
System.Windows.Forms.Cursors.Cross )
{
//Checks if its left mouse button
if(e.Button == MouseButtons.Left )
{
structDown = new Point(e.X,
e.Y);
structMoveOld.X = e.X;
structMoveOld.Y = e.Y;
blMouseDown = true;
blEndRePaint = true;
}
}
}
private void peImage_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
blEndRePaint = false;
//Check if cursor is cross
if(this.peImage.Cursor ==
System.Windows.Forms.Cursors.Cross )
{
//Checks if its left mouse button
if(e.Button == MouseButtons.Left )
{
structUp = new Point(e.X,
e.Y);
}
}
// Create pen.
Pen blackPen = new Pen(Color.Black);
System.Drawing.SolidBrush sbrushWhite = new
SolidBrush(Color.White);
// Create location and size of rectangle.
int intRectWidth = structUp.X - structDown.X;
int intRectHeight = structUp.Y - structDown.Y;
blMouseDown = false;
structUp.X = 0;
structUp.Y = 0;
// Draw rectangle to screen.
//Need to fill with a brush
Graphics g = this.peImage.CreateGraphics();
g.DrawRectangle(blackPen, structDown.X,
structDown.Y, e.X -
structDown.X, e.Y - structDown.Y);
g.Dispose();
}
private void peImage_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if(this.peImage.Cursor ==
System.Windows.Forms.Cursors.Cross &&
blMouseDown == true)
{
if(blEndRePaint == true)
{
if(structMoveOld.X > e.X &&
structMoveOld.Y > e.Y)
{
//Making Smaller
//Delete the vertical
leftovers

this.peImage.Invalidate(new Rectangle(structMoveOld.X+1 ,
structDown.Y, -(structMoveOld.X -e.X), e.Y));
//Delete the vertical
leftovers

this.peImage.Invalidate(new Rectangle(structDown.X ,
structMoveOld.Y+1, e.X, -(structMoveOld.Y -e.Y) ));
blRepaint = true;

this.peImage.Invalidate(new Rectangle(e.X , e.Y, -
(structMoveOld.X -e.X), - (structMoveOld.Y -e.Y)));
//Console.Write("Old X:
" + structUp.X.ToString() + " New X: " +
e.X.ToString() + "\r\n");
}
else if(structMoveOld.X < e.X
&& structMoveOld.Y < e.Y)
{
//Growing
blRepaint = true;

this.peImage.Invalidate(new Rectangle(structDown.X+1,
structDown.Y+1, e.X - structDown.X-1, e.Y - structDown.Y-1));
//Console.Write("Incr
Old X: " + structDown.X.ToString() + " Incr
New X: " + e.X.ToString() + "\r\n");
}
structMoveOld.X = e.X;
structMoveOld.Y = e.Y;

//Console.WriteLine("MouseMove");
}
}
}
private void peImage_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
if(blRepaint == true)
{
Pen blackPen = new Pen(Color.Red);
blackPen.DashStyle =
System.Drawing.Drawing2D.DashStyle.DashDotDot;
Graphics g =
this.peImage.CreateGraphics();
g.DrawRectangle(blackPen, structDown.X,
structDown.Y,
structMoveOld.X - structDown.X, structMoveOld.Y - structDown.Y);
g.Dispose();
//Console.WriteLine("ImagePaint");
}
blRepaint = false;
}
Thanks in advance for the help

Nov 17 '05 #1
1 1838
I found the solution to my first problem is mentioned in the MSDN help
and its and article titled:
HOW TO: Draw a Rubber Band Rectangle or Focus Rectangle in Visual C#
..NET

I would still appreciate help on the second issue though

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Agent Mulder | last post by:
I feel the need for an outline specifier to facilitate java-style programming.
14
by: Agent Mulder | last post by:
When C++ gives the programmer explicit control over the expansion of code, it needs a new specifier. If 'outline' as a specifier is too much out-of-line, one might consider unline as the...
4
by: Doors of Perception | last post by:
As you probably know, when you click on a link in MSIE and go to a page, then when you click the "back" button, you see a dotted box outlining the link on which I just clicked. As far as I'm...
20
by: Chris Bradbury | last post by:
Hi, I'm posting in this forum for the first time so if I break any conventions or protocols I'm sorry. I've attached this style: *:focus { outline: none } to a page but it doesn't remove...
6
by: Altramagnus | last post by:
I have n number of circles. Some of them might overlap. I need to draw the outline of all circles but not those overlap areas. Initially, I am try to use a Region, because a Region object has a...
5
by: Felix Collins | last post by:
Hi All, does anyone know any cleaver tricks to sort a list of outline numbers. An outline number is a number of the form... 1.2.3 they should be sorted in the following way... 1 1.1 1.2
1
by: John Doe | last post by:
I collapse an outline block, then copy it, then paste it. In my experience, the outline block always expands after the paste. Is their a way to modify the editor's behavior so that an outline block...
3
by: msnews.microsoft.com | last post by:
Anyone ever play with Outline views in VS.NET? I'm amazed I never discovered this. None of this was ever discussed in my training. It's a big help to use this with HTML view. View/Synchronize...
13
by: deko | last post by:
I. A. B. II. A. 1) 2) B. C.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.