dimanche 5 avril 2015

Anchor a label to move with an object

I have an elevator program.


The lift is represented as image object which moves to request people on the floors they are on.


I currently have a label which represents how many people are on the lift and is of type int.


I want this label to be anchored to the lift image while it moves to show how many people are currently in the lift while it moves. How would I go about doing this?


Below is the code for the lift image:



public Lift(PictureBox limg, int[] fy, int sf, frmLiftSim mf, int id, int peopleCounter)
{
liftImage = limg; // this is the image for the lift
floor_y = fy;
initFloor = sf;
mainForm = mf;
liftID = id;
counter = peopleCounter; // this is the people counter for the lift

liftImage.Top = floor_y[initFloor]; // Move lift to the start position
currentFloor = initFloor; // Set the lift's current position

mainForm.AddToLog("Lift " + liftID + " initialised. Start floor: " + currentFloor);

dtMove.Interval = TimeSpan.FromMilliseconds(20); // time
dtMove.Tick += new EventHandler(dtMove_Tick);

dtWait.Interval = TimeSpan.FromSeconds(2);
dtWait.Tick += new EventHandler(dtWait_Tick);

mainForm.UpdateFloorDisp(currentFloor, liftID);
}

Aucun commentaire:

Enregistrer un commentaire