This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -1,58 +0,0 @@
using System.Windows.Controls;
using WPFluent.Controls;
namespace WPFluent.Extensions;
public static class ContentDialogServiceExtensions
{
/// <summary>
/// Shows the simple alert-like dialog.
/// </summary>
/// <returns>Result of the life cycle of the <see cref="ContentDialog"/>.</returns>
public static Task<ContentDialogResult> ShowAlertAsync(
this ContentDialogService dialogService,
string title,
string message,
string closeButtonText,
CancellationToken cancellationToken = default)
{
var dialog = new ContentDialog();
dialog.SetCurrentValue(ContentDialog.TitleProperty, title);
dialog.SetCurrentValue(ContentControl.ContentProperty, message);
dialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, closeButtonText);
return dialogService.ShowAsync(dialog, cancellationToken);
}
/// <summary>
/// Shows simple dialog
/// </summary>
/// <param name="dialogService">The <see cref="IContentDialogService"/>.</param>
/// <param name="options">Set of parameters of the basic dialog box.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Result of the life cycle of the <see cref="ContentDialog"/>.</returns>
public static Task<ContentDialogResult> ShowSimpleDialogAsync(
this ContentDialogService dialogService,
SimpleContentDialogOptions options,
CancellationToken cancellationToken = default)
{
var dialog = new ContentDialog()
{
Title = options.Title,
Content = options.Content,
CloseButtonText = options.CloseButtonText,
PrimaryButtonText = options.PrimaryButtonText,
SecondaryButtonText = options.SecondaryButtonText,
VerticalContentAlignment = VerticalAlignment.Center,
HorizontalContentAlignment = HorizontalAlignment.Center
};
return dialogService.ShowAsync(dialog, cancellationToken);
}
}

View File

@@ -1,54 +0,0 @@
using WPFluent.Controls;
namespace WPFluent.Extensions;
public static class MessageExtensions
{
private static readonly ContentDialogService ContentDialogService = new ContentDialogService();
public static async void ShowMessage(string content = "内容...", string title = "消息")
{
Controls.MessageWindow uiMessageBox = new()
{
Title = title,
Content = content,
MinWidth = 200,
//PrimaryButtonIcon = SymbolRegular.Button16,
//PrimaryButtonAppearance = ControlAppearance.Primary,
//PrimaryButtonText = "确定",
//SecondaryButtonIcon = SymbolRegular.Button20,
//SecondaryButtonAppearance = ControlAppearance.Secondary,
//SecondaryButtonText = "取消",
CloseButtonAppearance = ControlAppearance.Primary,
//CloseButtonIcon = SymbolRegular.CalendarCancel16,
CloseButtonText = "确定",
WindowStartupLocation = System.Windows.WindowStartupLocation.Manual,
};
await uiMessageBox.ShowDialogAsync();
}
public static async Task<ContentDialogResult> ShowTaskDialog(
string title,
object content,
string primaryButtonText = "确定",
string secondaryButtonText = "取消",
string closeButtonText = "关闭")
{
return await ContentDialogService.ShowSimpleDialogAsync(
new SimpleContentDialogOptions()
{
Title = title,
Content = content,
PrimaryButtonText = primaryButtonText,
SecondaryButtonText = secondaryButtonText,
CloseButtonText = closeButtonText,
});
//result switch
//{
// ContentDialogResult.Primary => "User saved their work",
// ContentDialogResult.Secondary => "User did not save their work",
// _ => "User cancelled the dialog"
//};
}
}