C# 锚定标签以随对象移动
我有一个电梯程序 电梯被表示为图像对象,该对象移动以请求所在楼层的人员 我目前有一个标签,表示电梯上有多少人,类型为int 我希望在电梯移动时将此标签定位到电梯图像,以显示电梯移动时当前有多少人在电梯中。我该怎么做呢 以下是电梯图像的代码:C# 锚定标签以随对象移动,c#,image,animation,anchor,C#,Image,Animation,Anchor,我有一个电梯程序 电梯被表示为图像对象,该对象移动以请求所在楼层的人员 我目前有一个标签,表示电梯上有多少人,类型为int 我希望在电梯移动时将此标签定位到电梯图像,以显示电梯移动时当前有多少人在电梯中。我该怎么做呢 以下是电梯图像的代码: public Lift(PictureBox limg, int[] fy, int sf, frmLiftSim mf, int id, int peopleCounter) { liftImage = limg; // t
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);
}
我会通过
Panel1.Controls.Add(…)
将PictureBox和标签放在一个面板中,然后移动面板而不是PictureBox。是的,但是面板需要转换为图像对象,我的代码才能工作否,您必须重构代码。