diff --git a/Knossos.NET/AppStyles.axaml b/Knossos.NET/AppStyles.axaml
index ce7ac926..045f7839 100644
--- a/Knossos.NET/AppStyles.axaml
+++ b/Knossos.NET/AppStyles.axaml
@@ -274,6 +274,17 @@
+
+
+
+
diff --git a/Knossos.NET/ViewModels/Windows/ModDetailsViewModel.cs b/Knossos.NET/ViewModels/Windows/ModDetailsViewModel.cs
index 1df476d6..ebce7ae0 100644
--- a/Knossos.NET/ViewModels/Windows/ModDetailsViewModel.cs
+++ b/Knossos.NET/ViewModels/Windows/ModDetailsViewModel.cs
@@ -23,29 +23,41 @@ namespace Knossos.NET.ViewModels
///
public class ScreenshotItem
{
- public Bitmap image { get; set; }
+ public string image { get; set; }
public bool video { get; set; } = false;
public string url { get; set; }
- public ScreenshotItem(Bitmap image, bool isVideo = false)
+ public ScreenshotItem(string image, bool isVideo = false)
{
this.image = image;
this.video = isVideo;
this.url = string.Empty;
}
- internal void OpenVideo(object url)
+ internal void OpenVideo()
{
try
{
- KnUtils.OpenBrowserURL((string)url);
+ KnUtils.OpenBrowserURL(url);
}
catch (Exception ex)
{
Log.Add(Log.LogSeverity.Error, "ScreenshotItem.OpenVideo", ex);
}
}
+
+ internal void OpenImage()
+ {
+ try
+ {
+ KnUtils.OpenBrowserURL(image);
+ }
+ catch (Exception ex)
+ {
+ Log.Add(Log.LogSeverity.Error, "ScreenshotItem.OpenImage", ex);
+ }
+ }
}
///
@@ -72,7 +84,7 @@ public partial class ModDetailsViewModel : ViewModelBase
[ObservableProperty]
internal string? description = string.Empty;
[ObservableProperty]
- internal Bitmap? banner = null;
+ internal string? banner = null;
[ObservableProperty]
internal bool forumAvailable = false;
[ObservableProperty]
@@ -271,24 +283,19 @@ private void LoadBanner(int selectedIndex)
HasBanner = true;
if (System.IO.File.Exists(modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + modVersions[selectedIndex].banner))
{
- Banner = new Bitmap(modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + modVersions[selectedIndex].banner);
+ Banner = modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + modVersions[selectedIndex].banner;
}
else
{
var url = modVersions[selectedIndex].banner;
- if (url != null && url.ToLower().Contains("http"))
+ if (url != null && url.ToLower().StartsWith("http"))
{
- Banner?.Dispose();
- Banner = new Bitmap(AssetLoader.Open(new Uri("avares://Knossos.NET/Assets/general/loading.png")));
Task.Run(async () =>
{
- using (var fs = await KnUtils.GetRemoteResourceStream(url).ConfigureAwait(false))
- {
- Dispatcher.UIThread.Invoke(() => {
- if (fs != null)
- Banner = new Bitmap(fs);
- });
- }
+ var fs = await KnUtils.GetRemoteResource(url).ConfigureAwait(false);
+ Dispatcher.UIThread.Invoke(() => {
+ Banner = fs;
+ });
}).ConfigureAwait(false);
}
}
@@ -338,8 +345,7 @@ private void LoadScreenshots(int selectedIndex)
if (System.IO.File.Exists(modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + scn))
{
Dispatcher.UIThread.Invoke(() => {
- var bitmap = new Bitmap(modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + scn);
- var item = new ScreenshotItem(bitmap);
+ var item = new ScreenshotItem(modVersions[selectedIndex].fullPath + Path.DirectorySeparatorChar + scn);
Screenshots.Add(item);
});
}
@@ -347,15 +353,13 @@ private void LoadScreenshots(int selectedIndex)
{
Task.Run(async () =>
{
- using (var fs = await KnUtils.GetRemoteResourceStream(scn))
+ var fs = await KnUtils.GetRemoteResource(scn);
+ if (fs != null)
{
- if (fs != null)
- {
- Dispatcher.UIThread.Invoke(() => {
- var item = new ScreenshotItem(new Bitmap(fs));
- Screenshots.Add(item);
- });
- }
+ Dispatcher.UIThread.Invoke(() => {
+ var item = new ScreenshotItem(fs);
+ Screenshots.Add(item);
+ });
}
}).ConfigureAwait(false);
}
@@ -392,33 +396,24 @@ private async void DownloadVideoThumbnail(string url)
if (imageUrl != string.Empty)
{
- HttpResponseMessage response = await KnUtils.GetHttpClient().GetAsync(imageUrl).ConfigureAwait(false);
- byte[] content = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
- Stream stream = new MemoryStream(content);
- var item = new ScreenshotItem(new Bitmap(stream), true);
- item.url = url;
- Dispatcher.UIThread.Invoke(() => {
- Screenshots.Add(item);
- });
- }
- else
- {
- var item = new ScreenshotItem(new Bitmap(AssetLoader.Open(new Uri("avares://Knossos.NET/Assets/general/loading.png"))), true);
+ var img = await KnUtils.GetRemoteResource(imageUrl);
+ var item = new ScreenshotItem(img != null? img : "avares://Knossos.NET/Assets/general/loading.png", true);
item.url = url;
Dispatcher.UIThread.Invoke(() => {
Screenshots.Add(item);
});
+ return;
}
}
catch (Exception ex)
{
- var item = new ScreenshotItem(new Bitmap(AssetLoader.Open(new Uri("avares://Knossos.NET/Assets/general/loading.png"))), true);
- item.url = url;
- Dispatcher.UIThread.Invoke(() => {
- Screenshots.Add(item);
- });
Log.Add(Log.LogSeverity.Warning, "ModDetailsViewModel.DownloadVideoThumbnail", ex);
}
+ var itemFail = new ScreenshotItem("avares://Knossos.NET/Assets/general/loading.png", true);
+ itemFail.url = url;
+ Dispatcher.UIThread.Invoke(() => {
+ Screenshots.Add(itemFail);
+ });
}
///
diff --git a/Knossos.NET/Views/Templates/DevModDetailsView.axaml b/Knossos.NET/Views/Templates/DevModDetailsView.axaml
index 64024969..d3834bbe 100644
--- a/Knossos.NET/Views/Templates/DevModDetailsView.axaml
+++ b/Knossos.NET/Views/Templates/DevModDetailsView.axaml
@@ -79,7 +79,7 @@
-
+
@@ -88,25 +88,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Knossos.NET/Views/Windows/ModDetailsView.axaml b/Knossos.NET/Views/Windows/ModDetailsView.axaml
index 8d3065be..d5ce51df 100644
--- a/Knossos.NET/Views/Windows/ModDetailsView.axaml
+++ b/Knossos.NET/Views/Windows/ModDetailsView.axaml
@@ -12,16 +12,22 @@
Width="1070"
WindowStartupLocation="CenterOwner"
Title="{Binding Name}"
- CanResize="True">
+ CanResize="True"
+ xmlns:anim="https://github.com/whistyun/AnimatedImage.Avalonia"
+ xmlns:cvt="clr-namespace:Knossos.NET.Converters;assembly=Knossos.NET">
+
+
+
+
-
+
@@ -78,8 +84,8 @@
-
-