• 0

[WPF C#} Polygon filled with video


Question

Hello gang,

I am in need to make a polygon object that I will with a video. I have this working fine, however the fill of the video using the

<VisualBrush Stretch="UniformToFill">

including "None", "Fill", "Uniform" or "UniformToFill" is not filling the polygon as I would like.

Here is the XAML code for creating the polygon

        <Polygon Name="vlcPolygon" Points="500,300, 500,250, 770,200 770,440" Stroke="Black" StrokeThickness="4" >
            <Polygon.Fill>
                <VisualBrush Stretch="UniformToFill">
                    <VisualBrush.Visual>
                        <Image Source="{Binding VideoSource, ElementName=vlcPlayer}" />
                    </VisualBrush.Visual>
                </VisualBrush>
            </Polygon.Fill>
        </Polygon>

Any thoughts?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi James.

Saw your 2011 post while searching for wpf polygon fill video ....
You've probably moved on to other things.
Thought I'd share my experience and ask what your experience was and is.

Are you still working with video for apps/web/games/ just fun?

 

I experimented with it in 2009 (using F# and WPF no XAML) -- 

Create Outside the Box on YouTube ...

 

https://youtu.be/xbfARUZmxz8

 

 

Recently trying to get "replay" or "loop"  found this MSDN XAML and hacked .mp4 

  <!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
                     over and over indefinitely.-->

 

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="1844.16" Width="762.8" >

    <StackPanel Margin="338,10,78.2,-16">

        <!-- The MediaElement control plays the sound. -->
        <MediaElement Name="myMediaElement" HorizontalAlignment="Left" Width="313" Height="234" RenderTransformOrigin="0.5,0.5" >
            <MediaElement.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform AngleX="-20"/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </MediaElement.RenderTransform>
            <MediaElement.Triggers>
                <EventTrigger RoutedEvent="MediaElement.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>

                                <!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
                     over and over indefinitely.-->
                                <MediaTimeline Source="C:\Windows\WinSxS\amd64_microsoft-windows-shell-sounds_31bf3856ad364e35_6.3.9600.16384_none_07d0dc3d89809d9b\tada.wav" Storyboard.TargetName="myMediaElement"  
                 RepeatBehavior="Forever" />
                                <MediaTimeline Source="C:\Users\Honu\SkyDrive\Symmorphmetry\April 2015\Trim to short mpg4.mp4" Storyboard.TargetName="myMediaElement"  
                 RepeatBehavior="Forever" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </MediaElement.Triggers>
        </MediaElement>

    </StackPanel>

</Page>
 

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.