- New ConfirmDialog overlay with dark backdrop, rounded card, shadow - Warning/Question/Error icon types with accent colors - Replaced all MessageBox.Show calls (RemovePage, PreInstallCheck, Troubleshoot) - Click outside dialog = cancel Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 sor
2.2 KiB
C#
76 sor
2.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
|
|
namespace InstaSoftOfficeTool.Pages
|
|
{
|
|
public partial class ConfirmDialog : UserControl
|
|
{
|
|
private TaskCompletionSource<bool> _tcs;
|
|
|
|
public ConfirmDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public Task<bool> ShowAsync(string title, string message,
|
|
string confirmText = "Igen", string cancelText = "M\u00e9gse",
|
|
DialogType type = DialogType.Warning)
|
|
{
|
|
DialogTitle.Text = title;
|
|
DialogMessage.Text = message;
|
|
BtnConfirm.Content = confirmText;
|
|
BtnCancel.Content = cancelText;
|
|
|
|
switch (type)
|
|
{
|
|
case DialogType.Warning:
|
|
DialogIcon.Text = "\uE7BA";
|
|
DialogIcon.Foreground = (Brush)FindResource("WarningBrush");
|
|
break;
|
|
case DialogType.Question:
|
|
DialogIcon.Text = "\uE9CE";
|
|
DialogIcon.Foreground = (Brush)FindResource("AccentBrush");
|
|
break;
|
|
case DialogType.Error:
|
|
DialogIcon.Text = "\uE711";
|
|
DialogIcon.Foreground = (Brush)FindResource("ErrorBrush");
|
|
break;
|
|
}
|
|
|
|
Visibility = Visibility.Visible;
|
|
_tcs = new TaskCompletionSource<bool>();
|
|
return _tcs.Task;
|
|
}
|
|
|
|
private void BtnConfirm_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Visibility = Visibility.Collapsed;
|
|
_tcs?.TrySetResult(true);
|
|
}
|
|
|
|
private void BtnCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Visibility = Visibility.Collapsed;
|
|
_tcs?.TrySetResult(false);
|
|
}
|
|
|
|
private void Backdrop_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
// click outside = cancel
|
|
Visibility = Visibility.Collapsed;
|
|
_tcs?.TrySetResult(false);
|
|
}
|
|
}
|
|
|
|
public enum DialogType
|
|
{
|
|
Warning,
|
|
Question,
|
|
Error
|
|
}
|
|
}
|