Mapping a set of spatial coordinates

I have a simple forms program with a form that is 777 x 777, the program passes along 3 values from the previous form to 3 labels  XCoord, YCoord, and ZCoord.

What I AM trying to do is map on the form with a simple blue point 5px by 5px where exactly the point space is.

This is the code that is being used currently to pass the values to labels on the new form.

shw.XCoord.Text = "XCoord: " + coordX.ToString();
shw.YCoord.Text = "YCoord: " + coordY.ToString();
shw.ZCoord.Text = "ZCoord: " + coordZ.ToString();

Any help would be greatly appreiciated.

Thanks

Peter
schenkpAsked:
Who is Participating?
 
gazzzzzzerCommented:
First of all I would create a function on the form with the labels that sets the labels text.
Also create a form paint handler to draw the blue point on the form (not sure how you wannt to handle the zcoord).
This might look like:

///Global Vars to store where to paint the blue point
int xcoord,ycoord,zcoord = -5;


public void setCoord(int x int y, int z)
{
    //Set Label Text
    this.XCoord.text = x.ToString();
    this.YCoord.text = y.ToString();
    this.ZCoord.text = z.ToString();

    //Set global vars used to paint blue point
    xcoord = x;
    ycoord = y;
    zcoord = z;
}

//Form Paint Event Handler
void MyFormPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
    //Draw Blue Point on form canvas
    this.CreateGraphics().FillRectangle(new SolidBrush(Color.Blue),new Rectangle(xcoord,ycoord,5,5));
}


Now from your other form call the setCoord function. EXAMPLE:

setCoord(coordX,coordY,coordZ);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.