0

I'm developing this multitouch app in WPF with visual studio 2010.

I have the follow problem:

I'm trying to use the rotate,scaling and other effect with multitouch (like gallery in ipad style).

Can anyone tell me how to do that with a MEDIA ELEMENT?For the image as you see i haven't problem,and the rotate/scaling works fine.

The source is the follow:

<Window x:Class="TouchRect.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TouchRect" 
    Title="MainWindow" Height="600" Width="800">
<Grid Width="auto">
    <local:RulerCanvas x:Name="canvas"  >
        <!--<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"    Height="215" Width="736">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="3" HorizontalAlignment="Center" VerticalAlignment="Stretch"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>-->
        <Image x:Name="image3" Width="74" Height="49" IsManipulationEnabled="True" Source="flower3.jpg" Canvas.Left="239" Canvas.Top="-273">
            <Image.RenderTransform>
                <MatrixTransform Matrix="2.41806325085411,0,0,2.41806325085411,280.737615796121,292.420001677231" />
            </Image.RenderTransform>
        </Image>
        <Image x:Name="image2" Width="64" Height="49" IsManipulationEnabled="True" Source="flower2.jpg" VerticalAlignment="Stretch" Canvas.Left="-236" Canvas.Top="-272">
            <Image.RenderTransform>
                <MatrixTransform  Matrix="2.41806325085411,0,0,2.41806325085411,280.737615796121,292.420001677231"/>
            </Image.RenderTransform>
        </Image>
        <StackPanel Orientation="Horizontal" Margin="0,10,0,0"></StackPanel>


        <Image x:Name="image" Width="74" Height="49" IsManipulationEnabled="True" Source="flower.jpg" Stretch="Fill" HorizontalAlignment="Center" Canvas.Left="-7" Canvas.Top="-271">
            <Image.RenderTransform>
                <MatrixTransform Matrix="2.41806325085411,0,0,2.41806325085411,280.737615796121,292.420001677231" />
            </Image.RenderTransform>
        </Image>
        <MediaElement x:Name="media" Source="C:\Users\Public\Videos\Sample Videos\Wildlife.wmv" Width="633" Height="366" Canvas.Left="65" Canvas.Top="164" LoadedBehavior="Manual" IsManipulationEnabled="True" />

        <!--</ListBox>-->  
    </local:RulerCanvas>

</Grid>

Thanks a lot!

mac
  • 42,153
  • 26
  • 121
  • 131

1 Answers1

1

I would suggest you just use the TranslateZoomRotateBehavior from the Blend SDK:

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:is="http://schemas.microsoft.com/expression/2010/interactions"
<MediaElement Height="256" Source="H:\Videos\Programming\Skeet at DevDays 2009.mp4">
    <i:Interaction.Behaviors>
        <is:TranslateZoomRotateBehavior />
    </i:Interaction.Behaviors>
</MediaElement>

It's simple and works everywhere.

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • Oh thanks! In this way i can use the multitouch and it works without any implementation in the class? – stefano cumin Dec 05 '11 at 20:44
  • Yes, that's all the code you need (added the xmlns, now it really is complete). There are of course a few properties that can be set on the behavior to customize it. – H.B. Dec 05 '11 at 20:48
  • Hi!thanks a lot! today i have tried to implements the code but i get this problem: the attachable property behaviors was not found in type interaction,and this error: Error 1 The tag 'Interaction.Behaviors' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'. Line 38 Position 14. C:\Users\stage1\Desktop\GalleriaPinchToZoom\BasicInertia\MainWindow.xaml 38 14 BasicManipulationPlusInertia how i have to do to resolve this problem?Let me know.Thanks! – stefano cumin Dec 06 '11 at 07:33
  • Oh ok,but i have to launch the application in a tablet pc with windows 7,it work there without the blend sdk installed? – stefano cumin Dec 06 '11 at 07:50
  • You need to distribute the dll with your application, [there are ways to embedd them](http://stackoverflow.com/questions/6458436/including-a-dll-as-an-embedded-resource-in-a-wpf-project) as well so you do not have them flying around as separate files. – H.B. Dec 06 '11 at 08:12
  • oK thanks. I have a problem when adding System.windows.interactivity.dll Error 1 Unknown build error, 'Cannot resolve dependency to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' BasicManipulationPlusInertia i get this error. There is a way to eliminate it? I tried to google the problem but i didn't find something that help me. – stefano cumin Dec 06 '11 at 08:41
  • Sorry, i do not think that i can help you with that. – H.B. Dec 06 '11 at 09:06
  • Ok no problem! I have resolved it in half. Now i'm getting this error: Error 1 The tag 'Interaction.Behaviors' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'. Line 38 Position 14. C:\Users\stage1\Desktop\WPF4Touch\BasicInertia\MainWindow.xaml 38 14 BasicManipulationPlusInertia i have to add something in this i think: xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:is="http://schemas.microsoft.com/expression/2010/interactions" any ideas? I have to install something? – stefano cumin Dec 06 '11 at 09:18
  • I don't think there is more to it (unless you really are missing the `http://` at the start which i think SO cut off). You did add the *right* dll as reference, right? (`System.Windows.Interactivity`) – H.B. Dec 06 '11 at 09:27
  • If you cannot resolve this you maybe should ask another question as this is conceptually indendent from the original question about multi-touch manipulation of media elements. – H.B. Dec 06 '11 at 10:05