Click here to Skip to main content
15,900,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am working on multitouch application. My requirement is that I am using one image as background which should be static and other images are used to move on the Background image.

1. First I have downloaded the code which was in the blog and i saw that where ever i can touch the screen it is moving but i want when i touch the image then only it have to move.

2. I have used your code and modified according to my requirement.But no image is moving after doing the modifications.

Can you please help me regarding this.Below is my code:
<Window x:Class="Win7MultitouchDemo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Windows 7 MultiTouch Demo" Height="600" Width="800" WindowState="Maximized">
<Canvas x:Name="holder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="300" Width="500">
<Canvas.Background>
<ImageBrush ImageSource="images/Water lilies.jpg" Stretch="UniformToFill" />
</Canvas.Background>
<Image Source="images/Hydrangeas.jpg" RenderTransformOrigin="0.5,0.5" Width="200" Canvas.Left="307" Canvas.Top="-1" Height="150">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="tr1Scale" ScaleX="1" ScaleY="1"/>
<RotateTransform x:Name="tr1Rotate" Angle="0"/>
<TranslateTransform x:Name="tr1Translate" X="0" Y="0"/>
<SkewTransform AngleX="0" AngleY="0"/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image Source="images/Hydrangeas.jpg" RenderTransformOrigin="0.5,0.5" Width="200" Canvas.Left="309" Canvas.Top="148" Height="150" StretchDirection="Both">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="tr2Scale" ScaleX="1" ScaleY="1"/>
<RotateTransform x:Name="tr2Rotate" Angle="0"/>
<TranslateTransform x:Name="tr2Translate" X="0" Y="0"/>
<SkewTransform AngleX="0" AngleY="0"/>
</TransformGroup>
</Image.RenderTransform>
</Image>
</Canvas>
</Window>


Cs Code:
using System;
using System.Windows;
using Windows7.Multitouch;
using Windows7.Multitouch.Manipulation;
using Windows7.Multitouch.WPF;
namespace Win7MultitouchDemo
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
// object of a .Net Wrapper class for processing multitouch manipulation
private ManipulationProcessor manipulationProcessor = new ManipulationProcessor(ProcessorManipulations.ALL);
private static bool IsMultitouchEnabled = TouchHandler.DigitizerCapabilities.IsMultiTouchReady;
public Window1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Window1_Loaded);
}
void Window1_Loaded(object sender, RoutedEventArgs re)
{
// check to see whether multitouch is enabled
if (IsMultitouchEnabled)
{
// enables stylus events for processor manipulation
Factory.EnableStylusEvents(this);
// add the stylus events
StylusDown += (s, e) => { manipulationProcessor.ProcessDown((uint)e.StylusDevice.Id, e.GetPosition(this).ToDrawingPointF()); };
StylusUp += (s, e) => { manipulationProcessor.ProcessUp((uint)e.StylusDevice.Id, e.GetPosition(this).ToDrawingPointF()); };
StylusMove += (s, e) => { manipulationProcessor.ProcessMove((uint)e.StylusDevice.Id, e.GetPosition(this).ToDrawingPointF()); };
// register the ManipulationDelta event with the manipulation processor
manipulationProcessor.ManipulationDelta += ProcessManipulationDelta;
// set the rotation angle for single finger manipulation
manipulationProcessor.PivotRadius = 2;
}
}
private void ProcessManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
trTranslate.X += e.TranslationDelta.Width;
trTranslate.Y += e.TranslationDelta.Height;
trRotate.Angle += e.RotationDelta * 180 / Math.PI;
trScale.ScaleX *= e.ScaleDelta;
trScale.ScaleY *= e.ScaleDelta;
tr1Translate.X += e.TranslationDelta.Width;
tr1Translate.Y += e.TranslationDelta.Height;
tr1Rotate.Angle += e.RotationDelta * 180 / Math.PI;
tr1Scale.ScaleX *= e.ScaleDelta;
tr1Scale.ScaleY *= e.ScaleDelta;
tr2Translate.X += e.TranslationDelta.Width;
tr2Translate.Y += e.TranslationDelta.Height;
tr2Rotate.Angle += e.RotationDelta * 180 / Math.PI;
tr2Scale.ScaleX *= e.ScaleDelta;
tr2Scale.ScaleY *= e.ScaleDelta;

}
}
}
Posted
Updated 17-Sep-10 2:59am
v2

1 solution

You need to post the message in the forum section below the article you are refering to, that's the only way the author of the article will get to know.
 
Share this answer
 
Comments
bhanuprakash007 17-Sep-10 9:31am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900