This commit is contained in:
Michael Bucari-Tovo 2022-07-15 00:49:38 -06:00
parent 180d591b0a
commit d62821cd60
12 changed files with 104 additions and 138 deletions

View file

@ -10,7 +10,7 @@
Icon="/AvaloniaUI/Assets/1x1.png">
<Grid ColumnDefinitions="*" RowDefinitions="*,Auto">
<DockPanel Margin="5,10,10,10" Grid.Row="0" Background="White">
<DockPanel Margin="5,10,10,20" Grid.Row="0" Background="White">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal"
VerticalAlignment="Top">
@ -21,15 +21,16 @@
<Image IsVisible="{Binding IsExclamation}" Stretch="None" Source="/AvaloniaUI/Assets/MBIcons/Exclamation.png"/>
</Panel>
<TextBlock Margin="5,0,0,0" Name="messageTextBlock" MinHeight="45" MinWidth="203" TextWrapping="WrapWithOverflow" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="12" Text="{Binding Message}" />
<TextBlock Margin="5,0,0,0" Name="messageTextBlock" MinHeight="45" MinWidth="193" TextWrapping="WrapWithOverflow" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="12" Text="{Binding Message}" />
</StackPanel>
</DockPanel>
<DockPanel Height="45" Grid.Row="1" Background="LightGray">
<DockPanel Height="45" Grid.Row="1" Background="WhiteSmoke">
<DockPanel.Styles>
<Style Selector="Button:focus">
<Setter Property="Background" Value="{DynamicResource SystemAccentColor}" />
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
<Setter Property="BorderThickness" Value="2" />
</Style>
</DockPanel.Styles>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5" DockPanel.Dock="Bottom">

View file

@ -20,6 +20,24 @@ namespace LibationWinForms.AvaloniaUI.Views.Dialogs
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
this.Opened += MessageBoxWindow_Opened;
}
private void MessageBoxWindow_Opened(object sender, System.EventArgs e)
{
var vm = this.DataContext as MessageBoxViewModel;
switch (vm.DefaultButton)
{
case MessageBoxDefaultButton.Button1:
this.FindControl<Button>("Button1").Focus();
break;
case MessageBoxDefaultButton.Button2:
this.FindControl<Button>("Button2").Focus();
break;
case MessageBoxDefaultButton.Button3:
this.FindControl<Button>("Button3").Focus();
break;
}
}
public DialogResult DialogResult { get; private set; }

View file

@ -16,21 +16,6 @@ namespace LibationWinForms.AvaloniaUI.Views
_viewModel.RemoveButtonsVisible = false;
}
public async void removeBooksBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await productsDisplay.RemoveCheckedBooksAsync();
}
public async void doneRemovingBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
_viewModel.RemoveButtonsVisible = false;
productsDisplay.CloseRemoveBooksColumn();
//Restore the filter
await performFilter(_viewModel.FilterString);
}
public void removeLibraryBooksToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
// if 0 accounts, this will not be visible
@ -81,6 +66,21 @@ namespace LibationWinForms.AvaloniaUI.Views
await productsDisplay.ScanAndRemoveBooksAsync(accounts);
}
public async void removeBooksBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
await productsDisplay.RemoveCheckedBooksAsync();
}
public async void doneRemovingBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
_viewModel.RemoveButtonsVisible = false;
productsDisplay.CloseRemoveBooksColumn();
//Restore the filter
await performFilter(lastGoodFilter);
}
public void productsDisplay_RemovableCountChanged(object sender, int removeCount)
{
_viewModel.RemoveBooksButtonText = removeCount switch

View file

@ -38,7 +38,7 @@ namespace LibationWinForms.AvaloniaUI.Views
Serilog.Log.Logger.Error(ex, "An error occurred while backing up visible library books");
}
}
public void replaceTagsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
public async void replaceTagsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
{
var dialog = new TagsBatchDialog();
var result = dialog.ShowDialog();
@ -47,12 +47,13 @@ namespace LibationWinForms.AvaloniaUI.Views
var visibleLibraryBooks = productsDisplay.GetVisibleBookEntries();
var confirmationResult = MessageBoxLib.ShowConfirmationDialog(
var confirmationResult = await MessageBox.ShowConfirmationDialog(
this,
visibleLibraryBooks,
$"Are you sure you want to replace tags in {0}?",
"Are you sure you want to replace tags in {0}?",
"Replace tags?");
if (confirmationResult != System.Windows.Forms.DialogResult.Yes)
if (confirmationResult != DialogResult.Yes)
return;
foreach (var libraryBook in visibleLibraryBooks)
@ -60,7 +61,7 @@ namespace LibationWinForms.AvaloniaUI.Views
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
}
public void setDownloadedToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
public async void setDownloadedToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
{
var dialog = new LiberatedStatusBatchDialog();
var result = dialog.ShowDialog();
@ -69,12 +70,13 @@ namespace LibationWinForms.AvaloniaUI.Views
var visibleLibraryBooks = productsDisplay.GetVisibleBookEntries();
var confirmationResult = MessageBoxLib.ShowConfirmationDialog(
var confirmationResult = await MessageBox.ShowConfirmationDialog(
this,
visibleLibraryBooks,
$"Are you sure you want to replace downloaded status in {0}?",
"Are you sure you want to replace downloaded status in {0}?",
"Replace downloaded status?");
if (confirmationResult != System.Windows.Forms.DialogResult.Yes)
if (confirmationResult != DialogResult.Yes)
return;
foreach (var libraryBook in visibleLibraryBooks)
@ -86,12 +88,13 @@ namespace LibationWinForms.AvaloniaUI.Views
{
var visibleLibraryBooks = productsDisplay.GetVisibleBookEntries();
var confirmationResult = MessageBoxLib.ShowConfirmationDialog(
var confirmationResult = await MessageBox.ShowConfirmationDialog(
this,
visibleLibraryBooks,
$"Are you sure you want to remove {0} from Libation's library?",
"Are you sure you want to remove {0} from Libation's library?",
"Remove books from Libation?");
if (confirmationResult != System.Windows.Forms.DialogResult.Yes)
if (confirmationResult != DialogResult.Yes)
return;
var visibleIds = visibleLibraryBooks.Select(lb => lb.Book.AudibleProductId).ToList();

View file

@ -47,12 +47,13 @@ namespace LibationWinForms.AvaloniaUI.Views.ProductsGrid
return;
var libraryBooks = selectedBooks.Select(rge => rge.LibraryBook).ToList();
var result = MessageBoxLib.ShowConfirmationDialog(
var result = await MessageBox.ShowConfirmationDialog(
null,
libraryBooks,
$"Are you sure you want to remove {selectedBooks.Count} books from Libation's library?",
"Remove books from Libation?");
if (result != System.Windows.Forms.DialogResult.Yes)
if (result != DialogResult.Yes)
return;
foreach (var book in selectedBooks)