mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 02:23:01 +08:00
feat: 猫猫 (#12017)
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
<Resource Include="newlogo.ico" />
|
||||
<Resource Include="Res\Backgrounds\*" />
|
||||
<Resource Include="Res\Img\*" />
|
||||
<Resource Include="Res\Img\EasterEgg\*" />
|
||||
<None Include="..\..\README.md" Pack="True" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -879,6 +879,11 @@ namespace MaaWpfGui.Main
|
||||
toast.Show();
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow.ToYjDate().IsAprilFoolsDay())
|
||||
{
|
||||
Instances.TaskQueueViewModel.GifVisibility = true;
|
||||
}
|
||||
|
||||
// Instances.TaskQueueViewModel.CheckAndShutdown();
|
||||
Instances.TaskQueueViewModel.CheckAfterCompleted();
|
||||
}
|
||||
|
||||
BIN
src/MaaWpfGui/Res/Img/EasterEgg/1.gif
Normal file
BIN
src/MaaWpfGui/Res/Img/EasterEgg/1.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
BIN
src/MaaWpfGui/Res/Img/EasterEgg/2.gif
Normal file
BIN
src/MaaWpfGui/Res/Img/EasterEgg/2.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
@@ -22,6 +22,8 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using MaaWpfGui.Constants;
|
||||
using MaaWpfGui.Extensions;
|
||||
using MaaWpfGui.Helper;
|
||||
@@ -37,8 +39,9 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
using Stylet;
|
||||
using StyletIoC;
|
||||
using Application = System.Windows.Application;
|
||||
using IContainer = StyletIoC.IContainer;
|
||||
using Point = System.Windows.Point;
|
||||
using Screen = Stylet.Screen;
|
||||
|
||||
namespace MaaWpfGui.ViewModels.UI
|
||||
@@ -2223,13 +2226,15 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
foreach (var type in types)
|
||||
{
|
||||
// 获取 Instance 字段
|
||||
if (type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static) is PropertyInfo property)
|
||||
if (type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static) is not { } property)
|
||||
{
|
||||
// 获取实例
|
||||
if (property.GetValue(null) is TaskViewModel instance)
|
||||
{
|
||||
yield return instance;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取实例
|
||||
if (property.GetValue(null) is TaskViewModel instance)
|
||||
{
|
||||
yield return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2242,5 +2247,90 @@ 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 = 0;
|
||||
|
||||
private static string _gifPath = _gitList[_gifIndex];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,5 +350,17 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</hc:ScrollViewer>
|
||||
<hc:GifImage
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Width="100"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
MouseLeftButtonDown="{s:Action DraggableElementMouseLeftButtonDown}"
|
||||
MouseLeftButtonUp="{s:Action DraggableElementMouseLeftButtonUp}"
|
||||
MouseMove="{s:Action DraggableElementMouseMove}"
|
||||
MouseRightButtonDown="{s:Action ChangeGif}"
|
||||
Uri="{Binding GifPath}"
|
||||
Visibility="{c:Binding GifVisibility}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user