简体   繁体   English

获取滑块的X,Y坐标/位置

[英]Getting X,Y coordinates/position of slider

I need to get the [X,Y] positions of a slider. 我需要获取滑块的[X,Y]位置。 I already tried the function "PointFromScreen" but I didn't get any result. 我已经尝试过“ PointFromScreen”功能,但没有得到任何结果。

Anyone? 任何人?

Thanks 谢谢

    private void SliderPosition(object sender)
    {
        Slider slider = (Slider)sender;
        int x = (int)slider.Value;
        Point x1 = Point.Parse(x);
        Point slider_point = slider.PointFromScreen(x1);
    }

UPDATE and more clear doubt: 更新和更明确的疑问:

I have a video going through, and a slide that is dependent of the number of frames. 我有一段正在播放的视频和一张取决于帧数的幻灯片。 Video format is 640x480, slider is defined in terms of frames! 视频格式为640x480,滑块是根据帧定义的!

I need to know, when the right button is pushed in the video image, the position[X,Y] of the slider so that I can draw a line in a Canvas that is beneath the video. 我需要知道,当在视频图像中按下右键时,滑块的位置[X,Y]可以使我在视频下方的Canvas中画一条线。

I think it's clear now. 我认为现在很清楚。 Going through the library, the only parameter I can find is the slider.value but that doesn't make my case. 遍历库,我可以找到的唯一参数是slider.value,但这并不能说明问题。

Source code of my try: 我尝试的源代码:

     private void Slider_position(object sender, System.Windows.Controls.Slider e,    System.Windows.Input.MouseEventArgs e1)
    {
        if (e1.RightButton == MouseButtonState.Pressed)
        {
            Line line = new Line();
            line.X1 = e. //something, i would get here the coordinates X,Y of slider here
            // calculation from slider position to canvas position
            // draw a line of the height of the canvas here after

        }
    }

尝试使用MouseClick(),因为这将为您提供AutoIt窗口信息中的鼠标位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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