mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-23 09:55:48 +08:00
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
||
using System.Windows;
|
||
using BetterGenshinImpact.Helpers.Ui;
|
||
using AddTaskNodeDialogViewModel = BetterGenshinImpact.ViewModel.Windows.GearTask.AddTaskNodeDialogViewModel;
|
||
|
||
namespace BetterGenshinImpact.View.Windows.GearTask;
|
||
|
||
public partial class AddTaskNodeDialog
|
||
{
|
||
public AddTaskNodeDialogViewModel ViewModel { get; }
|
||
|
||
public AddTaskNodeDialog(string taskType)
|
||
{
|
||
ViewModel = new AddTaskNodeDialogViewModel(taskType);
|
||
DataContext = ViewModel;
|
||
|
||
InitializeComponent();
|
||
|
||
ViewModel.RequestClose += OnRequestClose;
|
||
this.SourceInitialized += OnSourceInitialized;
|
||
}
|
||
|
||
private void OnSourceInitialized(object? sender, EventArgs e)
|
||
{
|
||
// 应用与主窗口相同的背景主题
|
||
WindowHelper.TryApplySystemBackdrop(this);
|
||
}
|
||
|
||
private void OnRequestClose(object? sender, bool result)
|
||
{
|
||
DialogResult = result;
|
||
Close();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示添加任务对话框
|
||
/// </summary>
|
||
/// <param name="taskType">任务类型</param>
|
||
/// <param name="owner">父窗口</param>
|
||
/// <returns>如果用户点击确定返回ViewModel,否则返回null</returns>
|
||
public static AddTaskNodeDialogViewModel? ShowDialog(string taskType, Window? owner = null)
|
||
{
|
||
var dialog = new AddTaskNodeDialog(taskType);
|
||
if (owner != null)
|
||
{
|
||
dialog.Owner = owner;
|
||
}
|
||
|
||
var result = dialog.ShowDialog();
|
||
return result == true ? dialog.ViewModel : null;
|
||
}
|
||
} |