直接贴代码 废话不多说了。
运行环境 vs11 beta framework4.5 surface runtime surface sdk 2.0 多点触控模拟器 multitouchVista 或多点触控设备 源码请关注我的资源下载 功能说明: 多点触控时间轴,事件可缩放 旋转 多点同时操作 放大缩小等,时间范围0001-9980年 定位精确到天
时间轴数据加载格式如下: <?xml version="1.0" encoding="utf-8" ?> <data> <event imgUrl="Sample_Photos" start="2011/1/05" mediaUrl ="C:\Resources\Video\test.mp4" type="2" title="苹果" > iphone4s</event>
</data>主控件 1 XAML:
主控件背后代码:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;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;using System.Xml.Linq;namespace Transvalue.Timeline{ ////// TransvalueTimeline.xaml 的交互逻辑 /// public partial class TransvalueTimeline : UserControl { public TransvalueTimeline() { InitializeComponent(); var data = from item in XElement.Load("Data.xml").Elements("event") let title = item.Attribute("title") let content = item.Attribute("content") let date = item.Attribute("start") let imgUrl = item.Attribute("imgUrl") let mediaUrl = item.Attribute("mediaUrl") let type = item.Attribute("type") select new TimelineEventItem { Title = title.Value, Content = item.Value, Date = Convert.ToDateTime(date.Value), MedieUrl = mediaUrl.Value, ImgUrl = imgUrl.Value, EventType = (TimelineEventEnum.TimelineEventType)Convert.ToInt32(type.Value) }; this.timeline.TimelineEventSource = new System.Collections.ObjectModel.ObservableCollection(data.OrderBy(item => item.Date)); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { timeline.LoadComplatedEH += LoadCompletedEvent; timeline.LoadingEH += LoadingEvent; timeline.ShowScatterEH += ((o, args) => { this.ShowMdiWindow(args.svi); }); } private async void LoadCompletedEvent(object sender, EventArgs e) { await Task.Factory.StartNew(() => { svContent.Children.Clear(); this.glowWorm.Visibility = System.Windows.Visibility.Hidden; }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } private async void LoadingEvent(object sender, EventArgs e) { await Task.Factory.StartNew(() => { this.glowWorm.Visibility = System.Windows.Visibility.Visible; }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } private void ShowMdiWindow(UIElement svi) { Console.WriteLine(svi.GetType().BaseType.Name); if (svi.GetType().BaseType.Name.Equals("UserControl")) { Canvas.SetTop(svi, svContent.Height / 2); Canvas.SetLeft(svi, svContent.Width / 2); svContent.Children.Add(svi); } else { Window win = svi as Window; win.ManipulationStarting += ((sender, e) => { Console.WriteLine("开始多点操作"); e.Manipulators.ForEach(i => Console.WriteLine(i)); }); win.Show(); } } }}