基本信息
源码名称:wpf多点触控 示例源码下载
源码大小:2.40M
文件格式:.zip
开发语言:C#
更新时间:2017-07-18
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 5 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFMultiTouch
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        protected override void OnManipulationStarting(ManipulationStartingEventArgs e)
        {
            FrameworkElement element = null;
            Panel pnl = null;
            
            e.ManipulationContainer = this;
            
            element = e.Source as FrameworkElement;

            pnl = element.Parent as Panel;

            for (int i = 0; i < pnl.Children.Count; i  )
            {
                Panel.SetZIndex(pnl.Children[i],
                                (pnl.Children[i] == element) ? pnl.Children.Count : i);
                
                e.Handled = true;
            }
            base.OnManipulationStarting(e);
        }

        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            UIElement element = null;
            MatrixTransform xform = null;
            Matrix matrix;
            ManipulationDelta delta = null;
            Point center;

            element = e.Source as UIElement;

            xform = element.RenderTransform as MatrixTransform;

            matrix = xform.Matrix;

            delta = e.DeltaManipulation;

            center = e.ManipulationOrigin;

            matrix.ScaleAt(delta.Scale.X, delta.Scale.Y, center.X, center.Y);
            matrix.RotateAt(delta.Rotation, center.X, center.Y);
            matrix.Translate(delta.Translation.X, delta.Translation.Y);

            xform.Matrix = matrix;

            e.Handled = true;

            base.OnManipulationDelta(e);
        }
    }
}