MainWindow.xaml.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WpfZoom
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
/// <summary>
/// 半透明矩形框移动
/// </summary>
private void MoveRect_MouseMove(object sender, MouseEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
//计算鼠标在X轴的移动距离
double deltaV = e.GetPosition(MoveRect).Y - MoveRect.Height / 2;
//计算鼠标在Y轴的移动距离
double deltaH = e.GetPosition(MoveRect).X - MoveRect.Width / 2; ;
//得到图片Top新位置
double newTop = deltaV + (double)MoveRect.GetValue(Canvas.TopProperty);
//得到图片Left新位置
double newLeft = deltaH + (double)MoveRect.GetValue(Canvas.LeftProperty);
//边界的判断
if (newLeft <= 0)
{
newLeft = 0;
}
//左侧图片框宽度 - 半透明矩形框宽度
if (newLeft >= (this.SmallBox.Width - this.MoveRect.Width))
{
newLeft = this.SmallBox.Width - this.MoveRect.Width;
}
if (newTop <= 0)
{
newTop = 0;
}
//左侧图片框高度度 - 半透明矩形框高度度
if (newTop >= this.SmallBox.Height - this.MoveRect.Height)
{
newTop = this.SmallBox.Height - this.MoveRect.Height;
}
MoveRect.SetValue(Canvas.TopProperty, newTop);
MoveRect.SetValue(Canvas.LeftProperty, newLeft);
#region
//获取右侧大图框与透明矩形框的尺寸比率
double n = this.BigBox.Width / this.MoveRect.Width;
后面还有 22 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。