Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,259 changes: 635 additions & 624 deletions Changelog.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Deployment/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "COMPASS"
#define MyAppVersion "1.8.5"
#define MyAppVersion "1.8.6"
#define MyAppPublisher "Paul De Smul"
#define MyAppURL "https://www.compassapp.info"
#define MyAppExeName "COMPASS.exe"
Expand Down
20 changes: 10 additions & 10 deletions src/COMPASS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="8.2.0" />
<PackageReference Include="Autofac" Version="8.2.1" />
<PackageReference Include="Autoupdater.NET.Official" Version="1.9.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
<PackageReference Include="FuzzySharp" Version="2.0.2" />
<PackageReference Include="gong-wpf-dragdrop" Version="4.0.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
<PackageReference Include="itext7" Version="9.0.0" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="9.0.0" />
<PackageReference Include="log4net" Version="3.0.3" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.4.0" />
<PackageReference Include="Magick.NET.SystemDrawing" Version="8.0.4" />
<PackageReference Include="HtmlAgilityPack" Version="1.12.0" />
<PackageReference Include="itext7" Version="9.1.0" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="9.1.0" />
<PackageReference Include="log4net" Version="3.0.4" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.6.0" />
<PackageReference Include="Magick.NET.SystemDrawing" Version="8.0.6" />
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
<PackageReference Include="OpenCvSharp4.Windows" Version="4.10.0.20241108" />
<PackageReference Include="ScrapySharp" Version="3.0.0" />
<PackageReference Include="Selenium.Support" Version="4.28.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.28.0" />
<PackageReference Include="Selenium.Support" Version="4.31.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.31.0" />
<PackageReference Include="SharpCompress" Version="0.39.0" />
<PackageReference Include="System.Drawing.Common" Version="9.0.1" />
<PackageReference Include="System.Drawing.Common" Version="9.0.3" />
<PackageReference Include="VirtualizingWrapPanel" Version="2.1.1" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
<PackageReference Include="ZXing.Net" Version="0.16.10" />
Expand Down
2 changes: 1 addition & 1 deletion src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// app, or any theme specific resource dictionaries)
)]

[assembly: AssemblyVersion("1.8.5")]
[assembly: AssemblyVersion("1.8.6")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]


2 changes: 1 addition & 1 deletion src/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net9.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
Expand Down
41 changes: 27 additions & 14 deletions src/Services/CoverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static async Task GetCover(List<Codex> codices)
}
}

public static void SaveCover(Codex destCodex, IMagickImage image)
public static async Task SaveCover(Codex destCodex, IMagickImage image)
{
if (String.IsNullOrEmpty(destCodex.CoverArt))
{
Expand All @@ -126,8 +126,11 @@ public static void SaveCover(Codex destCodex, IMagickImage image)

if (image.Width > 850) image.Resize(850, 0);

image.Write(destCodex.CoverArt);
CreateThumbnail(destCodex, image);
if (IOService.EnsureFoldersExists(destCodex.CoverArt))
{
await image.WriteAsync(destCodex.CoverArt);
CreateThumbnail(destCodex, image);
}
}

public static async Task SaveCover(string imgURL, Codex destCodex)
Expand All @@ -139,9 +142,12 @@ public static async Task SaveCover(string imgURL, Codex destCodex)
}

var imgBytes = await IOService.DownloadFileAsync(imgURL);
await File.WriteAllBytesAsync(destCodex.CoverArt, imgBytes);
CreateThumbnail(destCodex);
destCodex.RefreshThumbnail();
if (IOService.EnsureFoldersExists(destCodex.CoverArt))
{
await File.WriteAllBytesAsync(destCodex.CoverArt, imgBytes);
CreateThumbnail(destCodex);
destCodex.RefreshThumbnail();
}
}

public static bool GetCoverFromImage(string imagePath, Codex destCodex)
Expand All @@ -162,14 +168,18 @@ public static bool GetCoverFromImage(string imagePath, Codex destCodex)

