WPF, MediaElement和MediaElement.剪辑与EllipseGeometry

本文关键字:MediaElement EllipseGeometry WPF | 更新日期: 2023-09-27 17:50:27

我正在使用MediaElement播放视频。
我在MediaElement下添加了MediaElement.Clip -> EllipseGeometry,仅显示部分视频。
我想做4个按钮,每个按钮将改变椭圆几何的中心位置。
当前代码如下:

<Grid>
    <Canvas Height="279" HorizontalAlignment="Left" Margin="26,20,0,0" Name="canvas1" VerticalAlignment="Top" Width="453">
        <Button Canvas.Left="22" Canvas.Top="200" Height="30" Width="30" HorizontalAlignment="Center" VerticalAlignment="Center" Panel.ZIndex="1">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <StackPanel>
                        <ContentPresenter Content="{TemplateBinding Content}" />
                    </StackPanel>
                </ControlTemplate>
            </Button.Template>
            <Image Source="Images'play.png"/>
        </Button>
        <MediaElement Canvas.Left="22" Canvas.Top="80" Height="193" Name="mediaElement1" Width="244" Panel.ZIndex="0" Source="C:'Users'ilans'Documents'Visual Studio 2010'Projects'Wildlife.wmv">
            <MediaElement.Clip>
                <EllipseGeometry Center="50,80" RadiusX="20" RadiusY="20" />
            </MediaElement.Clip>
        </MediaElement>
        <Button Canvas.Left="356" Canvas.Top="40" Content="Button" Height="23" Name="button1" Width="75" Click="button1_Click" />
    </Canvas>
</Grid>

我如何添加操纵MediaElement.ClipEllipseGeometry位置的新按钮?

WPF, MediaElement和MediaElement.剪辑与EllipseGeometry

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        Point ellipsePoint = new Point(80, 80);
        mediaElement1.Clip = new EllipseGeometry(ellipsePoint, 30, 30);
    }