mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
826c571773
实现 #109
81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using System.Windows.Forms;
|
|
using System.Windows.Interop;
|
|
using VPet_Simulator.Core;
|
|
|
|
namespace VPet_Simulator.Windows
|
|
{
|
|
/// <summary>
|
|
/// 窗体控制器实现
|
|
/// </summary>
|
|
public class MWController : IController
|
|
{
|
|
readonly MainWindow mw;
|
|
public MWController(MainWindow mw)
|
|
{
|
|
this.mw = mw;
|
|
}
|
|
|
|
public double GetWindowsDistanceLeft()
|
|
{
|
|
return mw.Dispatcher.Invoke(() => mw.Left);
|
|
}
|
|
|
|
public double GetWindowsDistanceUp()
|
|
{
|
|
return mw.Dispatcher.Invoke(() => mw.Top);
|
|
}
|
|
|
|
public double GetWindowsDistanceRight()
|
|
{
|
|
return mw.Dispatcher.Invoke(() =>
|
|
{
|
|
var windowInteropHelper = new WindowInteropHelper(mw);
|
|
var currentScreen = Screen.FromHandle(windowInteropHelper.Handle);
|
|
var currentScreenBorder = currentScreen.Bounds;
|
|
return currentScreenBorder.Width - mw.Left - mw.Width;
|
|
});
|
|
}
|
|
|
|
public double GetWindowsDistanceDown()
|
|
{
|
|
return mw.Dispatcher.Invoke(() =>
|
|
{
|
|
var windowInteropHelper = new WindowInteropHelper(mw);
|
|
var currentScreen = Screen.FromHandle(windowInteropHelper.Handle);
|
|
var currentScreenBorder = currentScreen.Bounds;
|
|
return currentScreenBorder.Height - mw.Top - mw.Height;
|
|
});
|
|
}
|
|
|
|
public void MoveWindows(double X, double Y)
|
|
{
|
|
mw.Dispatcher.Invoke(() =>
|
|
{
|
|
mw.Left += X * ZoomRatio;
|
|
mw.Top += Y * ZoomRatio;
|
|
});
|
|
}
|
|
|
|
public void ShowSetting()
|
|
{
|
|
mw.Topmost = false;
|
|
mw.ShowSetting();
|
|
}
|
|
|
|
public void ShowPanel()
|
|
{
|
|
var panelWindow = new winCharacterPanel();
|
|
panelWindow.ShowDialog();
|
|
}
|
|
|
|
public double ZoomRatio => mw.Set.ZoomLevel;
|
|
|
|
public int PressLength => mw.Set.PressLength;
|
|
|
|
public bool EnableFunction => mw.Set.EnableFunction;
|
|
|
|
public int InteractionCycle => mw.Set.InteractionCycle;
|
|
|
|
}
|
|
}
|