Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 锚定标签以随对象移动_C#_Image_Animation_Anchor - Fatal编程技术网

C# 锚定标签以随对象移动

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

我有一个电梯程序

电梯被表示为图像对象,该对象移动以请求所在楼层的人员

我目前有一个标签,表示电梯上有多少人,类型为int

我希望在电梯移动时将此标签定位到电梯图像,以显示电梯移动时当前有多少人在电梯中。我该怎么做呢

以下是电梯图像的代码:

    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。是的,但是面板需要转换为图像对象,我的代码才能工作否,您必须重构代码。