diff --git a/FoliCon/FoliCon.csproj b/FoliCon/FoliCon.csproj index 343131ad..f9761347 100644 --- a/FoliCon/FoliCon.csproj +++ b/FoliCon/FoliCon.csproj @@ -26,11 +26,18 @@ dineshsolanki.github.io/folicon/ + + + + + + + @@ -50,13 +57,20 @@ dineshsolanki.github.io/folicon/ + + + + + + + diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs index c5003017..1c8d099e 100644 --- a/FoliCon/Modules/Util.cs +++ b/FoliCon/Modules/Util.cs @@ -49,8 +49,8 @@ public static async void CheckForUpdate(bool onlyShowIfUpdateAvailable = false) { var info = new GrowlInfo { - - Message = LangProvider.GetLang("NewVersionFound").Format(ver.TagName, ver.Changelog.Replace("\\n", Environment.NewLine)), + Message = LangProvider.GetLang("NewVersionFound").Format(ver.TagName, + ver.Changelog.Replace("\\n", Environment.NewLine)), ConfirmStr = LangProvider.GetLang("UpdateNow"), CancelStr = LangProvider.GetLang("Ignore"), ShowDateTime = false, @@ -75,7 +75,9 @@ public static async void CheckForUpdate(bool onlyShowIfUpdateAvailable = false) Growl.InfoGlobal(info); } } - else Growl.ErrorGlobal(new GrowlInfo { Message = LangProvider.GetLang("NetworkNotAvailable"), ShowDateTime = false }); + else + Growl.ErrorGlobal(new GrowlInfo + { Message = LangProvider.GetLang("NetworkNotAvailable"), ShowDateTime = false }); } /// @@ -179,6 +181,7 @@ public static void DeleteIconsFromSubfolders(string folderPath) { DeleteIconsFromFolder(folder); } + RefreshIconCache(); SHChangeNotify(SHCNE.SHCNE_ASSOCCHANGED, SHCNF.SHCNF_IDLIST | SHCNF.SHCNF_FLUSHNOWAIT, folderPath); } @@ -200,6 +203,7 @@ public static void DeleteMediaInfoFromSubfolders(string folderPath) File.Delete(icoFile); } } + /// /// Checks if Web is accessible from This System /// @@ -229,9 +233,10 @@ public static List GetFolderNames(string folderPath) if (!string.IsNullOrEmpty(folderPath)) { folderNames.AddRange(from folder in Directory.GetDirectories(folderPath) - where !File.Exists(folder + @"\" + Path.GetFileName(folder) + ".ico") - select Path.GetFileName(folder)); + where !File.Exists(folder + @"\" + Path.GetFileName(folder) + ".ico") + select Path.GetFileName(folder)); } + return folderNames; } @@ -273,20 +278,23 @@ public static void AddToPickedListDataTable(DataTable dataTable, string poster, dataTable.Rows.Add(nRow); } - public static ObservableCollection FetchAndAddDetailsToListView(ResultResponse result, string query, bool isPickedById) + public static ObservableCollection FetchAndAddDetailsToListView(ResultResponse result, string query, + bool isPickedById) { var source = new ObservableCollection(); if (result.MediaType == MediaTypes.Tv) { - dynamic ob = isPickedById ? (TvShow) result.Result : (SearchContainer)result.Result; + dynamic ob = isPickedById ? (TvShow)result.Result : (SearchContainer)result.Result; source = Tmdb.ExtractTvDetailsIntoListItem(ob); } else if (result.MediaType == MediaTypes.Movie || result.MediaType == MediaTypes.Collection) { if (query.ToLower(CultureInfo.InvariantCulture).Contains("collection")) { - dynamic ob = isPickedById ? (Collection) result.Result : (SearchContainer)result.Result; + dynamic ob = isPickedById + ? (Collection)result.Result + : (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } else @@ -294,12 +302,14 @@ public static ObservableCollection FetchAndAddDetailsToListView(Result dynamic ob; try { - ob = isPickedById ? (Movie) result.Result : (SearchContainer)result.Result; + ob = isPickedById ? (Movie)result.Result : (SearchContainer)result.Result; source = Tmdb.ExtractMoviesDetailsIntoListItem(ob); } catch (Exception) { - ob = isPickedById ? (Collection) result.Result : (SearchContainer)result.Result; + ob = isPickedById + ? (Collection)result.Result + : (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } } @@ -424,6 +434,7 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick HideFile(targetFile); SetFolderIcon($"{i}.ico", $@"{selectedFolder}\{i}"); } + ApplyChanges(selectedFolder); SHChangeNotify(SHCNE.SHCNE_UPDATEITEM, SHCNF.SHCNF_PATHW, selectedFolder); return iconProcessedCount; @@ -466,6 +477,12 @@ public static void BuildFolderIco(string iconMode, string filmFolderPath, string IconOverlay.Alternate => StaTask.Start(() => new PosterIconAlt(new PosterIcon(filmFolderPath, rating, ratingVisibility, mockupVisibility)) .RenderToBitmap()), + IconOverlay.Liaher => StaTask.Start(() => + new PosterIconLiaher(new PosterIcon(filmFolderPath, rating, ratingVisibility, mockupVisibility)) + .RenderToBitmap()), + IconOverlay.Faelpessoal => StaTask.Start(() => new PosterIconFaelpessoal(new PosterIcon( + filmFolderPath, rating, + ratingVisibility, mockupVisibility)).RenderToBitmap()), _ => StaTask.Start(() => new Views.PosterIcon(new PosterIcon(filmFolderPath, rating, ratingVisibility, mockupVisibility)) .RenderToBitmap()) @@ -529,7 +546,7 @@ public static void ApplyChanges(string folderPath) #endregion IconUtil public static void ReadApiConfiguration(out string tmdbkey, out string igdbClientId, - out string igdbClientSecret, out string dartClientSecret, out string dartId) + out string igdbClientSecret, out string dartClientSecret, out string dartId) { var settings = GlobalDataHelper.Load(); tmdbkey = settings.TmdbKey; @@ -588,8 +605,8 @@ public static CultureInfo GetCultureInfoByLanguage(Languages language) public static void SaveMediaInfo(int id, string mediaType, string folderPath) { var filePath = Path.Combine(folderPath, GlobalVariables.MediaInfoFile); - InIHelper.AddValue("ID", id.ToString(CultureInfo.InvariantCulture),null,filePath); - InIHelper.AddValue("MediaType", mediaType,null,filePath); + InIHelper.AddValue("ID", id.ToString(CultureInfo.InvariantCulture), null, filePath); + InIHelper.AddValue("MediaType", mediaType, null, filePath); HideFile(filePath); } @@ -598,7 +615,7 @@ public static (string ID, string MediaType) ReadMediaInfo(string folderPath) var filePath = Path.Combine(folderPath, GlobalVariables.MediaInfoFile); var id = File.Exists(filePath) ? InIHelper.ReadValue("ID", null, filePath) : null; var mediaType = File.Exists(filePath) ? InIHelper.ReadValue("MediaType", null, filePath) : null; - var mediaInfo = (ID:id, MediaType:mediaType); + var mediaInfo = (ID: id, MediaType: mediaType); return mediaInfo; } } diff --git a/FoliCon/Resources/PosterIconFaelpessoal 2.ico b/FoliCon/Resources/PosterIconFaelpessoal 2.ico new file mode 100644 index 00000000..e6a478db Binary files /dev/null and b/FoliCon/Resources/PosterIconFaelpessoal 2.ico differ diff --git a/FoliCon/Resources/PosterIconFaelpessoal.ico b/FoliCon/Resources/PosterIconFaelpessoal.ico new file mode 100644 index 00000000..3691f447 Binary files /dev/null and b/FoliCon/Resources/PosterIconFaelpessoal.ico differ diff --git a/FoliCon/Resources/PosterIconFaelpessoalHorizontal.ico b/FoliCon/Resources/PosterIconFaelpessoalHorizontal.ico new file mode 100644 index 00000000..dcc13507 Binary files /dev/null and b/FoliCon/Resources/PosterIconFaelpessoalHorizontal.ico differ diff --git a/FoliCon/Resources/PosterIconFaelpessoalHorizontal2.ico b/FoliCon/Resources/PosterIconFaelpessoalHorizontal2.ico new file mode 100644 index 00000000..155f6558 Binary files /dev/null and b/FoliCon/Resources/PosterIconFaelpessoalHorizontal2.ico differ diff --git a/FoliCon/Resources/PosterIconLiaher.ico b/FoliCon/Resources/PosterIconLiaher.ico new file mode 100644 index 00000000..bf018de2 Binary files /dev/null and b/FoliCon/Resources/PosterIconLiaher.ico differ diff --git a/FoliCon/Resources/PosterIconLiaher2.ico b/FoliCon/Resources/PosterIconLiaher2.ico new file mode 100644 index 00000000..92298324 Binary files /dev/null and b/FoliCon/Resources/PosterIconLiaher2.ico differ diff --git a/FoliCon/Views/PosterIconFaelpessoal.xaml.cs b/FoliCon/Views/PosterIconFaelpessoal.xaml.cs index 2c7fa735..0a06723e 100644 --- a/FoliCon/Views/PosterIconFaelpessoal.xaml.cs +++ b/FoliCon/Views/PosterIconFaelpessoal.xaml.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -24,5 +26,36 @@ public PosterIconFaelpessoal() { InitializeComponent(); } + + public PosterIconFaelpessoal(object dataContext) + { + DataContext = dataContext; + InitializeComponent(); + } + public Bitmap RenderToBitmap() + { + return RenderTargetBitmapTo32BppArgb(AsRenderTargetBitmap()); + } + + private RenderTargetBitmap AsRenderTargetBitmap() + { + var size = new System.Windows.Size(256, 256); + Measure(size); + Arrange(new Rect(size)); + + var rtb = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Default); + rtb.Render(this); + + return rtb; + } + + private static Bitmap RenderTargetBitmapTo32BppArgb(BitmapSource rtb) + { + var stream = new MemoryStream(); + BitmapEncoder encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(rtb)); + encoder.Save(stream); + return new Bitmap(stream); + } } } diff --git a/FoliCon/Views/PosterIconLiaher.xaml.cs b/FoliCon/Views/PosterIconLiaher.xaml.cs index 0b2dea83..8a74be01 100644 --- a/FoliCon/Views/PosterIconLiaher.xaml.cs +++ b/FoliCon/Views/PosterIconLiaher.xaml.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -24,5 +26,36 @@ public PosterIconLiaher() { InitializeComponent(); } + + public PosterIconLiaher(object dataContext) + { + DataContext = dataContext; + InitializeComponent(); + } + public Bitmap RenderToBitmap() + { + return RenderTargetBitmapTo32BppArgb(AsRenderTargetBitmap()); + } + + private RenderTargetBitmap AsRenderTargetBitmap() + { + var size = new System.Windows.Size(256, 256); + Measure(size); + Arrange(new Rect(size)); + + var rtb = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Default); + rtb.Render(this); + + return rtb; + } + + private static Bitmap RenderTargetBitmapTo32BppArgb(BitmapSource rtb) + { + var stream = new MemoryStream(); + BitmapEncoder encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(rtb)); + encoder.Save(stream); + return new Bitmap(stream); + } } } diff --git a/FoliCon/Views/posterIconConfig.xaml b/FoliCon/Views/posterIconConfig.xaml index 134180e7..c093e130 100644 --- a/FoliCon/Views/posterIconConfig.xaml +++ b/FoliCon/Views/posterIconConfig.xaml @@ -20,8 +20,9 @@ @@ -29,11 +30,15 @@ + Background="Transparent" Width="843"> + + + + + + + + + + + + + + \ No newline at end of file