简体   繁体   中英

Move a dot automatically by setting two coordinate points in C# - Winforms Visual Studio (Dynamic spot)

I´m developing a Winforms App that allows the user to choose a video to play. That video is the path from the main entry of my university to the destiny he chooses (a classroom, a lab, a proffesor's office...).

Now, I want to add like a little map with a moving red dot that indicates the video's location every moment . I've already created the 'map' with an image of the building drawing and I've also drawn the red dot. You can see the code:

    Graphics Grafico;
    Pen Lapiz = new Pen(Color.Red, 3);

//Planos es el nombre de la pictureBox donde se encuentra el plano del edificio
    private void Planos_Paint_1(object sender, PaintEventArgs e)
    {
        Grafico = e.Graphics;
        Grafico.DrawEllipse(Lapiz, Grafico.ClipBounds.Left + 174, Grafico.ClipBounds.Top + 123, 3, 3);
    }

The red dot has to move at the same time as the videos does. Also, we have to keep in mind that the video can be paused, accelerated, rewinded... by the user, so if the video stops, accelerates or rewinds, the dot has to do it too .

I've being thinking that maybe I should set several coordinate points and tell the dot that has to pass through them watching the state of the video. However, I do not know how to do it.

I would very gratefull if some of you can help me. I do not have much knowledge of programming.

You can generate a series of images with the dot moving in the map and combine these images into a video using ffmpeg or any such tool. You can then mix both videos using a video editing tool into a single video. When the video is played, everything will move in unison. Now, the question is how to move the dot so as to match the video. You need to go along the video at regular intervals of 1 second for example, and record the coordinates on the map. You program the dot to move the dot along these lines segments at a constant speed by splitting each segment into increments of 30 or 60 and draw a dot in there. 30 and 60 are selected for 30fps of 60fps.

Maybe you can consider using a Macro recorder, like "Macro Recorder" (previously "Mouse Recorder". Record a macro of your mouse movements, while video playback. That way you will get coordniates and waittimes, to fill into a datafile. Of course the mouse-movement-speed requires a little extra, but if you click on a mouse move in the recorded macro, you will get duration of the move.

The advanced way to do it, is coding a recording function yourself, but I bet there is a tool already out there, that might do the trick of providing the data you need to make a path for your moving dot.

Macro Recorder: https://www.mouserecorder.com/download.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM