Chaged colors
Added handelrs for networking exceptions Made Book selector a bit bigger Fixed issue with publishing date
This commit is contained in:
@@ -42,7 +42,7 @@ public partial class MainWindow : Window
|
||||
|
||||
uppdateListedBooks(0);
|
||||
|
||||
Console.WriteLine(Book.GetBookFromISBN("978-1-97470719-5"));
|
||||
//Console.WriteLine(Book.GetBookFromISBN("978-1-97470719-5"));
|
||||
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, __) =>
|
||||
{
|
||||
@@ -68,45 +68,65 @@ public partial class MainWindow : Window
|
||||
int i = 0;
|
||||
|
||||
Library.Children.Clear();
|
||||
|
||||
|
||||
foreach (Book book in shown)
|
||||
{
|
||||
|
||||
Grid grid = new Grid();
|
||||
|
||||
Color c = new Color();
|
||||
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
grid.Background = Brushes.DarkGray;
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.Background = Brushes.LightGray;
|
||||
}
|
||||
|
||||
grid.Margin = new Thickness(0, 5, 0, 0);
|
||||
grid.SetValue(Grid.RowProperty, i);
|
||||
i++;
|
||||
|
||||
|
||||
ColumnDefinition def1 = new ColumnDefinition();
|
||||
def1.Width = new GridLength(40);
|
||||
grid.ColumnDefinitions.Add(def1);
|
||||
|
||||
|
||||
ColumnDefinition def2 = new ColumnDefinition();
|
||||
def2.Width = GridLength.Auto;
|
||||
grid.ColumnDefinitions.Add(def2);
|
||||
|
||||
|
||||
ColumnDefinition def7 = new ColumnDefinition();
|
||||
def2.Width = GridLength.Auto;
|
||||
grid.ColumnDefinitions.Add(def7);
|
||||
|
||||
BitmapImage coverBitmap = new BitmapImage();
|
||||
coverBitmap.BeginInit();
|
||||
coverBitmap.UriSource = new Uri($"https://covers.openlibrary.org/b/isbn/{book.ISBN}-S.jpg");
|
||||
coverBitmap.CacheOption = BitmapCacheOption.OnLoad; // Ensure full load before use
|
||||
//coverBitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache; // Prevent caching issues
|
||||
coverBitmap.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.Default); // Network-friendly caching
|
||||
coverBitmap.EndInit();
|
||||
|
||||
Image cover = new Image();
|
||||
cover.SetValue(Grid.ColumnProperty, 0);
|
||||
cover.Stretch = Stretch.Uniform;
|
||||
cover.Source = coverBitmap;
|
||||
cover.Margin = new Thickness(0, 0, 5, 0);
|
||||
|
||||
grid.Children.Add(cover);
|
||||
|
||||
Grid bookInfo = new Grid();
|
||||
try
|
||||
{
|
||||
|
||||
BitmapImage coverBitmap = new BitmapImage();
|
||||
coverBitmap.BeginInit();
|
||||
coverBitmap.UriSource = new Uri($"https://covers.openlibrary.org/b/isbn/{book.ISBN}-S.jpg");
|
||||
coverBitmap.CacheOption = BitmapCacheOption.OnLoad; // Ensure full load before use
|
||||
//coverBitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache; // Prevent caching issues
|
||||
coverBitmap.UriCachePolicy =
|
||||
new RequestCachePolicy(RequestCacheLevel.Default); // Network-friendly caching
|
||||
coverBitmap.EndInit();
|
||||
|
||||
Image cover = new Image();
|
||||
cover.SetValue(Grid.ColumnProperty, 0);
|
||||
cover.Stretch = Stretch.Uniform;
|
||||
cover.Source = coverBitmap;
|
||||
cover.Margin = new Thickness(0, 0, 5, 0);
|
||||
|
||||
grid.Children.Add(cover);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Grid bookInfo = new Grid();
|
||||
|
||||
bookInfo.SetValue(Grid.ColumnProperty, 1);
|
||||
|
||||
@@ -156,12 +176,13 @@ public partial class MainWindow : Window
|
||||
removeImage.Source = removeBitmap;
|
||||
removeImage.MaxHeight = 20;
|
||||
removeImage.MaxWidth = 20;
|
||||
removeImage.Margin = new Thickness(0, 0, 5, 0);
|
||||
//removeImage.Margin = new Thickness(0, 0, 5, 0);
|
||||
|
||||
Button remove = new Button();
|
||||
remove.Click += (_, __) => RemoveBook(book);
|
||||
remove.Content = removeImage;
|
||||
remove.MaxWidth = 30;
|
||||
remove.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
remove.SetValue(Grid.ColumnProperty, 2);
|
||||
|
||||
grid.Children.Add(remove);
|
||||
|
||||
Reference in New Issue
Block a user