mulittouch应用程序中的多个图像 [英] Multiple images in mulittouch application

查看:62
本文介绍了mulittouch应用程序中的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Iam致力于多点触控应用.我的要求是Iam使用一个图像作为背景,该图像应该是静态的,而其他图像则用于在Background图像上移动.
1.首先,我已经下载了您的代码,然后发现可以触摸屏幕的任何地方都在移动,但是当我触摸图像时我只想移动它即可.
2.我使用了您的代码并根据需要进行了修改.但是修改后没有图像移动.
您能否为此提供帮助.以下是我的代码:

Hi,
Iam working on multitouch applciation.My requirement is Iam 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 your code 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;


}
}
}

推荐答案

您应该直接向从中获得代码的文章的作者问这个问题.

返回文章,一直滚动到底部,您将看到一个向作者发送消息的区域.
You should ask this question directly to the writer of the article you got the code from.

Go back to the article, scroll all the way to the bottom and you will see a section to send a message to the author.


这篇关于mulittouch应用程序中的多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