From 5e7bff46830443953d77b3faa61290a269aeed37 Mon Sep 17 00:00:00 2001
From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com>
Date: Mon, 9 Aug 2021 20:05:12 +0530
Subject: [PATCH] Fixed icon overlay changing only once until app restart.
---
FoliCon/Models/GlobalVariables.cs | 17 ++++++++++-------
FoliCon/Models/PosterIcon.cs | 13 +++++++++++++
FoliCon/Modules/Util.cs | 13 ++++++++-----
FoliCon/Views/PosterIconFaelpessoal.xaml | 10 ++++++++++
FoliCon/Views/PosterIconFaelpessoal.xaml.cs | 12 +-----------
5 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/FoliCon/Models/GlobalVariables.cs b/FoliCon/Models/GlobalVariables.cs
index ddd34a99..9fbdbdc3 100644
--- a/FoliCon/Models/GlobalVariables.cs
+++ b/FoliCon/Models/GlobalVariables.cs
@@ -6,14 +6,17 @@ internal static class GlobalVariables
{
public static bool SkipAll;
- public static IconOverlay IconOverlayType = new PosterIconConfigViewModel().IconOverlay switch
+ public static IconOverlay IconOverlayType()
{
- "Legacy" => IconOverlay.Legacy,
- "Alternate" => IconOverlay.Alternate,
- "Liaher" => IconOverlay.Liaher,
- "Faelpessoal" => IconOverlay.Faelpessoal,
- _ => IconOverlay.Alternate
- };
+ return new PosterIconConfigViewModel().IconOverlay switch
+ {
+ "Legacy" => IconOverlay.Legacy,
+ "Alternate" => IconOverlay.Alternate,
+ "Liaher" => IconOverlay.Liaher,
+ "Faelpessoal" => IconOverlay.Faelpessoal,
+ _ => IconOverlay.Alternate
+ };
+ }
public static string MediaInfoFile = "info.folicon";
}
diff --git a/FoliCon/Models/PosterIcon.cs b/FoliCon/Models/PosterIcon.cs
index 1b47131b..10c64f53 100644
--- a/FoliCon/Models/PosterIcon.cs
+++ b/FoliCon/Models/PosterIcon.cs
@@ -11,6 +11,7 @@ public class PosterIcon
public string RatingVisibility { get; set; }
public string Rating { get; set; }
public string MockupVisibility { get; set; }
+ public string MediaTitle { get; set; }
public PosterIcon()
{
@@ -24,6 +25,7 @@ public PosterIcon()
Rating = "7.8";
MockupVisibility = "visible";
RatingVisibility = "visible";
+ MediaTitle = "Made with ♥ by FoliCon";
}
public PosterIcon(string folderJpgPath, string rating, string ratingVisibility, string mockupVisibility)
@@ -36,5 +38,16 @@ public PosterIcon(string folderJpgPath, string rating, string ratingVisibility,
//byte[] bytes = Util.ImageSourceToBytes(new PngBitmapEncoder(), FolderJpg);
//string base64string = System.Convert.ToBase64String(bytes);
}
+ public PosterIcon(string folderJpgPath, string rating, string ratingVisibility, string mockupVisibility, string mediaTitle="FoliCon")
+ {
+ RatingVisibility = ratingVisibility;
+ Rating = rating;
+ MockupVisibility = mockupVisibility;
+ var thisMemoryStream = new MemoryStream(File.ReadAllBytes(folderJpgPath));
+ FolderJpg = (ImageSource)new ImageSourceConverter().ConvertFrom(thisMemoryStream);
+ MediaTitle = mediaTitle;
+ //byte[] bytes = Util.ImageSourceToBytes(new PngBitmapEncoder(), FolderJpg);
+ //string base64string = System.Convert.ToBase64String(bytes);
+ }
}
}
\ No newline at end of file
diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs
index 1c8d099e..c6ba96b7 100644
--- a/FoliCon/Modules/Util.cs
+++ b/FoliCon/Modules/Util.cs
@@ -423,9 +423,12 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick
.Where(p => p["FolderName"].Equals(tempI))
.Select(p => p["Rating"].ToString())
.FirstOrDefault();
-
+ var mediaTitle = pickedListDataTable.AsEnumerable()
+ .Where(p => p["FolderName"].Equals(tempI))
+ .Select(p => p["Title"].ToString())
+ .FirstOrDefault();
BuildFolderIco(iconMode, $@"{selectedFolder}\{i}\{i}.png", rating, ratingVisibility,
- mockupVisibility);
+ mockupVisibility, mediaTitle);
iconProcessedCount += 1;
File.Delete($@"{selectedFolder}\{i}\{i}.png"); //<--IO Exception here
}
@@ -449,7 +452,7 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick
/// Show rating or NOT
/// Is Cover Mockup visible.
public static void BuildFolderIco(string iconMode, string filmFolderPath, string rating,
- string ratingVisibility, string mockupVisibility)
+ string ratingVisibility, string mockupVisibility, string mediaTitle)
{
if (!File.Exists(filmFolderPath))
{
@@ -469,7 +472,7 @@ public static void BuildFolderIco(string iconMode, string filmFolderPath, string
}
else
{
- using var task = GlobalVariables.IconOverlayType switch
+ using var task = GlobalVariables.IconOverlayType() switch
{
IconOverlay.Legacy => StaTask.Start(() =>
new Views.PosterIcon(new PosterIcon(filmFolderPath, rating, ratingVisibility, mockupVisibility))
@@ -482,7 +485,7 @@ public static void BuildFolderIco(string iconMode, string filmFolderPath, string
.RenderToBitmap()),
IconOverlay.Faelpessoal => StaTask.Start(() => new PosterIconFaelpessoal(new PosterIcon(
filmFolderPath, rating,
- ratingVisibility, mockupVisibility)).RenderToBitmap()),
+ ratingVisibility, mockupVisibility, mediaTitle)).RenderToBitmap()),
_ => StaTask.Start(() =>
new Views.PosterIcon(new PosterIcon(filmFolderPath, rating, ratingVisibility, mockupVisibility))
.RenderToBitmap())
diff --git a/FoliCon/Views/PosterIconFaelpessoal.xaml b/FoliCon/Views/PosterIconFaelpessoal.xaml
index 6f6a55f7..e7ec56d0 100644
--- a/FoliCon/Views/PosterIconFaelpessoal.xaml
+++ b/FoliCon/Views/PosterIconFaelpessoal.xaml
@@ -25,6 +25,16 @@
+
+
+
+
+
+
+
+
+
+