XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEToolBox

【WPF】XFE工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Windows;
using XFEToolBox.Client.Model;
using XFEToolBox.Client.Utilities;

namespace XFEToolBox.Tools.QuickSuite;

// This adapter and the namespaced implementation are included in the .xfetool.
// Only the host's stable theme and confirmation APIs are used, never its old page.
public static class PackagedQuickTools
{
    private static bool configured;
    public static QuickToolPage Create(string kind)
    {
        if (!Enum.TryParse<QuickToolKind>(kind, out var tool)) throw new ArgumentException("未知工具。");
        if (!configured)
        {
            configured = true;
            QuickToolPage.Confirmation = (title, message, owner) => PopupHelper.ShowConfirmDialog(message,
                new PopupWindowOptions { Title = title, Owner = owner, Width = 560, Height = 360 }, true, "确认执行") == MessageBoxResult.OK;
            Application.Current.Exit += (_, _) => { ClipboardHistory.Shared.Dispose(); AwakeLease.Shared.Dispose(); };
        }
        return new QuickToolPage(tool);
    }
}