您好,欢迎光临本网站![请登录][注册会员]  
文件名称: WPF 3D图书 可翻页和写字 源码
  所属分类: Web开发
  开发工具:
  文件大小: 602kb
  下载次数: 0
  上传时间: 2013-04-19
  提 供 者: sdf3*****
 详细说明: using System; using System.Speech.Synthesis; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Animation; using System.Windows.Media.Media3D; namespace BookWriter3D { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { /// /// Public constructor /// public MainWindow() { InitializeComponent(); } /// /// Represents whether the book is open or not. /// bool IsBookOpen; /// /// Event handler for the Loaded event of the MainWindow /// private void MainWindow_Loaded(object sender, RoutedEventArgs e) { CloseBook(0); // Book starts closed // Make book fade in DoubleAnimation da = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(2))); da.DecelerationRatio = 1; _Main3D.BeginAnimation(UIElement.OpacityProperty, da); } /// /// Event handler for the MouseDown event of the cover, back cover, spine and edges /// private void Cover_MouseDown(object sender, MouseButtonEventArgs e) { if (IsBookOpen) CloseBook(1.5); else OpenBook(1.5); } /// /// Event handler for the MouseDoubleClick event of the TextBoxes /// private void Page_MouseDoubleClick(object sender, MouseButtonEventArgs e) { // Read page content out loud SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SpeakAsync(((TextBox)sender).Text); } /// /// Event handler for the PreviewMouseRightButtonDown event of the InkCanvas (right page) /// private void InkCanvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { // Switch InkCanvas editing mode InkCanvas ic = sender as InkCanvas; ic.EditingMode = (ic.EditingMode == InkCanvasEditingMode.Ink) ? InkCanvasEditingMode.EraseByPoint : InkCanvasEditingMode.Ink; } /// /// Opens the 3D book. /// /// Time in seconds that the animation will take. void OpenBook(double durationSeconds) { // Transform3D_LeftRotation RotateTransform3D rot = (RotateTransform3D)TryFindResource("Transform3D_LeftRotation"); DoubleAnimation da = new DoubleAnimation(15, new Duration(TimeSpan.FromSeconds(durationSeconds))); da.DecelerationRatio = 1; rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_RightRotation rot = (RotateTransform3D)TryFindResource("Transform3D_RightRotation"); da = new DoubleAnimation(-15, new Duration(TimeSpan.FromSeconds(durationSeconds))); rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_SpineRotation rot = (RotateTransform3D)TryFindResource("Transform3D_SpineRotation"); da = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.8333 * durationSeconds))); rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_SpineCoverTranslation TranslateTransform3D trans = (TranslateTransform3D)TryFindResource("Transform3D_SpineCoverTranslation"); da = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.8333 * durationSeconds))); trans.BeginAnimation(TranslateTransform3D.OffsetXProperty, da); // _Main3D.Camera Point3DAnimation pa = new Point3DAnimation(new Point3D(0, -2.5, 6.5), new Duration(TimeSpan.FromSeconds(durationSeconds))); pa.AccelerationRatio = 0.5; pa.DecelerationRatio = 0.5; ((PerspectiveCamera)_Main3D.Camera).BeginAnimation(PerspectiveCamera.PositionProperty, pa); // Now the book is open. IsBookOpen = true; } /// /// Closes the 3D book. /// /// Time in seconds that the animation will take. void CloseBook(double durationSeconds) { // Transform3D_LeftRotation RotateTransform3D rot = (RotateTransform3D)TryFindResource("Transform3D_LeftRotation"); DoubleAnimation da = new DoubleAnimation(180, new Duration(TimeSpan.FromSeconds(durationSeconds))); da.DecelerationRatio = 1; rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_RightRotation rot = (RotateTransform3D)TryFindResource("Transform3D_RightRotation"); da = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(durationSeconds))); rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_SpineRotation rot = (RotateTransform3D)TryFindResource("Transform3D_SpineRotation"); da = new DoubleAnimation(90, new Duration(TimeSpan.FromSeconds(0.8333 * durationSeconds))); rot.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da); // Transform3D_SpineCoverTranslation TranslateTransform3D trans = (TranslateTransform3D)TryFindResource("Transform3D_SpineCoverTranslation"); da = new DoubleAnimation(-0.125, new Duration(TimeSpan.FromSeconds(0.8333 * durationSeconds))); trans.BeginAnimation(TranslateTransform3D.OffsetXProperty, da); // _Main3D.Camera Point3DAnimation pa = new Point3DAnimation(new Point3D(0.72, -2.5, 6.5), new Duration(TimeSpan.FromSeconds(durationSeconds))); pa.AccelerationRatio = 0.5; pa.DecelerationRatio = 0.5; ((PerspectiveCamera)_Main3D.Camera).BeginAnimation(PerspectiveCamera.PositionProperty, pa); // Now the book is closed. IsBookOpen = false; } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: WPF 3D 图书 翻页 写字
 输入关键字,在本站1000多万海量源码库中尽情搜索: