- The rail grows with the longest label (128-200 px); the first-run dialog disables the shell behind it and focuses its chosen option; toasts stay above it; F6 reaches the newest toast. - Confirm and login dialogs are named by their heading, focus the safe button, announce sign-in errors. - Error toasts say what happened only for catalog sentences (ErrorText); other details stay in the log. - Window title, queued-jobs text (plural) and the pause button name come from resources. - Logs, paths and templates in the client styles stay left to right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using System.Windows;
|
|
using Titano.App.Infrastructure;
|
|
using Titano.Ui.Controls;
|
|
|
|
namespace Titano.App.Shell;
|
|
|
|
/// <summary>Modal confirmation for trusting a certificate and for destructive actions (BRIEF §12.1).</summary>
|
|
public sealed partial class ConfirmDialog : TitanoWindow
|
|
{
|
|
public ConfirmDialog(ConfirmRequest request)
|
|
{
|
|
DataContext = request;
|
|
InitializeComponent();
|
|
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
|
|
if (request.TypedConfirmation is null)
|
|
{
|
|
Loaded += (_, _) => Safe.Focus();
|
|
return;
|
|
}
|
|
Typing.Visibility = Visibility.Visible;
|
|
Loaded += (_, _) => Typed.Focus();
|
|
EnableAction(false);
|
|
}
|
|
|
|
/// <summary>True when the user chose the action.</summary>
|
|
public static bool Ask(Window? owner, ConfirmRequest request)
|
|
{
|
|
var dialog = new ConfirmDialog(request);
|
|
if (owner is { IsVisible: true }) dialog.Owner = owner;
|
|
else dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
return dialog.ShowDialog() == true;
|
|
}
|
|
|
|
private void OnSafe(object sender, RoutedEventArgs e) => DialogResult = false;
|
|
|
|
private void OnAction(object sender, RoutedEventArgs e) => DialogResult = true;
|
|
|
|
private void OnTyped(object sender, System.Windows.Controls.TextChangedEventArgs e) =>
|
|
EnableAction(string.Equals(Typed.Text.Trim(), ((ConfirmRequest)DataContext).TypedConfirmation, StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
/// <summary>The action waits for the typed confirmation; until then its tooltip says what to type (DESIGN §4 disabled states).</summary>
|
|
private void EnableAction(bool enabled)
|
|
{
|
|
var request = (ConfirmRequest)DataContext;
|
|
Action.IsEnabled = enabled;
|
|
Action.ToolTip = enabled ? request.ActionToolTip : request.TypedPrompt;
|
|
}
|
|
}
|