473,382 Members | 1,252 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,382 software developers and data experts.

question about rectangle?

you are given two rectangles, each defined by an upper left(UL) corner and a
low right(LR)corner,Both rectangles' edges will always be parrallel to the x
or y axis ,Write a window program with c# that user can use mouse to draw
the rectangle add the program will determines whether the two rectangles
overlap. For convenience, you may use the following structs:
Struct point{
Int x;
Int y;
}
Struct rect{
struct point UL;
struct point LR;
}
The function prototype is As following:
int overlap(struct rect A,struct rect B);
Nov 15 '05 #1
4 1486
Um, this sounds like home work or some test :P
Note all triangles will be like this one, but the position may wary.
If you get stuck, ask specific problems.

UL
Y |\
| | \
| |__\LR
|
|_______x

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
I want to know the best way to draw rectangle on form,
I write some code in mouseup() and mousemove(),mousedown(),
but it not work, i cant save the rectangle's data
Nov 15 '05 #3
Well, you only need two points to know the rectangle since you can
calculate the third one.
UL and LR. The corner point (CP) will be (UL.x, LR,y).

Drawing the triangle can be done by DrawLine between each of the points
(UL, LR), (LR, CP), (CP, UL)
Capture the UL on mousedown, and use mousemove coordinates for LR until
mouseup.

If you call Invalidate() after mousemove events/mouseup you can erase the
old triangle by drawing it using the background color (you need the old LR
for that) before drawing the new triangle.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #4
thanx
i will try
"Morten Wennevik" <Mo************@hotmail.com>
??????:oprykoc5t8hntkfz@localhost...
Well, you only need two points to know the rectangle since you can
calculate the third one.
UL and LR. The corner point (CP) will be (UL.x, LR,y).

Drawing the triangle can be done by DrawLine between each of the points
(UL, LR), (LR, CP), (CP, UL)
Capture the UL on mousedown, and use mousemove coordinates for LR until
mouseup.

If you call Invalidate() after mousemove events/mouseup you can erase the
old triangle by drawing it using the background color (you need the old LR
for that) before drawing the new triangle.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #5

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

Similar topics

7
by: Porky Pig Jr | last post by:
Hello, I"m still learning Python, but going through the Ch 5 OOP of Nutshell book. There is discussion on __slots__, and my understanding from reading this section is that if I have a class...
2
by: padawan | last post by:
I have a winforms control that draws a rectangle for a boarder and positions some graphical elements around the control to create the boarder effect I desired. In the control I have overriden the...
1
by: Yuelin | last post by:
Hi, thanks for the answers to my previous questions. Now I have a question on drawing in C#: For example I have written following code to draw a rectangle on a form: protected override void...
5
by: Crirus | last post by:
What do you think about this approaches, wich one is the best? For x As Integer = u.GetViewBounds.X To u.GetViewBounds.X + u.GetViewBounds.Width For y As Integer = u.GetViewBounds.Y To...
1
by: CJ Taylor | last post by:
Alright, I cannot figure out what I'm doing wrong here. As some of you know I've been stripping out C1 out of my current project, and going back to native .NET controls. However, on one of my...
9
by: rut | last post by:
If I have a picturebox with a background image and I want to 1. Display text atop of the background and 2. Have transistions between text; ie, when the text changes, the screen can fade out/in...
3
by: Nebulism | last post by:
Hi everyone! Earlier I asked a question about mouse interaction with a GUI. I have found a pretty comprehensive script that is supposed to work <mod edit: link removed, source inserted>:# This...
6
by: Dom | last post by:
I have a class that has a System.Drawing.Rectangle as a member, called m_Rect. I set it up as a property, like this: get { return m_Rect;} set { m_Rect = value;} Now in my main code I want...
5
by: Dom | last post by:
is there a difference between the following: Rectangle r = new Rectangle (10,20,30,40); Rectangle r = Rectangle.FromLTRB(10,20,30,40); Also, I guess I'm not sure why Structs are created with a...
4
by: raiderdav | last post by:
I understand how the ternary operator (question mark - ?) works in an if/else setting, but what does it mean when used as a type? For instance, I'm trying to add a get/set in some existing code,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.