Skip to content

Commit

Permalink
Fixed icon overlay changing only once until app restart.
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshSolanki committed Aug 9, 2021
1 parent 599f9bf commit 5e7bff4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 23 deletions.
17 changes: 10 additions & 7 deletions FoliCon/Models/GlobalVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
13 changes: 13 additions & 0 deletions FoliCon/Models/PosterIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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)
Expand All @@ -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);
}
}
}
13 changes: 8 additions & 5 deletions FoliCon/Modules/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -449,7 +452,7 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick
/// <param name="ratingVisibility">Show rating or NOT</param>
/// <param name="mockupVisibility">Is Cover Mockup visible. </param>
public static void BuildFolderIco(string iconMode, string filmFolderPath, string rating,
string ratingVisibility, string mockupVisibility)
string ratingVisibility, string mockupVisibility, string mediaTitle)
{
if (!File.Exists(filmFolderPath))
{
Expand All @@ -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))
Expand All @@ -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())
Expand Down
10 changes: 10 additions & 0 deletions FoliCon/Views/PosterIconFaelpessoal.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
<RowDefinition Height="100" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding MediaTitle}" TextWrapping="Wrap" Foreground="White" FontFamily="Cormorant" TextTrimming="WordEllipsis" Margin="190,14,-2,53" RenderTransformOrigin="0.5,0.5" Grid.Row="1">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
<Image x:Name="Shield" Source="../Resources/shield.png" RenderOptions.BitmapScalingMode="HighQuality"
Margin="160,97,6,5" Panel.ZIndex="2" Visibility="{Binding RatingVisibility}" Grid.Row="1" Grid.RowSpan="2" />
<TextBlock x:Name="Ratingtext" Text="{Binding Rating}" HorizontalAlignment="Center"
Expand Down
12 changes: 1 addition & 11 deletions FoliCon/Views/PosterIconFaelpessoal.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FoliCon.Views
{
Expand Down

0 comments on commit 5e7bff4

Please sign in to comment.