开发工具:
文件大小: 1mb
下载次数: 0
上传时间: 2011-09-04
详细说明: silverlight3鱼眼控件, using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Imaging; namespace LifeSonic.UI.Controls { public partial class FishEyeMenu : UserControl { public event RoutedEventHandler ImageClick; #region prop private bool initialized = false; private List _images = new List(); private static readonly DependencyProperty images = D ependencyProperty.Register("Datas",typeof(FishEyeData[]),typeof(FishEyeMenu),null); private static readonly DependencyProperty imageMargin = DependencyProperty.Register("ImageMargin", typeof(int), typeof(FishEyeMenu), null); private static readonly DependencyProperty imageWidth = DependencyProperty.Register("ImageWidth", typeof(int), typeof(FishEyeMenu), null); private static readonly DependencyProperty imageHeight = DependencyProperty.Register("ImageHeight", typeof(int), typeof(FishEyeMenu), null); private static readonly DependencyProperty maxScale = DependencyProperty.Register("MaxScale", typeof(int), typeof(FishEyeMenu), null); private static readonly DependencyProperty multiplier = DependencyProperty.Register("Multiplier", typeof(int), typeof(FishEyeMenu), null); public FishEyeData[] Datas { get { return (FishEyeData[])GetValue(images); } set { SetValue(images, value); if (initialized) BindImages(); } } public int ImageMargin { get { return (int)GetValue(imageMargin); } set { SetValue(imageMargin, value); } } public int ImageWidth { get { return (int)GetValue(imageWidth); } set { SetValue(imageWidth, value); } } public int ImageHeight { get { return (int)GetValue(imageHeight); } set { SetValue(imageHeight, value); } } public int MaxScale { get { return (int)GetValue(maxScale); } set { SetValue(maxScale, value); } } public int Multiplier { get { return (int)GetValue(multiplier); } set { SetValue(multiplier, value); } } #endregion public FishEyeMenu() { InitializeComponent(); initialized = true; BindImages(); this.MouseMove += new MouseEventHandler(FishEyeMenu_MouseMove); } void FishEyeMenu_MouseMove(object sender, MouseEventArgs e) { for (int i = 0; i < _images.Count; i++) { Image image = _images[i]; double imageScale = MaxScale - Math.Min(MaxScale - 1, Math.Abs(e.GetPosition(this).X - ((double)image.GetValue(Canvas.LeftProperty) + image.Width / 2)) / Multiplier); resizeImage(image, ImageWidth * imageScale, ImageHeight * imageScale, i, Datas.Length); image.SetValue(Canvas.ZIndexProperty, (int)Math.Round(ImageWidth * imageScale)); } } private void BindImages() { FishEyeData[] ims = Datas; if (ims != null && ims.Length > 0) { for (int i = 0; i < ims.Length; i++) { string url = ims[i].IamgePath; Image image = new Image(); image.Source = new BitmapImage(new Uri(url, UriKind.Relative)); image.Tag = ims[i]; string tootip = ims[i].Tootip; if (!String.IsNullOrEmpty(tootip)) image.SetValue(ToolTipService.ToolTipProperty,tootip); image.MouseLeftButtonDown += new MouseButtonEventHandler(image_MouseLeftButtonDown); image.Cursor = Cursors.Hand; resizeImage(image, ImageWidth, ImageHeight, i, ims.Length); LayoutRoot.Children.Add(image); _images.Add(image); } } } void image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Image img = (Image)sender; if (ImageClick != null) ImageClick(img.Tag, new RoutedEventArgs()); } private void resizeImage(Image image, double imageWidth, double imageHeight, int index, int total) { image.Width = imageWidth; image.Height = imageHeight; image.SetValue(Canvas.TopProperty, Height / 2 - image.Height / 2); image.SetValue(Canvas.LeftProperty, Width / 2 + (index - (total - 1) / 2) * (ImageMargin + ImageWidth) - image.Width / 2); } #region FishEye Data public class FishEyeData { public FishEyeData() { } public string Id { get; set; } public string IamgePath { get; set; } public string Tootip { get; set; } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.