From fec9f514fc0d49ae02ca70903963757507965bf0 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Tue, 12 Mar 2024 19:36:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=AA=97=E4=BD=93=E5=A4=96?= =?UTF-8?q?=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/MessageBar.xaml | 3 +- .../Function/MWController.cs | 24 +++++------ VPet-Simulator.Windows/MainWindow.cs | 43 +++++++++++++------ VPet-Simulator.Windows/MainWindow.xaml | 12 +++--- 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml b/VPet-Simulator.Core/Display/MessageBar.xaml index 80d76d3..660d5df 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml +++ b/VPet-Simulator.Core/Display/MessageBar.xaml @@ -23,7 +23,8 @@ Background="{x:Null}" /> + TextWrapping="WrapWithOverflow" FontSize="24" x:FieldModifier="public" Background="{x:Null}" + BorderBrush="{x:Null}" BorderThickness="0" /> diff --git a/VPet-Simulator.Windows/Function/MWController.cs b/VPet-Simulator.Windows/Function/MWController.cs index bba350b..52172fc 100644 --- a/VPet-Simulator.Windows/Function/MWController.cs +++ b/VPet-Simulator.Windows/Function/MWController.cs @@ -72,8 +72,8 @@ namespace VPet_Simulator.Windows { return mw.Dispatcher.Invoke(() => { - if (IsPrimaryScreen) return System.Windows.SystemParameters.PrimaryScreenWidth - mw.Left - mw.Width; - return ScreenBorder.Width + ScreenBorder.X - mw.Left - mw.Width; + if (IsPrimaryScreen) return System.Windows.SystemParameters.PrimaryScreenWidth - mw.Left - mw.ActualWidth; + return ScreenBorder.Width + ScreenBorder.X - mw.Left - mw.ActualWidth; }); } @@ -81,8 +81,8 @@ namespace VPet_Simulator.Windows { return mw.Dispatcher.Invoke(() => { - if (IsPrimaryScreen) return System.Windows.SystemParameters.PrimaryScreenHeight - mw.Top - mw.Height; - return ScreenBorder.Height + ScreenBorder.Y - mw.Top - mw.Height; + if (IsPrimaryScreen) return System.Windows.SystemParameters.PrimaryScreenHeight - mw.Top - mw.ActualHeight; + return ScreenBorder.Height + ScreenBorder.Y - mw.Top - mw.ActualHeight; }); } @@ -111,29 +111,29 @@ namespace VPet_Simulator.Windows { mw.Dispatcher.Invoke(() => { - if (GetWindowsDistanceUp() < -0.25 * mw.Height && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight) + if (GetWindowsDistanceUp() < -0.25 * mw.ActualHeight && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight) { MoveWindows(0, -GetWindowsDistanceUp() / ZoomRatio); } - else if (GetWindowsDistanceDown() < -0.25 * mw.Height && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight) + else if (GetWindowsDistanceDown() < -0.25 * mw.ActualHeight && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight) { MoveWindows(0, GetWindowsDistanceDown() / ZoomRatio); } - if (GetWindowsDistanceLeft() < -0.25 * mw.Width && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth) + if (GetWindowsDistanceLeft() < -0.25 * mw.ActualWidth && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth) { MoveWindows(-GetWindowsDistanceLeft() / ZoomRatio, 0); } - else if (GetWindowsDistanceRight() < -0.25 * mw.Width && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth) + else if (GetWindowsDistanceRight() < -0.25 * mw.ActualWidth && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth) { MoveWindows(GetWindowsDistanceRight() / ZoomRatio, 0); } }); } public bool CheckPosition() => mw.Dispatcher.Invoke(() => - GetWindowsDistanceUp() < -0.25 * mw.Height && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight - || GetWindowsDistanceDown() < -0.25 * mw.Height && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight - || GetWindowsDistanceLeft() < -0.25 * mw.Width && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth - || GetWindowsDistanceRight() < -0.25 * mw.Width && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth + GetWindowsDistanceUp() < -0.25 * mw.ActualHeight && GetWindowsDistanceDown() < System.Windows.SystemParameters.PrimaryScreenHeight + || GetWindowsDistanceDown() < -0.25 * mw.ActualHeight && GetWindowsDistanceUp() < System.Windows.SystemParameters.PrimaryScreenHeight + || GetWindowsDistanceLeft() < -0.25 * mw.ActualWidth && GetWindowsDistanceRight() < System.Windows.SystemParameters.PrimaryScreenWidth + || GetWindowsDistanceRight() < -0.25 * mw.ActualWidth && GetWindowsDistanceLeft() < System.Windows.SystemParameters.PrimaryScreenWidth ); public bool RePostionActive { get; set; } = true; diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 50e0b09..ee9e0ba 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -36,6 +36,7 @@ using static VPet_Simulator.Windows.Interface.ExtensionFunction; using Image = System.Windows.Controls.Image; using System.Data; using System.Windows.Media; +using System.Windows.Threading; namespace VPet_Simulator.Windows { @@ -266,7 +267,7 @@ namespace VPet_Simulator.Windows { Set.ZoomLevel = zl; //this.Height = 500 * zl; - this.Width = 500 * zl; + MGrid.Width = 500 * zl; if (petHelper != null) { petHelper.Width = 50 * zl; @@ -1207,8 +1208,8 @@ namespace VPet_Simulator.Windows InitializeComponent(); - this.Height = 500 * Set.ZoomLevel; - this.Width = 500 * Set.ZoomLevel; + //MGrid.Height = 500 * Set.ZoomLevel; + MGrid.Width = 500 * Set.ZoomLevel; double L = 0, T = 0; if (Set.StartRecordLast) @@ -1231,12 +1232,30 @@ namespace VPet_Simulator.Windows // control position inside bounds Core.Controller = new MWController(this); - double dist; - if ((dist = Core.Controller.GetWindowsDistanceLeft()) < 0) Left -= dist; - if ((dist = Core.Controller.GetWindowsDistanceRight()) < 0) Left += dist; - if ((dist = Core.Controller.GetWindowsDistanceUp()) < 0) Top -= dist; - if ((dist = Core.Controller.GetWindowsDistanceDown()) < 0) Top += dist; - + Task.Run(() => + { + double dist; + if ((dist = Core.Controller.GetWindowsDistanceLeft()) < 0) + { + Thread.Sleep(100); + Dispatcher.Invoke(() => Left -= dist); + } + if ((dist = Core.Controller.GetWindowsDistanceRight()) < 0) + { + Thread.Sleep(100); + Dispatcher.Invoke(() => Left += dist); + } + if ((dist = Core.Controller.GetWindowsDistanceUp()) < 0) + { + Thread.Sleep(100); + Dispatcher.Invoke(() => Top -= dist); + } + if ((dist = Core.Controller.GetWindowsDistanceDown()) < 0) + { + Thread.Sleep(100); + Dispatcher.Invoke(() => Top += dist); + } + }); if (Set.TopMost) { Topmost = true; @@ -1735,7 +1754,7 @@ namespace VPet_Simulator.Windows if (Set.MessageBarOutside) Main.MsgBar.SetPlaceOUT(); - Main.ToolBar.WorkCheck = WorkCheck; + Main.WorkCheck = WorkCheck; //加载图标 notifyIcon = new NotifyIcon(); @@ -1926,8 +1945,8 @@ namespace VPet_Simulator.Windows { if (Main.ToolBar.BdrPanel.Visibility == Visibility.Visible) { - tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100}" + - (GameSavesData.GameSave.LevelMax == 0 ? "" : $" x{GameSavesData.GameSave.LevelMax}"); + if (GameSavesData.GameSave.LevelMax != 0) + tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100} x{GameSavesData.GameSave.LevelMax}"; } } #if NewYear diff --git a/VPet-Simulator.Windows/MainWindow.xaml b/VPet-Simulator.Windows/MainWindow.xaml index 7d541e8..f7cc4b4 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml +++ b/VPet-Simulator.Windows/MainWindow.xaml @@ -5,15 +5,17 @@ xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ShowInTaskbar="False" xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" WindowStyle="None" Title="MainWindow" - Width="250" Closed="Window_Closed" pu:WindowXCaption.Height="0" SizeToContent="Height" + Closed="Window_Closed" pu:WindowXCaption.Height="0" SizeToContent="WidthAndHeight" Loaded="Window_SourceInitialized" LocationChanged="WindowX_LocationChanged" Background="{x:Null}"> -