diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs
index ed7c026c1e..bb6463773b 100644
--- a/src/MaaWpfGui/Main/AsstProxy.cs
+++ b/src/MaaWpfGui/Main/AsstProxy.cs
@@ -899,8 +899,11 @@ namespace MaaWpfGui.Main
if (DateTime.UtcNow.ToYjDate().IsAprilFoolsDay())
{
- Instances.TaskQueueViewModel.GifVisibility = true;
- Instances.TaskQueueViewModel.ChangeGif();
+ if (Application.Current.MainWindow?.DataContext is RootViewModel rvm)
+ {
+ rvm.GifVisibility = true;
+ rvm.ChangeGif();
+ }
}
// Instances.TaskQueueViewModel.CheckAndShutdown();
diff --git a/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs b/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs
index 9960eb7e06..e7a88e501b 100644
--- a/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/RootViewModel.cs
@@ -11,9 +11,13 @@
// but WITHOUT ANY WARRANTY
//
+#nullable enable
+
using System;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Media;
using HandyControl.Tools;
using MaaWpfGui.Constants;
@@ -175,9 +179,9 @@ namespace MaaWpfGui.ViewModels.UI
}
}
- private Brush _windowTopMostButtonForeground = (SolidColorBrush)Application.Current.FindResource("PrimaryTextBrush");
+ private Brush? _windowTopMostButtonForeground = (SolidColorBrush?)Application.Current.FindResource("PrimaryTextBrush");
- public Brush WindowTopMostButtonForeground
+ public Brush? WindowTopMostButtonForeground
{
get => _windowTopMostButtonForeground;
set => SetAndNotify(ref _windowTopMostButtonForeground, value);
@@ -189,8 +193,8 @@ namespace MaaWpfGui.ViewModels.UI
{
IsWindowTopMost = !IsWindowTopMost;
WindowTopMostButtonForeground = IsWindowTopMost
- ? (Brush)Application.Current.FindResource("TitleBrush")
- : (Brush)Application.Current.FindResource("PrimaryTextBrush");
+ ? (Brush?)Application.Current.FindResource("TitleBrush")
+ : (Brush?)Application.Current.FindResource("PrimaryTextBrush");
}
///
@@ -198,5 +202,91 @@ namespace MaaWpfGui.ViewModels.UI
{
Bootstrapper.Shutdown();
}
+
+ private static readonly string[] _gitList =
+ [
+ "/Res/Img/EasterEgg/1.gif",
+ "/Res/Img/EasterEgg/2.gif",
+ ];
+
+ private static int _gifIndex = -1;
+
+ private static string? _gifPath = null;
+
+ public string? GifPath
+ {
+ get => _gifPath;
+ set => SetAndNotify(ref _gifPath, value);
+ }
+
+ private bool _gifVisibility = true;
+
+ public bool GifVisibility
+ {
+ get => _gifVisibility;
+ set => SetAndNotify(ref _gifVisibility, value);
+ }
+
+ // ReSharper disable once UnusedMember.Global
+ public void ChangeGif()
+ {
+ if (++_gifIndex >= _gitList.Length)
+ {
+ _gifIndex = 0;
+ }
+
+ GifPath = _gitList[_gifIndex];
+ }
+
+ private static bool _isDragging = false;
+ private static Point _offset;
+
+ // ReSharper disable once UnusedMember.Global
+ public void DraggableElementMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ if (sender is not HandyControl.Controls.GifImage childElement)
+ {
+ return;
+ }
+
+ _isDragging = true;
+ _offset = e.GetPosition(childElement);
+ childElement.CaptureMouse();
+ }
+
+ // ReSharper disable once UnusedMember.Global
+ public void DraggableElementMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (sender is not HandyControl.Controls.GifImage childElement)
+ {
+ return;
+ }
+
+ _isDragging = false;
+ childElement.ReleaseMouseCapture();
+ }
+
+ // ReSharper disable once UnusedMember.Global
+ public void DraggableElementMouseMove(object sender, MouseEventArgs e)
+ {
+ if (!_isDragging || sender is not HandyControl.Controls.GifImage { Parent: Grid parentElement } childElement)
+ {
+ return;
+ }
+
+ Point currentPosition = e.GetPosition(parentElement);
+
+ // 计算偏移量
+ double newX = currentPosition.X - _offset.X;
+ double newY = currentPosition.Y - _offset.Y;
+
+ // 确保元素在父元素范围内
+ newX = Math.Max(10, Math.Min(newX, parentElement.ActualWidth - childElement.ActualWidth - 10));
+ newY = Math.Max(10, Math.Min(newY, parentElement.ActualHeight - childElement.ActualHeight - 10));
+
+ childElement.HorizontalAlignment = HorizontalAlignment.Left;
+ childElement.VerticalAlignment = VerticalAlignment.Top;
+ childElement.Margin = new(newX, newY, 10, 10);
+ }
}
}
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index baeb95e20b..48a4d808c2 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -2247,90 +2247,5 @@ namespace MaaWpfGui.ViewModels.UI
instance.ProcSubTaskMsg(msg, details);
}
}
-
- private static readonly string[] _gitList =
- [
- "/Res/Img/EasterEgg/1.gif",
- "/Res/Img/EasterEgg/2.gif",
- ];
-
- private static int _gifIndex = -1;
-
- private static string _gifPath = null;
-
- public string GifPath
- {
- get => _gifPath;
- set => SetAndNotify(ref _gifPath, value);
- }
-
- private bool _gifVisibility = false;
-
- public bool GifVisibility
- {
- get => _gifVisibility;
- set => SetAndNotify(ref _gifVisibility, value);
- }
-
- // ReSharper disable once UnusedMember.Global
- public void ChangeGif()
- {
- if (++_gifIndex >= _gitList.Length)
- {
- _gifIndex = 0;
- }
-
- GifPath = _gitList[_gifIndex];
- }
-
- private static bool _isDragging = false;
- private static Point _offset;
-
- // ReSharper disable once UnusedMember.Global
- public void DraggableElementMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- if (sender is not HandyControl.Controls.GifImage childElement)
- {
- return;
- }
-
- _isDragging = true;
- _offset = e.GetPosition(childElement);
- childElement.CaptureMouse();
- }
-
- public void DraggableElementMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- if (sender is not HandyControl.Controls.GifImage childElement)
- {
- return;
- }
-
- _isDragging = false;
- childElement.ReleaseMouseCapture();
- }
-
- // ReSharper disable once UnusedMember.Global
- public void DraggableElementMouseMove(object sender, MouseEventArgs e)
- {
- if (!_isDragging || sender is not HandyControl.Controls.GifImage { Parent: Grid parentElement } childElement)
- {
- return;
- }
-
- Point currentPosition = e.GetPosition(parentElement);
-
- // 计算偏移量
- double newX = currentPosition.X - _offset.X;
- double newY = currentPosition.Y - _offset.Y;
-
- // 确保元素在父元素范围内
- newX = Math.Max(0, Math.Min(newX, parentElement.ActualWidth - childElement.ActualWidth - 10));
- newY = Math.Max(0, Math.Min(newY, parentElement.ActualHeight - childElement.ActualHeight - 10));
-
- childElement.HorizontalAlignment = HorizontalAlignment.Left;
- childElement.VerticalAlignment = VerticalAlignment.Top;
- childElement.Margin = new(newX, newY, 0, 0);
- }
}
}
diff --git a/src/MaaWpfGui/Views/UI/RootView.xaml b/src/MaaWpfGui/Views/UI/RootView.xaml
index e4281a9f3b..569e98cee5 100644
--- a/src/MaaWpfGui/Views/UI/RootView.xaml
+++ b/src/MaaWpfGui/Views/UI/RootView.xaml
@@ -53,22 +53,35 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+