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); 4 1506
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/
I want to know the best way to draw rectangle on form,
I write some code in mouseup() and mousemove(),mou sedown(),
but it not work, i cant save the rectangle's data
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/
thanx
i will try
"Morten Wennevik" <Mo************ @hotmail.com>
??????:oprykoc5 t8hntkfz@localh ost...
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/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 Rectangle (as
defined in some prior sections), and then I provide definition
class OptimizedRectangle(Rectangle):
__slots__ = 'width', 'heigth'
I can use the instance of OptimizedRectangle, say, x, with 'width' and
'heigth', but (quoting the book)...
|
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 onpaint event and added the
code to draw my rectangle and position my graphic items:
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
e.Graphics.Clear(Color.FromArgb(255, 255, 255))
|
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 OnPaint ( PaintEventArgs e)
{
Graphics dc = e.Graphics;
Pen BluePen = new Pen(Volor.Blue, 3);
|
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
u.GetViewBounds.Y + u.GetViewBounds.Height
Dim Dx As Integer = x - u.Location.X
Dim Dy As Integer = y - u.Location.Y
If Dx * Dx + Dy * Dy <= u.ViewRange * u.ViewRange
Then 'punctul e in cercul vizual
|
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 grids I have the following code...
....
| |
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 or have a windowblind type transition,etc.
How do you create transitions in a picture box in conjunction with
displaying text?
(Using vb.net.
|
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 class describes a generic method of drawing rubberbands
# on a wxPython canvas object (wxStaticBitmap, wxPanel etc) when
# the user presses the left mouse button and drags it over a rectangular
# area. It has methods to return the selected area by...
|
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 to do the following:
myObject.Rect.Width = width;
myObject.Rect.Height = height;
|
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 NEW keyword,
anyway. Aren't they located on the stack, like values, and isn't NEW
used to create space on the heap?
Dom
|
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, but
the return type doesn't match:
Rectangle? m_textArea = null;
public Rectangle TextArea {
set { m_textArea = value; }
get { return m_textArea; }
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |