Click here to Skip to main content
15,894,907 members
Home / Discussions / C#
   

C#

 
Generala thread question Pin
cchere29-Dec-04 4:20
cchere29-Dec-04 4:20 
GeneralRe: a thread question Pin
Tom Larsen29-Dec-04 4:36
Tom Larsen29-Dec-04 4:36 
GeneralRe: a thread question Pin
cchere29-Dec-04 5:30
cchere29-Dec-04 5:30 
GeneralRe: a thread question Pin
Member 161799929-Dec-04 6:51
Member 161799929-Dec-04 6:51 
GeneralRe: a thread question Pin
cchere29-Dec-04 7:15
cchere29-Dec-04 7:15 
GeneralRe: a thread question Pin
Tom Larsen29-Dec-04 10:39
Tom Larsen29-Dec-04 10:39 
GeneralVector-Based Application Pin
el_zeeyed29-Dec-04 3:21
el_zeeyed29-Dec-04 3:21 
GeneralRe: Vector-Based Application Pin
Heath Stewart29-Dec-04 9:10
protectorHeath Stewart29-Dec-04 9:10 
This is a simple matter of abstraction. You define a general Shape class, for example, from which each shape derives. On that you define general properties like the bounding rectangle, perhaps an ID, connection points, etc.

To move those shapes your container, or drawing surface, need to handle the MouseDown, MouseMove, and MouseUp events. When a user clicks, you use the coordinates and loop through the array finding the shape that contains those coordinates (the Rectangle.Contains method is handy in this case). While the mouse is down (use a simple state variable that gets reset in your MouseUp handler) change the location of the image as the user drags.

You extend a base class because you can implement helper methods in a single class. The container just needs to worry about positioning and sizing while the shapes worry about drawing themselves (the dumber the container is, the more extensible your solution is).

To scale individual images you need to implement functionality in either the shape or the container to size it. You can use the mouse techniques above to do that as well. Define a threshold and when the mouse is within that threshold and near the edge of a shape you can resize it. If you want to resize the whole drawing surface, you can apply a scale transform in your OnPaint override using the Graphics.ScaleTransform method.

This is not an easy subject and I recommend you start off with basic functionality. If the article you found is too complicated (welcome to the reality of application development) then I suggest picking up some object-oriented development books or reading additional articles. Eventually it will start making sense.

Be sure to read, however, because just using IntelliSense like I see far too many people doing in lieu of reading documentation won't teach you anything. When someone mentions classes, methods, properties, etc. that you're not familiar with (like I did above several times) find them in the .NET Framework SDK that is installed by default with VS.NET and is available online at http://msdn.microsoft.com/library[^] and read about them.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralAsynchronous socket programming - threading design question Pin
Adam Goossens29-Dec-04 2:31
Adam Goossens29-Dec-04 2:31 
GeneralRe: Asynchronous socket programming - threading design question Pin
Robert Rohde29-Dec-04 2:40
Robert Rohde29-Dec-04 2:40 
GeneralRe: Asynchronous socket programming - threading design question Pin
Stefan Troschuetz29-Dec-04 7:36
Stefan Troschuetz29-Dec-04 7:36 
GeneralRe: Asynchronous socket programming - threading design question Pin
Adam Goossens29-Dec-04 14:37
Adam Goossens29-Dec-04 14:37 
GeneralDoDragDrop problem Pin
Marc Clifton29-Dec-04 2:16
mvaMarc Clifton29-Dec-04 2:16 
GeneralRe: DoDragDrop problem Pin
Robert Rohde29-Dec-04 2:55
Robert Rohde29-Dec-04 2:55 
GeneralRe: DoDragDrop problem Pin
Marc Clifton29-Dec-04 3:26
mvaMarc Clifton29-Dec-04 3:26 
Generaltime between points Pin
gerstla29-Dec-04 2:14
gerstla29-Dec-04 2:14 
GeneralRe: time between points Pin
Adam Goossens29-Dec-04 2:50
Adam Goossens29-Dec-04 2:50 
GeneralWinforms Pin
| Muhammad Waqas Butt |29-Dec-04 1:35
professional| Muhammad Waqas Butt |29-Dec-04 1:35 
GeneralCrystal Report Pin
| Muhammad Waqas Butt |29-Dec-04 1:00
professional| Muhammad Waqas Butt |29-Dec-04 1:00 
GeneralRe: Crystal Report Pin
Michael P Butler29-Dec-04 1:39
Michael P Butler29-Dec-04 1:39 
GeneralNumber to Word Pin
| Muhammad Waqas Butt |29-Dec-04 0:57
professional| Muhammad Waqas Butt |29-Dec-04 0:57 
GeneralRe: Number to Word Pin
Marc Clifton29-Dec-04 3:11
mvaMarc Clifton29-Dec-04 3:11 
Generalchanging row color in a datagrid Pin
Salmanzz28-Dec-04 19:47
Salmanzz28-Dec-04 19:47 
GeneralRe: changing row color in a datagrid Pin
Identity Undisclosed28-Dec-04 20:25
Identity Undisclosed28-Dec-04 20:25 
GeneralRe: changing row color in a datagrid Pin
Robert Rohde28-Dec-04 22:08
Robert Rohde28-Dec-04 22:08 

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.