Added BookDetailsDialog, LiberatedStatusBatchDialog, ScanAccountsDialog, SearchSyntaxDialog and TagsBatchDialog
This commit is contained in:
parent
952173d450
commit
ccdd1dc9f3
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
@ -90,5 +91,29 @@ namespace LibationWinForms.AvaloniaUI
|
||||
public int Width;
|
||||
public bool IsMaximized;
|
||||
}
|
||||
|
||||
|
||||
public static void HideMinMaxBtns(this Window form)
|
||||
{
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
return;
|
||||
#if WINDOWS7_0
|
||||
var handle = form.PlatformImpl.Handle.Handle;
|
||||
var currentStyle = GetWindowLong(handle, GWL_STYLE);
|
||||
|
||||
SetWindowLong(handle, GWL_STYLE, currentStyle & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WINDOWS7_0
|
||||
const long WS_MINIMIZEBOX = 0x00020000L;
|
||||
const long WS_MAXIMIZEBOX = 0x10000L;
|
||||
const int GWL_STYLE = -16;
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
static extern long GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
static extern int SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,12 +235,11 @@ namespace LibationWinForms.AvaloniaUI
|
||||
{
|
||||
var dialog = new MessageBoxWindow();
|
||||
|
||||
#if WINDOWS7_0
|
||||
HideMinMaxBtns(dialog.PlatformImpl.Handle.Handle);
|
||||
#endif
|
||||
dialog.HideMinMaxBtns();
|
||||
|
||||
var vm = new MessageBoxViewModel(message, caption, buttons, icon, defaultButton);
|
||||
dialog.DataContext = vm;
|
||||
dialog.ControlToFocusOnShow = dialog.FindControl<Control>(defaultButton.ToString());
|
||||
dialog.CanResize = false;
|
||||
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
var tbx = dialog.FindControl<TextBlock>("messageTextBlock");
|
||||
@ -295,21 +294,5 @@ namespace LibationWinForms.AvaloniaUI
|
||||
}
|
||||
}
|
||||
|
||||
#if WINDOWS7_0
|
||||
|
||||
private static void HideMinMaxBtns(IntPtr handle)
|
||||
{
|
||||
var currentStyle = GetWindowLong(handle, GWL_STYLE);
|
||||
|
||||
SetWindowLong(handle, GWL_STYLE, currentStyle & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
|
||||
}
|
||||
const long WS_MINIMIZEBOX = 0x00020000L;
|
||||
const long WS_MAXIMIZEBOX = 0x10000L;
|
||||
const int GWL_STYLE = -16;
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
static extern long GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
static extern int SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
|
||||
public bool RemoveColumnVisivle { get => _removeColumnVisivle; private set => this.RaiseAndSetIfChanged(ref _removeColumnVisivle, value); }
|
||||
|
||||
public List<LibraryBook> GetVisibleBookEntries()
|
||||
=> GridEntries
|
||||
=> GridEntries.InternalList
|
||||
.BookEntries()
|
||||
.Select(lbe => lbe.LibraryBook)
|
||||
.ToList();
|
||||
|
||||
@ -11,6 +11,12 @@
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="*,Auto,Auto,Auto">
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button:focus">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
||||
<Setter Property="BorderThickness" Value="2" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Grid ColumnDefinitions="Auto,*" Margin="10,10,10,0">
|
||||
<Panel VerticalAlignment="Top" Margin="5" Background="LightGray" Width="80" Height="80" >
|
||||
<Image Grid.Column="0" Width="80" Height="80" Source="{Binding Cover}" />
|
||||
|
||||
@ -12,7 +12,7 @@ using System.Linq;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public partial class BookDetailsDialog2 : Window
|
||||
public partial class BookDetailsDialog2 : DialogWindow
|
||||
{
|
||||
private LibraryBook _libraryBook;
|
||||
private BookDetailsDialogViewModel _viewModel;
|
||||
@ -34,9 +34,7 @@ namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
public BookDetailsDialog2()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
{
|
||||
using var context = DbContexts.GetContext();
|
||||
@ -48,6 +46,14 @@ namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
LibraryBook = libraryBook;
|
||||
}
|
||||
|
||||
|
||||
protected override void SaveAndClose()
|
||||
{
|
||||
SaveButton_Clicked(null, null);
|
||||
base.SaveAndClose();
|
||||
}
|
||||
|
||||
|
||||
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
LibraryBook.Book.UpdateBook(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using System;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public abstract class DialogWindow : Window
|
||||
{
|
||||
public Control ControlToFocusOnShow { get; set; }
|
||||
public DialogWindow()
|
||||
{
|
||||
this.HideMinMaxBtns();
|
||||
this.KeyDown += DialogWindow_KeyDown;
|
||||
this.Opened += DialogWindow_Opened;
|
||||
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void DialogWindow_Opened(object sender, EventArgs e)
|
||||
{
|
||||
ControlToFocusOnShow?.Focus();
|
||||
}
|
||||
|
||||
protected virtual void SaveAndClose() => Close(DialogResult.OK);
|
||||
protected virtual void CancelAndClose() => Close(DialogResult.Cancel);
|
||||
|
||||
private void DialogWindow_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Avalonia.Input.Key.Escape)
|
||||
CancelAndClose();
|
||||
else if (e.Key == Avalonia.Input.Key.Return)
|
||||
SaveAndClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.LiberatedStatusBatchDialog"
|
||||
Title="Liberated status: Whether the book has been downloaded"
|
||||
MinWidth="400" MinHeight="120"
|
||||
MaxWidth="400" MaxHeight="120"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="10,10,10,0"
|
||||
Text="To download again next time: change to Not Downloaded
To not download: change to Downloaded"/>
|
||||
|
||||
<StackPanel
|
||||
Margin="10"
|
||||
Grid.Row="1"
|
||||
Orientation="Horizontal">
|
||||
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Margin="0,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Text="Book" />
|
||||
|
||||
<ComboBox
|
||||
Width="130"
|
||||
MinHeight="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
||||
Items="{Binding BookStatuses}">
|
||||
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
Text="{Binding Text}" />
|
||||
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Padding="30,0,30,0"
|
||||
Margin="10,0,10,10"
|
||||
HorizontalAlignment="Right"
|
||||
Height="25"
|
||||
Content="Save"
|
||||
Click="SaveButton_Clicked"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -0,0 +1,51 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
using DataLayer;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public partial class LiberatedStatusBatchDialog : DialogWindow
|
||||
{
|
||||
private class liberatedComboBoxItem
|
||||
{
|
||||
public LiberatedStatus Status { get; set; }
|
||||
public string Text { get; set; }
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
|
||||
public LiberatedStatus BookLiberatedStatus { get; private set; }
|
||||
|
||||
private liberatedComboBoxItem _selectedStatus;
|
||||
public object SelectedItem
|
||||
{
|
||||
get => _selectedStatus;
|
||||
set
|
||||
{
|
||||
_selectedStatus = value as liberatedComboBoxItem;
|
||||
|
||||
BookLiberatedStatus = _selectedStatus.Status;
|
||||
}
|
||||
}
|
||||
|
||||
public IList BookStatuses { get; } = new List<liberatedComboBoxItem>
|
||||
{
|
||||
new liberatedComboBoxItem { Status = LiberatedStatus.Liberated, Text = "Downloaded" },
|
||||
new liberatedComboBoxItem { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" },
|
||||
};
|
||||
|
||||
public LiberatedStatusBatchDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
SelectedItem = BookStatuses[0] as liberatedComboBoxItem;
|
||||
DataContext = this;
|
||||
}
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> SaveAndClose();
|
||||
}
|
||||
}
|
||||
@ -1,44 +1,26 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.ReactiveUI;
|
||||
using LibationWinForms.AvaloniaUI.ViewModels.Dialogs;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
|
||||
public partial class MessageBoxWindow : ReactiveWindow<MessageBoxViewModel>
|
||||
public partial class MessageBoxWindow : DialogWindow
|
||||
{
|
||||
public MessageBoxWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
protected override void CancelAndClose() => Close(DialogResult.None);
|
||||
|
||||
protected override void SaveAndClose() { }
|
||||
|
||||
public DialogResult DialogResult { get; private set; }
|
||||
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="185"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.ScanAccountsDialog"
|
||||
MinWidth="500" MinHeight="160"
|
||||
MaxWidth="500" MaxHeight="185"
|
||||
Title="Which Accounts?"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto">
|
||||
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button:focus">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
||||
<Setter Property="BorderThickness" Value="2" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="10,10,10,0"
|
||||
Text="Check the accounts to scan and import.
To change default selections, go to: Settings > Accounts"/>
|
||||
|
||||
<ScrollViewer
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Margin="10"
|
||||
MinHeight="90"
|
||||
MaxHeight="90">
|
||||
|
||||
<ListBox Items="{Binding Accounts}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
<StackPanel Height="20" Orientation="Horizontal">
|
||||
|
||||
<CheckBox
|
||||
Margin="0,0,10,0"
|
||||
IsChecked="{Binding IsChecked, Mode=TwoWay}" />
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Text}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
|
||||
</ScrollViewer>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Padding="20,0,20,0"
|
||||
Margin="10,0,10,10"
|
||||
Height="25"
|
||||
Content="Edit Accounts"
|
||||
Click="EditAccountsButton_Clicked"/>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Padding="30,0,30,0"
|
||||
Margin="10,0,10,10"
|
||||
HorizontalAlignment="Right"
|
||||
Height="25"
|
||||
Content="Import"
|
||||
Name="ImportButton"
|
||||
Click="ImportButton_Clicked"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -0,0 +1,78 @@
|
||||
using AudibleUtilities;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public partial class ScanAccountsDialog : DialogWindow
|
||||
{
|
||||
public List<Account> CheckedAccounts { get; } = new();
|
||||
private List<listItem> _accounts { get; } = new();
|
||||
public IList Accounts => _accounts;
|
||||
private class listItem
|
||||
{
|
||||
public Account Account { get; set; }
|
||||
public string Text { get; set; }
|
||||
public bool IsChecked { get; set; } = true;
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
|
||||
public ScanAccountsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
LoadAccounts();
|
||||
}
|
||||
|
||||
private void LoadAccounts()
|
||||
{
|
||||
_accounts.Clear();
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
var accounts = persister.AccountsSettings.Accounts;
|
||||
|
||||
foreach (var account in accounts)
|
||||
_accounts.Add(new listItem
|
||||
{
|
||||
Account = account,
|
||||
Text = $"{account.AccountName} ({account.AccountId} - {account.Locale.Name})"
|
||||
});
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
this.HideMinMaxBtns();
|
||||
this.Opened += ScanAccountsDialog_Opened;
|
||||
}
|
||||
|
||||
private void ScanAccountsDialog_Opened(object sender, System.EventArgs e)
|
||||
{
|
||||
this.FindControl<Button>(nameof(ImportButton)).Focus();
|
||||
}
|
||||
|
||||
public void EditAccountsButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (new LibationWinForms.Dialogs.AccountsDialog().ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
// reload grid and default checkboxes
|
||||
LoadAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SaveAndClose()
|
||||
{
|
||||
foreach (listItem item in _accounts.Where(a => a.IsChecked))
|
||||
CheckedAccounts.Add(item.Account);
|
||||
|
||||
base.SaveAndClose();
|
||||
}
|
||||
|
||||
public void ImportButton_Clicked(object sender, RoutedEventArgs e) => SaveAndClose();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="950" d:DesignHeight="550"
|
||||
MinWidth="950" MinHeight="550"
|
||||
MaxWidth="950" MaxHeight="550"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.SearchSyntaxDialog"
|
||||
Title="Filter Options"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid
|
||||
Margin="10,0,10,10"
|
||||
RowDefinitions="Auto,Auto,*"
|
||||
ColumnDefinitions="Auto,Auto,Auto,Auto">
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="4"
|
||||
Text="Full Lucene query syntax is supported
Fields with similar names are synomyns (eg: Author, Authors, AuthorNames)

TAG FORMAT: [tagName]" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Text="STRING FIELDS" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Text="NUMBER FIELDS" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Text="BOOLEAN (TRUE/FALSE) FIELDS" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="1"
|
||||
Grid.Column="3"
|
||||
Text="ID FIELDS" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Text="{Binding StringFields}" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Text="{Binding NumberFields}" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Text="{Binding BoolFields}" />
|
||||
|
||||
<TextBlock Margin="10"
|
||||
Grid.Row="2"
|
||||
Grid.Column="3"
|
||||
Text="{Binding IdFields}" />
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -0,0 +1,60 @@
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public partial class SearchSyntaxDialog : DialogWindow
|
||||
{
|
||||
public string StringFields { get; init; }
|
||||
public string NumberFields { get; init; }
|
||||
public string BoolFields { get; init; }
|
||||
public string IdFields { get; init; }
|
||||
public SearchSyntaxDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
StringFields = @"
|
||||
Search for wizard of oz:
|
||||
title:oz
|
||||
title:""wizard of oz""
|
||||
|
||||
|
||||
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchStringFields());
|
||||
|
||||
NumberFields = @"
|
||||
Find books between 1-100 minutes long
|
||||
length:[1 TO 100]
|
||||
Find books exactly 1 hr long
|
||||
length:60
|
||||
|
||||
|
||||
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields());
|
||||
|
||||
BoolFields = @"
|
||||
Find books that you haven't rated:
|
||||
-IsRated
|
||||
|
||||
|
||||
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields());
|
||||
|
||||
IdFields = @"
|
||||
Alice's Adventures in Wonderland (ID: B015D78L0U)
|
||||
id:B015D78L0U
|
||||
|
||||
All of these are synonyms for the ID field
|
||||
|
||||
|
||||
" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchIdFields());
|
||||
|
||||
|
||||
DataContext = this;
|
||||
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
this.HideMinMaxBtns();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="630" d:DesignHeight="110"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.TagsBatchDialog"
|
||||
MinWidth="630" MinHeight="110"
|
||||
MaxWidth="630" MaxHeight="110"
|
||||
Title="Replace Tags"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="10,10,10,0"
|
||||
Text="Tags are separated by a space. Each tag can contain letters, numbers, and underscores"/>
|
||||
<TextBox
|
||||
Grid.Row="1"
|
||||
Margin="10"
|
||||
MinHeight="25"
|
||||
Name="EditTagsTb"
|
||||
Text="{Binding NewTags, Mode=TwoWay}" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Padding="30,0,30,0"
|
||||
Margin="10,0,10,10"
|
||||
HorizontalAlignment="Right"
|
||||
Height="25"
|
||||
Content="Save"
|
||||
Click="SaveButton_Clicked"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@ -0,0 +1,26 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Views.Dialogs
|
||||
{
|
||||
public partial class TagsBatchDialog : DialogWindow
|
||||
{
|
||||
public string NewTags { get; set; }
|
||||
public TagsBatchDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
ControlToFocusOnShow = this.FindControl<TextBox>(nameof(EditTagsTb));
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> SaveAndClose();
|
||||
}
|
||||
}
|
||||
@ -11,8 +11,8 @@ namespace LibationWinForms.AvaloniaUI.Views
|
||||
{
|
||||
protected void Configure_Filter() { }
|
||||
|
||||
public void filterHelpBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> new SearchSyntaxDialog().ShowDialog();
|
||||
public async void filterHelpBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> await (new LibationWinForms.AvaloniaUI.Views.Dialogs.SearchSyntaxDialog()).ShowDialog(this);
|
||||
|
||||
public async void filterSearchTb_KeyPress(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
@ -40,11 +40,11 @@ namespace LibationWinForms.AvaloniaUI.Views
|
||||
}
|
||||
|
||||
// selectively remove books from some accounts
|
||||
public void removeSomeAccountsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
public async void removeSomeAccountsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
using var scanAccountsDialog = new ScanAccountsDialog();
|
||||
var scanAccountsDialog = new Dialogs.ScanAccountsDialog();
|
||||
|
||||
if (scanAccountsDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||||
if (await scanAccountsDialog.ShowDialog<DialogResult>(this) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
if (!scanAccountsDialog.CheckedAccounts.Any())
|
||||
|
||||
@ -47,9 +47,9 @@ namespace LibationWinForms.AvaloniaUI.Views
|
||||
|
||||
public async void scanLibraryOfSomeAccountsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
using var scanAccountsDialog = new ScanAccountsDialog();
|
||||
var scanAccountsDialog = new Dialogs.ScanAccountsDialog();
|
||||
|
||||
if (scanAccountsDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||||
if (await scanAccountsDialog.ShowDialog<DialogResult>(this) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
if (!scanAccountsDialog.CheckedAccounts.Any())
|
||||
|
||||
@ -41,9 +41,9 @@ namespace LibationWinForms.AvaloniaUI.Views
|
||||
}
|
||||
public async void replaceTagsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var dialog = new TagsBatchDialog();
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != System.Windows.Forms.DialogResult.OK)
|
||||
var dialog = new Dialogs.TagsBatchDialog();
|
||||
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var visibleLibraryBooks = _viewModel.ProductsDisplay.GetVisibleBookEntries();
|
||||
@ -64,9 +64,9 @@ namespace LibationWinForms.AvaloniaUI.Views
|
||||
|
||||
public async void setDownloadedToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var dialog = new LiberatedStatusBatchDialog();
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != System.Windows.Forms.DialogResult.OK)
|
||||
var dialog = new Dialogs.LiberatedStatusBatchDialog();
|
||||
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
var visibleLibraryBooks = _viewModel.ProductsDisplay.GetVisibleBookEntries();
|
||||
|
||||
@ -112,6 +112,9 @@
|
||||
<Compile Update="AvaloniaUI\Views\Dialogs\BookDetailsDialog2.axaml.cs">
|
||||
<DependentUpon>BookDetailsDialog2.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="AvaloniaUI\Views\Dialogs\SearchSyntaxDialog.axaml.cs">
|
||||
<DependentUpon>SearchSyntaxDialog.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user