Click here to Skip to main content
16,008,010 members
Home / Discussions / C#
   

C#

 
GeneralHelp me out Pin
Member 76655314-Dec-03 22:25
Member 76655314-Dec-03 22:25 
GeneralRe: Help me out Pin
Colin Angus Mackay14-Dec-03 23:05
Colin Angus Mackay14-Dec-03 23:05 
GeneralLoad C# windows applcation from windows service Pin
JeyKey14-Dec-03 22:08
JeyKey14-Dec-03 22:08 
GeneralRe: Load C# windows applcation from windows service Pin
Rampas Tomas15-Dec-03 0:14
Rampas Tomas15-Dec-03 0:14 
GeneralRe: Load C# windows applcation from windows service Pin
JeyKey15-Dec-03 0:27
JeyKey15-Dec-03 0:27 
GeneralGUI Pin
G_ULJEE14-Dec-03 20:59
G_ULJEE14-Dec-03 20:59 
GeneralGDI+ Graphics.DrawRectangle() Pin
krisp14-Dec-03 20:33
krisp14-Dec-03 20:33 
GeneralRe: Drawing rectangles in GDI+ Pin
Arun Reginald Zaheeruddin14-Dec-03 23:28
Arun Reginald Zaheeruddin14-Dec-03 23:28 

The coordinate system
As we all know, drawing systems in .Net are based upon pixels that are arranged on a two-dimensional coordinate system. The origin, that is, the points (0, 0) lie on the far top-left of the screen. Each consecutive pixel towards the right of the origin forms the x-axis, and each consecutive pixels towards the bottom of the screen forms the y-axis.

If you note carefully, the co-ordinate system for onscreen graphics is an inverted copy of the Cartesian Co-ordinate System used in Mathematical Geometry.

Now, when we give the call to the system to draw a rectangle, we provide it with four arguments. The x-coordinate, the y-coordinate, width and the height of the rectangle. We will traverse through each step that the system undergoes to create a rectangle.

Step 1:
First, the point (x, y) or the pixel present on the point (x, y) is plotted or marked on the coordinate system as shown below.

Step 2:
Then, it adds the width provided as argument to the next consecutive x-coordinate. For instance, if the x-coordinate is 0 and the width is 10, then the resultant point on the x-axis (fx) will be:

Because x-coordinate specified was 0,
So the next x-coordinate will be 1

Final Point = next x-coordinate + width
Final Point = 1 + 10
Final Point = 11;

Same goes for the y-coordinate and the height to calculate the resultant point on the y-axis (fy).

Step 3:
System marks all the pixels from (0, 0) to the point (fx, 0) on the x-axis and also marks all the pixels from (0, 0) to (0, fy). This gives two straight lines joined at (0, 0) at an angle of 90 degrees.

The points (fx, 0) and (0, fy) are then interconnected at the point (fx, fy). Thus giving the illusion of a perfect rectangle.

What happens with GDI+ drawing routines
If you keep the x-coordinate and the y-coordinate as (0, 0), then it is seen that:

Resultant Point fx = width + 1 and
Resultant Point fy = height + 1

So, if we specify the below mentioned statements in GDI+:

C#
g.DrawRectangle(new SolidBrush(Color.Blue), 0, 0, this.Width, this.Height);
g.DrawRectangle(new SolidBrush(Color.Blue),
	new Rectangle(0, 0, this.Width, this.Height));


From these statements, it is clear that the resultant point to which the rectangle will be stretched is (this.Width+1, this.Height+1) which unfortunately exceeds the visible region of the Component or Custom Control.

Did not understand a single word? Ask for a detailed and illustrated description at: aaronreginald@yahoo.com. I would be more that glad to help you out.





The beginning of knowledge is the fear of God

GeneralWBEM not WMI Pin
WayneMJ14-Dec-03 18:42
WayneMJ14-Dec-03 18:42 
GeneralGet Folder Attributes Pin
Daniel Negron14-Dec-03 14:57
Daniel Negron14-Dec-03 14:57 
GeneralRe: Get Folder Attributes Pin
Rampas Tomas14-Dec-03 20:57
Rampas Tomas14-Dec-03 20:57 
GeneralHelp Regarding Image Transfer Pin
Ali Gohar14-Dec-03 9:24
sussAli Gohar14-Dec-03 9:24 
GeneralRe: Help Regarding Image Transfer Pin
Heath Stewart15-Dec-03 4:18
protectorHeath Stewart15-Dec-03 4:18 
GeneralHeath - Further External Drag Drop Questions Pin
Tristan Rhodes14-Dec-03 6:42
Tristan Rhodes14-Dec-03 6:42 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Nick Parker14-Dec-03 7:22
protectorNick Parker14-Dec-03 7:22 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes14-Dec-03 12:10
Tristan Rhodes14-Dec-03 12:10 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Heath Stewart15-Dec-03 4:13
protectorHeath Stewart15-Dec-03 4:13 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes15-Dec-03 6:59
Tristan Rhodes15-Dec-03 6:59 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Heath Stewart15-Dec-03 8:27
protectorHeath Stewart15-Dec-03 8:27 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes15-Dec-03 8:58
Tristan Rhodes15-Dec-03 8:58 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Heath Stewart15-Dec-03 9:00
protectorHeath Stewart15-Dec-03 9:00 
GeneralRe: Heath - Further External Drag Drop Questions Pin
Tristan Rhodes15-Dec-03 10:15
Tristan Rhodes15-Dec-03 10:15 
GeneralRe: Heath - Further External Drag Drop Questions Pin
J. Dunlap15-Dec-03 11:11
J. Dunlap15-Dec-03 11:11 
GeneralNever mind... Pin
J. Dunlap15-Dec-03 11:14
J. Dunlap15-Dec-03 11:14 
GeneralRe: Never mind... Pin
Tristan Rhodes15-Dec-03 11:16
Tristan Rhodes15-Dec-03 11:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.