try
{
using (MagickImage image = new(imagePath))
if (IOService.EnsureFoldersExists(destCodex.CoverArt))
{
if (image.Width > 1000) image.Resize(1000, 0);
image.Write(destCodex.CoverArt);
CreateThumbnail(destCodex, image);
using (MagickImage image = new(imagePath))
{
if (image.Width > 1000) image.Resize(1000, 0);
image.Write(destCodex.CoverArt);
CreateThumbnail(destCodex, image);
}
destCodex.RefreshThumbnail();
return true;
}
destCodex.RefreshThumbnail();
return true;
return false;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -204,8 +214,11 @@ public static void CreateThumbnail(Codex c, IMagickImage? image = null)
uint height = image.Height;
uint newHeight = newWidth / width * height;
//create thumbnail
image.Thumbnail(newWidth, newHeight);
image.Write(c.Thumbnail);
if (IOService.EnsureFoldersExists(c.Thumbnail))
{
image.Thumbnail(newWidth, newHeight);
image.Write(c.Thumbnail);
}
}
finally
{
Expand Down
21 changes: 21 additions & 0 deletions src/Services/IOService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,26 @@ public static IEnumerable<string> TryGetFilesInFolder(string path)
}
return files;
}

public static bool EnsureFoldersExists(string path)
{
var directory = Path.GetDirectoryName(path);

if (string.IsNullOrEmpty(directory))
{
return false;
}

try
{
Directory.CreateDirectory(directory);
return true;
}
catch (Exception ex)
{
Logger.Error($"Failed to create required folders for path {path}", ex);
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion src/ViewModels/Sources/GmBinderSourceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async Task<bool> FetchCover(Codex codex)
//screenshot and download the image
using (IMagickImage image = CoverService.GetCroppedScreenShot(driver, coverPage))
{
CoverService.SaveCover(codex, image);
await CoverService.SaveCover(codex, image);
}
codex.RefreshThumbnail();
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/Sources/HomebrewerySourceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ await Task.Run(() =>
//screenshot and download the image
using (IMagickImage image = CoverService.GetCroppedScreenShot(driver, location, coverPage.Size))
{
CoverService.SaveCover(codex, image);
await CoverService.SaveCover(codex, image);
}
codex.RefreshThumbnail();
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/ViewModels/Sources/PdfSourceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ public override async Task<bool> FetchCover(Codex codex)
image.BackgroundColor = new MagickColor("#FFFFFF");
image.Alpha(AlphaOption.Remove);

await image.WriteAsync(codex.CoverArt);
CoverService.CreateThumbnail(codex, image);
await CoverService.SaveCover(codex, image);
}
codex.RefreshThumbnail();
return true;
Expand Down
12 changes: 3 additions & 9 deletions src/Views/HomeLayout.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using COMPASS.Models;
using COMPASS.Tools;
using COMPASS.ViewModels;
using System;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace COMPASS.Views
{
Expand Down Expand Up @@ -33,14 +31,10 @@ private void Thumbnail_ImageFailed(object sender, System.Windows.ExceptionRouted
Image? img = sender as Image;
Codex? codex = img?.DataContext as Codex;

string msg = codex == null ? "Failed to load tumbnail" : $"Failed to load tumbnail for {codex.Title}";
string msg = codex == null ? "Failed to load thumbnail\n" : $"Failed to load thumbnail for {codex.Title}\n";
msg += "It might be corrupted, try regenerating it from the edit window";

Logger.Error(msg, e.ErrorException);

if (img != null)
{
img.Source = new BitmapImage(new Uri("pack://application:,,,/Media/CoverPlaceholder.png"));
}
Logger.Warn(msg, e.ErrorException);
}
}
}
13 changes: 4 additions & 9 deletions src/Views/TileLayout.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using COMPASS.Models;
using COMPASS.Tools;
using COMPASS.ViewModels;
using System;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace COMPASS.Views
{
Expand Down Expand Up @@ -33,14 +31,11 @@ private void Thumbnail_ImageFailed(object sender, System.Windows.ExceptionRouted
Image? img = sender as Image;
Codex? codex = img?.DataContext as Codex;

string msg = codex == null ? "Failed to load tumbnail" : $"Failed to load tumbnail for {codex.Title}";
string msg = codex == null ? "Failed to load thumbnail\n" : $"Failed to load thumbnail for {codex.Title}\n";
msg += "It might be corrupted, try regenerating it from the edit window";

Logger.Error(msg, e.ErrorException);

if (img != null)
{
img.Source = new BitmapImage(new Uri("pack://application:,,,/Media/CoverPlaceholder.png"));
}
Logger.Warn(msg, e.ErrorException);
}
}
}

4 changes: 2 additions & 2 deletions versionInfo.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.8.5</version>
<url>https://github.com/DSPAUL/COMPASS/releases/download/v1.8.5/COMPASS_Setup_1.8.5.exe</url>
<version>1.8.6</version>
<url>https://github.com/DSPAUL/COMPASS/releases/download/v1.8.6/COMPASS_Setup_1.8.6.exe</url>
<mandatory>false</mandatory>
</item>
Loading