<Grid>
        <Canvas x:Name="LayoutRoot">
            <Image Cursor="Hand" MouseLeftButtonDown="imgLogo1_MouseLeftButtonDown" MouseEnter="imgLogo1_MouseEnter"
                   MouseLeave="imgLogo1_MouseLeave" Canvas.ZIndex="1" x:Name="imgLogo1" Canvas.Left="100"
                   Canvas.Top="60" Height="100" Source="Image/Picture.jpg">
                <Image.RenderTransform>
                    <ScaleTransform x:Name="LogoScale" CenterX="90" CenterY="96">
 
                    </ScaleTransform>
                </Image.RenderTransform>
            </Image>
        </Canvas>
    </Grid>

  

public partial class Window8 : Window
   {
       public Window8()
       {
           InitializeComponent();
           timer = new System.Windows.Threading.DispatcherTimer();
           timer.Interval = TimeSpan.FromMilliseconds(50);
           timer.Tick += new EventHandler(timer_Tick);
       }
 
       private System.Windows.Threading.DispatcherTimer timer;
       private ScaleDirection scaleDirection ;
       
 
       void timer_Tick(object sender, EventArgs e)
       {
           AdjustScale(scaleDirection, LogoScale);
       }
 
       void AdjustScale(ScaleDirection scaleDirection, ScaleTransform scale)
       {
           if (scaleDirection == ScaleDirection.Down)
           {
               if (scale.ScaleX < 1.3)
               {
                   scale.ScaleX += 0.05; scale.ScaleY += 0.05;
               }
               else
                   timer.Stop();
           }
           else
           {
               if (scale.ScaleX > 1.0)
               {
                   scale.ScaleX -= 0.05;
                   scale.ScaleY -= 0.05;
               }
               else
                   timer.Stop();
           }
       }
 
       enum ScaleDirection
       {
           Up,
           Down
       }
 
       private void imgLogo1_MouseEnter(object sender, MouseEventArgs e)
       {
           scaleDirection = ScaleDirection.Down;
           timer.Start();
       }
 
       private void imgLogo1_MouseLeave(object sender, MouseEventArgs e)
       {
           scaleDirection = ScaleDirection.Up;
           timer.Start();
       }
 
       private void imgLogo1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
       {
           MessageBox.Show("test");
       }
   }

最新文章

  1. 从阿里巴巴IPO联想到创始人和资方关系
  2. 多媒体(1):MCI接口编程
  3. lua面试基础知识
  4. 编写一个Car类,具有String类型的属性品牌,具有功能drive; 定义其子类Aodi和Benchi,具有属性:价格、型号;具有功能:变速; 定义主类E,在其main方法中分别创建Aodi和Benchi的对象并测试对象的特 性。
  5. Vue 模板
  6. Jmeter初步使用三--使用jmeter自身录制脚本
  7. BZOJ 1625: [Usaco2007 Dec]宝石手镯( dp )
  8. spring的jar各包作用
  9. 【easy】653. Two Sum IV - Input is a BST
  10. [C][代码实例]冒泡排序
  11. nodejs stream 手册学习
  12. Java并发—synchronized关键字
  13. Spring MVC 学习 之 - 配置简单demo
  14. Vijos P1002 过河 (NOIP提高组2005)
  15. 理解JavaScript原始类型和引用类型
  16. Centos 7 快速安装 Docker
  17. AngularJS之页面跳转Route
  18. Java并发(5)- ReentrantLock与AQS
  19. vlan 配置
  20. Day2-VIM(一):移动

热门文章

  1. Three---面向对象与面向过程/属性和变量/关于self/一些魔法方法的使用/继承/super方法/多态
  2. Go 语言图片处理简明教程
  3. 杀死 Windows 某个端口
  4. 牛客IOI周赛26-提高组 A. 逆序对
  5. Star (欧拉函数)
  6. Swift中的Result 类型的简单介绍
  7. Python实现XMind测试用例快速转Excel用例
  8. KingbaseES 全局索引
  9. SpringBoot使用自定义注解+AOP+Redis实现接口限流
  10. ProxySQL(9):ProxySQL的查询缓存功能