鱼眼菜单功能

鱼眼菜单功能: 获取 Microsoft Silverlight

 

   void  FishEyeMenu_MouseMove(object sender, MouseEventArgs e)

        {
            
for(int i = 0 ; i < _images.Count; i++){
                Image image  
= _images[i];    

                
                
// compute the scale of each image according to the mouse position
                double imageScale = MAX_SCALE - Math.Min(MAX_SCALE - 1, Math.Abs(e.GetPosition(this).X - ((double) image.GetValue(Canvas.LeftProperty) + image.Width / 2)) / MULTIPLIER);
                
// resize the image
                resizeImage(image, IMAGE_WIDTH * imageScale, IMAGE_HEIGHT * imageScale, i, IMAGES.Length);

                
// sort the children according to the scale
                image.SetValue(Canvas.ZIndexProperty, (int) Math.Round(IMAGE_WIDTH * imageScale));
            }
        }

 

 

 

代码
    // resize the image
        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);
            
double width =  Width / 2 + (index - (total - 1/ 2* (MARGIN + IMAGE_WIDTH) - image.Width / 2 +100;          
            image.SetValue(Canvas.LeftProperty, width);
        }

 

posted @ 2010-08-06 12:00  林强  阅读(814)  评论(1编辑  收藏  举报