VPet/VPet-Simulator.Windows/MWController.cs

55 lines
1.6 KiB
C#
Raw Normal View History

2022-12-13 07:10:18 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
namespace VPet_Simulator.Windows
{
2022-12-14 18:17:13 +00:00
/// <summary>
/// 窗体控制器实现
/// </summary>
2022-12-13 07:10:18 +00:00
public class MWController : IController
{
2022-12-14 18:17:13 +00:00
readonly MainWindow mw;
2022-12-13 07:10:18 +00:00
public MWController(MainWindow mw)
{
this.mw = mw;
}
2022-12-14 18:17:13 +00:00
public double WindowsWidth { get => mw.Dispatcher.Invoke(() => mw.Width); set => mw.Dispatcher.Invoke(() => mw.Width = value); }
public double WindowsHight { get => mw.Dispatcher.Invoke(() => mw.Height); set => mw.Dispatcher.Invoke(() => mw.Height = value); }
2022-12-13 07:10:18 +00:00
2022-12-14 18:17:13 +00:00
public double GetWindowsDistanceDown()
2022-12-13 07:10:18 +00:00
{
2022-12-14 18:17:13 +00:00
return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenHeight - mw.Top - mw.Height);
2022-12-13 07:10:18 +00:00
}
2022-12-14 18:17:13 +00:00
public double GetWindowsDistanceLeft()
2022-12-13 07:10:18 +00:00
{
2022-12-14 18:17:13 +00:00
return mw.Dispatcher.Invoke(() => mw.Left);
2022-12-13 07:10:18 +00:00
}
2022-12-14 18:17:13 +00:00
public double GetWindowsDistanceRight()
2022-12-13 07:10:18 +00:00
{
2022-12-14 18:17:13 +00:00
return mw.Dispatcher.Invoke(() => System.Windows.SystemParameters.PrimaryScreenWidth - mw.Left - mw.Width);
2022-12-13 07:10:18 +00:00
}
2022-12-14 18:17:13 +00:00
public double GetWindowsDistanceUp()
2022-12-13 07:10:18 +00:00
{
2022-12-14 18:17:13 +00:00
return mw.Dispatcher.Invoke(() => mw.Top);
2022-12-13 07:10:18 +00:00
}
2022-12-14 18:17:13 +00:00
public void MoveWindows(double X, double Y)
2022-12-13 07:10:18 +00:00
{
2022-12-14 18:17:13 +00:00
mw.Dispatcher.Invoke(() =>
{
mw.Left += X * ZoomRatio;
mw.Top += Y * ZoomRatio;
});
2022-12-13 07:10:18 +00:00
}
2022-12-14 18:17:13 +00:00
public double ZoomRatio => 0.5;
2022-12-13 07:10:18 +00:00
}
}