WPF 鼠标移动到图片变大,移开还原,单击触发事件效果
2022-12-04站长百科下载本文单击,变大,移开,触发,鼠标
<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" );
}
}
|
WPF 鼠标移动到图片变大,移开还原,单击触发事件效果的相关教程结束。
《WPF 鼠标移动到图片变大,移开还原,单击触发事件效果.doc》
下载本文的Word格式文档,以方便收藏与打印。
-
-
-
[OpenCV-Python] 7 把鼠标当画笔
文章目录
OpenCV-Python: II OpenCV 中的 Gui 特性
7 把鼠标当画笔
7.1 简单演示
7.2 高级一点的示例
OpenCV-Python: II OpenCV 中的 Gui 特性
7 把鼠标当画笔
目标 • 学习使用 OpenCV 处理鼠标事件 • 你...
2023-07-31编程代码opencv,画笔,鼠标
-
js 之三 鼠标和键盘事件处理
鼠标和键盘事件
鼠标常见的事件,按下onmousedown,拖动onmounsemove,松开onmousevtup,滚轮等事件;
开发需求: 当鼠标点击控件,进行拖拽,控件跟随鼠标移动;
拖拽事件需求的实现思路分析:
1 首先鼠标选中对...
2023-07-29编程代码之三,键盘,鼠标
-
web自动化05-鼠标操作
鼠标操作方法
1、常见的鼠标操作
点击、右击、双击、悬停、拖拽等
2、selenium中的封装鼠标操作
说明:在Selenium中将操作鼠标的方法封装在ActionChains类中
实...
2023-07-29编程代码操作,自动化,鼠标
-
-
-
-
Base64编码字符串时数据量明显变大
那就是当把byte[]通过Convert.ToBase64String转换成Base64编码字符串时数据量明显变大
Base64编码的思想是是采用64个基本的ASCII码字符对数据进行重新编码。它将需要编码的数据拆分成字节数组。以3个字节为一组。...
2023-06-25编程教程变大,字符串,编码