Welcome

首页 / 软件开发 / .NET编程技术 / WPF实现图片浏览的伪3D效果

WPF实现图片浏览的伪3D效果2015-01-01首先上效果图:

因项目要求,需要把图片以“好看”、“炫”的效果展示出来,特地研究了一下WPF关于3D方面的制作,奈何最终成果只是能够画出一个立方体并使之旋转。

项目时间仅剩两天,只好放弃3D另找出路,于是就想起了Flash中各种“炫丽”的动画效果,图片按椭圆排列,并且旋转。

于是开始代码,然后发现关于椭圆啊、正玄余玄、x,y,r等等数学知识都忘得光光了,仅有思路没有进展,无奈之下开始百度恶补数学知识。图形变换、3D是很考验数学知识的,本人对于3D方面的学习就败在数学之下,高中数学学的还不错的,现在……哎,不提也罢。

然后找到这么一篇博文——,是js代码,在此感谢这位大大的无私奉献。

下面正式上代码:

定义ImageInfo类,实现INotifyPropertyChanged接口,属性没有写说明,不过看名称我想各位也能知道是什么含义了。

public class ImageInfo : INotifyPropertyChanged{private int _zIndex;public int ZIndex{get { return _zIndex; }set{if (value != _zIndex){_zIndex = value;this.NotifyPropertyChanged("ZIndex");}}}private double _left;public double Left{get { return _left; }set{if (value != _left){_left = value;this.NotifyPropertyChanged("Left");}}}private double _top;public double Top{get { return _top; }set{if (value != _top){_top = value;this.NotifyPropertyChanged("Top");}}}private double _width;public double Width{get { return _width; }set{if (value != _width){_width = value;this.NotifyPropertyChanged("Width");}}}private double _height;public double Height{get { return _height; }set{if (value != _height){_height = value;this.NotifyPropertyChanged("Height");}}}private double _opacity = 1.0;public double Opactity{get { return _opacity; }set{if (value != _opacity){_opacity = value;this.NotifyPropertyChanged("Opactity");}}}private string _imagePath;public string ImagePath{get { return _imagePath; }set{if (value != _imagePath){_imagePath = value;this.NotifyPropertyChanged("ImagePath");}}}public ImageInfo(string path){this.ImagePath = path;}public event PropertyChangedEventHandler PropertyChanged;private void NotifyPropertyChanged(String propertyName){PropertyChangedEventHandler handler = PropertyChanged;if (null != handler){handler(this, new PropertyChangedEventArgs(propertyName));}}}ViewModel Code