-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Snap.Hutao/Snap.Hutao/View/Dialog/ReconfirmDialog.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<ContentDialog | ||
x:Class="Snap.Hutao.View.Dialog.ReconfirmDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:shcm="using:Snap.Hutao.Control.Markup" | ||
Title="{shcm:ResourceString Name=ViewDialogReconfirmTitle}" | ||
CloseButtonText="{shcm:ResourceString Name=ContentDialogCancelCloseButtonText}" | ||
DefaultButton="Close" | ||
IsPrimaryButtonEnabled="False" | ||
PrimaryButtonText="{shcm:ResourceString Name=ContentDialogConfirmPrimaryButtonText}" | ||
Style="{StaticResource DefaultContentDialogStyle}" | ||
mc:Ignorable="d"> | ||
|
||
<TextBox | ||
Margin="0,0,0,8" | ||
VerticalAlignment="Top" | ||
Header="{shcm:ResourceString Name=ViewDialogReconfirmTextHeader}" | ||
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> | ||
</ContentDialog> |
35 changes: 35 additions & 0 deletions
35
src/Snap.Hutao/Snap.Hutao/View/Dialog/ReconfirmDialog.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) DGP Studio. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Snap.Hutao.View.Dialog; | ||
|
||
[DependencyProperty("Text", typeof(string), default(string), nameof(OnTextChanged))] | ||
internal sealed partial class ReconfirmDialog : ContentDialog | ||
{ | ||
private readonly ITaskContext taskContext; | ||
|
||
public ReconfirmDialog(IServiceProvider serviceProvider) | ||
{ | ||
InitializeComponent(); | ||
|
||
taskContext = serviceProvider.GetRequiredService<ITaskContext>(); | ||
} | ||
|
||
public string ConfirmText { get; private set; } = default!; | ||
|
||
public async ValueTask<bool> ConfirmAsync(string confirmText) | ||
{ | ||
await taskContext.SwitchToMainThreadAsync(); | ||
ConfirmText = confirmText; | ||
return await ShowAsync() is ContentDialogResult.Primary; | ||
} | ||
|
||
private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) | ||
{ | ||
ReconfirmDialog dialog = (ReconfirmDialog)sender; | ||
dialog.IsPrimaryButtonEnabled = string.Equals(dialog.Text, dialog.ConfirmText, StringComparison.Ordinal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters