I have an excersize in C# to create a new class and add some functions and variables but i dont unde

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I need to use this class and its functions then in Form1 in the Paint event and mouse up mose move mose down evetns.

1. General<br/>

– App has single screen (Single Form) – windows forms application
– Possibly app has menu
– Possible options in menu : File , Edit , ..
– Options in File menu : Load Video , Load WireAnim , Save WireAnim , Exit
– Main screen contains :
– picturebox for displaying video frame + wire object over it.
– Video Navigation Buttons : previous frame , next frame , play , jump -10 , jump +10...
– WireObject Buttons : Connect , Delete
– WireObject name TextEdit box
– Point name TextEdit
2. Operation<br/>
User first loads a video so he can browse it frames, frame by frame using the video<br/>
navigation buttons. Video is loaded on the first frame in the video. With a jump-10 or jump+10 the<br/>
user can faster navigate moving between frames (maybe also adding a trackbar or horizontal scroll<br/>
bar).
User moves to the first frame he wants to start work on.
User now declares a “WireObject” for the first time. By pressing the right mouse button on<br/>
the picturebox a point is added to the WireObject, visually it looks as a circle ( or a nice large<br/>
enough point) drawn where the mouse was. Pressing again on the right mouse button adds more<br/>
points.
User can now select to point. Selection is made by pressing the left mouse button on a point<br/>
already drawn. If a press is made where there is no point.. nothing will happen. Only two points can<br/>
be selected at once. If a third is selected it replaces the selection. Pressing on a point already<br/>
selected DE-select that point. When two points are selected and the user press the “Connect” button<br/>
a connection is added WireObject and visually it looks like a line connect those two points. If one<br/>
point is selected and the “Delete” button is selected this point is deleted from the WireObject.<br/>
By selecting “SaveWireAnim” the WireObject is saved / Load..... to be discussed..<br/>
when a point is selected it “Point Name” could also be edited..(textBox)..<br/>
The name of the entire object (WireObject Name) could also be edited at anytime..
3. WireObject Class
Variables :
string name – this is the name of this object (for example : human , cat , mouse , bird )<br/>
int array x,y – two arrays for the x and y coordinates of every point<br/>
string point_name – array that contains the name of each point (same size as of x and y)<br/>
int 2d-array connections – this is a 2d array.. I think declared int connections[][].. but not<br/>
sure..this array holds which points are connected with a line between them. The side of this<br/>
2d array is 2x(size of the x or y arrays). It doesnt hold coordinates like x or y.. but it holds<br/>
index of a points..for example it could contain:
1 2<br/>
1 3<br/>
2 9<br/>
0 4
Which means that point 1 (x[1] ,y[1]) is connected to 2 , 1 also to 3, 2 also to 9, and 0 to 4.<br/>
(0 is also a valid index.. since arrays index start with 0 , point 0 is x[0],y[0])
Functions:
InitObject( name , size )<br/>
SetPoint(index , x , y , name ) overloaded.. SetPoint(index , x , y)<br/>
SetConnections( 2d connection array size*2 )<br/>
GetConnectionsCoords returns 4*size 2d array of coordinates( x1,y1,x2,y2 .. size times<br/>
)<br/>
GetPointIndex( x , y ) returns index of the point closest to this x and y. This what will<br/>
make it possible for making mouse selection for points already drawn.. This functions<br/>
get an x,y coordinates (probably of the mouse location) and searches the x and y arrays<br/>
to see if there is match (with a small tolerance about the size of the drawn point.. 5<br/>
pixels? 10 pixels?) and this function returns the closest math if one was found or -1 if no<br/>
point is close enough to the x and y that was given.
4. General Coding
General for writing functions... make the following remark before any new function you write<br/>
so we will have proper documentation:
/*-----------------------------------------------------------------<br/>
* Function :<br/>
* Description :<br/>
* Returns:<br/>
* Notes:<br/>
*----------------------------------------------------------------*/
<span style=" <hr class="sig danieli

View the full article
 
Back
Top