feat: Implement AI CSV overwrite confirmation and update CSV output path based on destination
This commit is contained in:
parent
6e05869b04
commit
f3ac1ea920
3 changed files with 214 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ public partial class AvaloniaMainWindow : Window
|
|||
|
||||
// Let DataModel marshal callbacks onto Avalonia UI thread.
|
||||
_model.UiInvoker = action => Dispatcher.UIThread.Invoke(action);
|
||||
_model.ConfirmAiCsvOverwriteAsync = ShowConfirmationDialogAsync;
|
||||
|
||||
_model.SelectSourceFolderRequested += async (_, _) =>
|
||||
{
|
||||
|
|
@ -283,6 +284,25 @@ public partial class AvaloniaMainWindow : Window
|
|||
await dialog.ShowDialog(this);
|
||||
}
|
||||
|
||||
private async Task<bool> ShowConfirmationDialogAsync(string title, string message)
|
||||
{
|
||||
var dialog = new Window
|
||||
{
|
||||
Title = title,
|
||||
Width = 520,
|
||||
CanResize = false,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
SizeToContent = SizeToContent.Height
|
||||
};
|
||||
|
||||
dialog.Content = BuildConfirmationDialogContent(
|
||||
message,
|
||||
() => dialog.Close(true),
|
||||
() => dialog.Close(false));
|
||||
|
||||
return await dialog.ShowDialog<bool>(this);
|
||||
}
|
||||
|
||||
private static Control BuildMessageDialogContent(string message, Action closeDialog)
|
||||
{
|
||||
var layout = new StackPanel
|
||||
|
|
@ -310,4 +330,46 @@ public partial class AvaloniaMainWindow : Window
|
|||
layout.Children.Add(closeButton);
|
||||
return layout;
|
||||
}
|
||||
|
||||
private static Control BuildConfirmationDialogContent(string message, Action confirmDialog, Action cancelDialog)
|
||||
{
|
||||
var layout = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(16),
|
||||
Spacing = 12
|
||||
};
|
||||
|
||||
layout.Children.Add(new TextBlock
|
||||
{
|
||||
Text = message,
|
||||
TextWrapping = Avalonia.Media.TextWrapping.Wrap,
|
||||
MaxWidth = 460
|
||||
});
|
||||
|
||||
var buttons = new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
Spacing = 8
|
||||
};
|
||||
|
||||
var cancelButton = new Button
|
||||
{
|
||||
Content = "Annulla",
|
||||
MinWidth = 96
|
||||
};
|
||||
cancelButton.Click += (_, _) => cancelDialog();
|
||||
|
||||
var confirmButton = new Button
|
||||
{
|
||||
Content = "Sovrascrivi",
|
||||
MinWidth = 96
|
||||
};
|
||||
confirmButton.Click += (_, _) => confirmDialog();
|
||||
|
||||
buttons.Children.Add(cancelButton);
|
||||
buttons.Children.Add(confirmButton);
|
||||
layout.Children.Add(buttons);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue