Files
better-genshin-impact/BetterGenshinImpact/View/Controls/Drawer/DrawerViewModel.cs
辉鸭蛋 6f87a0c4d0 脚本仓库V2 (#1707)
* feat: add custom drawer control and integrate it into the UI

* 更新仓库UI

* feat: implement Git-based repository update mechanism and improve error handling

* feat: add reset repository functionality with confirmation dialog

* 修改打开队伍配置界面的重试次数和日志

* feat: add drawer open/close events and improve drawer closing logic

* feat: enhance WebpagePanel navigation handling and improve initialization logic

* feat: add drawer opened event handling and improve navigation completion logic

* feat: implement dynamic height adjustment for WebpagePanel using Grid container

* feat: update drawer dimensions and apply dynamic sizing based on position

* feat: add CustomDrawer component and integrate with MapPathingViewModel for enhanced navigation

* feat: integrate WebView2 for Markdown file navigation in MapPathingViewModel
2025-06-17 03:13:56 +08:00

72 lines
1.6 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.ComponentModel;
using System.Windows.Input;
namespace BetterGenshinImpact.View.Controls.Drawer;
public partial class DrawerViewModel : ObservableObject
{
[ObservableProperty]
private bool _isDrawerOpen;
[ObservableProperty]
private object? _drawerContent;
[ObservableProperty]
private DrawerPosition _drawerPosition = DrawerPosition.Right;
[ObservableProperty]
private double _drawerWidth = 400;
[ObservableProperty]
private double _drawerHeight = 300;
[ObservableProperty]
private RelayCommand _onDrawerOpenedCommand;
[ObservableProperty]
private RelayCommand<CancelEventArgs> _onDrawerClosingCommand;
public void setDrawerOpenedAction(Action action)
{
OnDrawerOpenedCommand = new RelayCommand(action!);
}
public void SetDrawerClosingAction(Action<CancelEventArgs> action)
{
OnDrawerClosingCommand = new RelayCommand<CancelEventArgs>(action!);
}
[RelayCommand]
public void OpenDrawer(object content)
{
DrawerContent = content;
IsDrawerOpen = true;
}
[RelayCommand]
public void CloseDrawer()
{
IsDrawerOpen = false;
}
[RelayCommand]
public void ToggleDrawer(object? content = null)
{
if (IsDrawerOpen)
{
CloseDrawer();
}
else
{
if (content != null)
{
DrawerContent = content;
}
IsDrawerOpen = true;
}
}
}