From bc9cc880a2bf85830c1d639f9d11cafcf3393a50 Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Fri, 6 Aug 2021 00:24:48 +0530 Subject: [PATCH 1/4] made changes for All except game. --- FoliCon/Models/ListItem.cs | 6 +- FoliCon/Modules/DialogServiceExtensions.cs | 10 +- FoliCon/Modules/IGDBClass.cs | 15 ++- FoliCon/Modules/TMDB.cs | 121 +++++++++++++++++--- FoliCon/Modules/Util.cs | 31 ++++- FoliCon/ViewModels/MainWindowViewModel.cs | 43 ++++--- FoliCon/ViewModels/PosterPickerViewModel.cs | 16 ++- FoliCon/ViewModels/SearchResultViewModel.cs | 11 +- 8 files changed, 198 insertions(+), 55 deletions(-) diff --git a/FoliCon/Models/ListItem.cs b/FoliCon/Models/ListItem.cs index 342ad4d0..4c6b889d 100644 --- a/FoliCon/Models/ListItem.cs +++ b/FoliCon/Models/ListItem.cs @@ -10,14 +10,15 @@ public class ListItem : BindableBase private string _folder; private string _overview; private string _poster; + private int _id; public string Title { get => _title; set => SetProperty(ref _title, value); } public string Year { get => _year; set => SetProperty(ref _year, value); } public string Rating { get => _rating; set => SetProperty(ref _rating, value); } public string Folder { get => _folder; set => SetProperty(ref _folder, value); } public string Overview { get => _overview; set => SetProperty(ref _overview, value); } public string Poster { get => _poster; set => SetProperty(ref _poster, value); } - - public ListItem(string title, string year, string rating, string overview = null, string poster = null, string folder = "") + public int Id { get => _id; set => SetProperty(ref _id, value); } + public ListItem(string title, string year, string rating, string overview = null, string poster = null, string folder = "", int id = 0) { Title = title; Year = year; @@ -25,6 +26,7 @@ public ListItem(string title, string year, string rating, string overview = null Overview = overview; Poster = poster; Folder = folder; + Id = id; } public ListItem() diff --git a/FoliCon/Modules/DialogServiceExtensions.cs b/FoliCon/Modules/DialogServiceExtensions.cs index 70995157..a022815f 100644 --- a/FoliCon/Modules/DialogServiceExtensions.cs +++ b/FoliCon/Modules/DialogServiceExtensions.cs @@ -15,14 +15,15 @@ public static void ShowMessageBox(this IDialogService dialogService, string mess } public static void ShowSearchResult(this IDialogService dialogService, string searchMode, string query, - string folderPath, ResultResponse result, Tmdb tmdbObject, IgdbClass igdbObject, + string folderPath, ResultResponse result, Tmdb tmdbObject, IgdbClass igdbObject, bool isPickedById, Action callBack) { var p = new DialogParameters { {"query", query}, {"result", result}, {"searchmode", searchMode}, {"tmdbObject", tmdbObject}, {"igdbObject", igdbObject}, - {"folderpath", folderPath} + {"folderpath", folderPath}, + {"isPickedById" , isPickedById} }; dialogService.ShowDialog("SearchResult", p, callBack); } @@ -57,11 +58,12 @@ public static void ShowAboutBox(this IDialogService dialogService, Action resultData, Action callBack) + public static void ShowPosterPicker(this IDialogService dialogService, Tmdb tmdbObject, ResultResponse result,int pickedIndex, System.Collections.ObjectModel.ObservableCollection resultData, bool isPickedById, Action callBack) { var p = new DialogParameters { - {"pickedIndex", pickedIndex}, {"result", result}, {"tmdbObject",tmdbObject} , {"resultList", resultData} + {"pickedIndex", pickedIndex}, {"result", result}, {"tmdbObject",tmdbObject} , {"resultList", resultData}, + {"isPickedById" , isPickedById} }; dialogService.ShowDialog("PosterPicker", p, callBack); } diff --git a/FoliCon/Modules/IGDBClass.cs b/FoliCon/Modules/IGDBClass.cs index e2bc149b..7c4a1785 100644 --- a/FoliCon/Modules/IGDBClass.cs +++ b/FoliCon/Modules/IGDBClass.cs @@ -50,6 +50,18 @@ public async Task SearchGameAsync(string query) }; return response; } + public async Task SearchGameByIdAsync(string id) + { + Contract.Assert(_serviceClient != null); + var r = await _serviceClient.QueryAsync(IGDBClient.Endpoints.Games, + $"fields name,first_release_date,total_rating,summary,cover.*; where id = {id}"); + var response = new ResultResponse + { + MediaType = MediaTypes.Game, + Result = r + }; + return response; + } public static ObservableCollection ExtractGameDetailsIntoListItem(Game[] result) { @@ -81,7 +93,8 @@ public void ResultPicked(Game result, string fullFolderPath, string rating = "") var year = result.FirstReleaseDate != null ? result.FirstReleaseDate.Value.Year.ToString(CultureInfo.InvariantCulture) : ""; var posterUrl = ImageHelper.GetImageUrl(result.Cover.Value.ImageId, ImageSize.HD720); Util.AddToPickedListDataTable(_listDataTable, localPosterPath, result.Name, rating, fullFolderPath, folderName, - year); + year, (int)(result.Id ?? 0)); + if (result.Id != null) Util.SaveMediaInfo((int)result.Id, "Game", fullFolderPath); var tempImage = new ImageToDownload { LocalPath = localPosterPath, diff --git a/FoliCon/Modules/TMDB.cs b/FoliCon/Modules/TMDB.cs index b5a65481..f80a5dd6 100644 --- a/FoliCon/Modules/TMDB.cs +++ b/FoliCon/Modules/TMDB.cs @@ -7,8 +7,11 @@ using System.IO; using System.Threading.Tasks; using TMDbLib.Client; +using TMDbLib.Objects.Collections; using TMDbLib.Objects.General; +using TMDbLib.Objects.Movies; using TMDbLib.Objects.Search; +using TMDbLib.Objects.TvShows; namespace FoliCon.Modules { @@ -128,6 +131,47 @@ public static ObservableCollection ExtractResourceDetailsIntoListItem( return items; } + public static ObservableCollection ExtractTvDetailsIntoListItem(TvShow result) + { + var items = new ObservableCollection(); + var mediaName = result.Name; + var year = result.FirstAirDate != null ? result.FirstAirDate.Value.Year.ToString(CultureInfo.InvariantCulture) : ""; + var rating = result.VoteAverage.ToString(CultureInfo.CurrentCulture); + var overview = result.Overview; + var poster = result.PosterPath != null ? SmallPosterBase + result.PosterPath : null; + items.Add(new ListItem(mediaName, year, rating, overview, poster)); + + return items; + } + + public static ObservableCollection ExtractCollectionDetailsIntoListItem( + Collection result) + { + var items = new ObservableCollection(); + var mediaName = result.Name; + const string year = ""; + const string rating = ""; + const string overview = ""; + var poster = Convert.ToString(result.PosterPath != null ? SmallPosterBase + result.PosterPath : null, CultureInfo.InvariantCulture); + items.Add(new ListItem(mediaName, year, rating, overview, poster)); + + return items; + } + + public static ObservableCollection ExtractMoviesDetailsIntoListItem( + Movie result) + { + var items = new ObservableCollection(); + var mediaName = result.Title; + var year = result.ReleaseDate != null ? result.ReleaseDate.Value.Year.ToString(CultureInfo.InvariantCulture) : ""; + var rating = result.VoteAverage.ToString(CultureInfo.CurrentCulture); + var overview = result.Overview; + var poster = result.PosterPath != null ? SmallPosterBase + result.PosterPath : null; + items.Add(new ListItem(mediaName, year, rating, overview, poster)); + + return items; + } + public static ObservableCollection ExtractTvDetailsIntoListItem(SearchContainer result) { var items = new ObservableCollection(); @@ -143,7 +187,6 @@ public static ObservableCollection ExtractTvDetailsIntoListItem(Search return items; } - /// /// Prepares the Selected Result for Download And final List View /// @@ -152,14 +195,17 @@ public static ObservableCollection ExtractTvDetailsIntoListItem(Search /// Full Path to the current Media Folder /// Rating for media /// TODO: Merge parameter response and resultType. - public void ResultPicked(dynamic result, string resultType, string fullFolderPath, string rating = "") + public void ResultPicked(dynamic result, string resultType, string fullFolderPath, string rating = "",bool isPickedById = false) { if (result.PosterPath == null) { throw new InvalidDataException("NoPoster"); } + + var id = 0; + var type = resultType; if (string.IsNullOrWhiteSpace(rating) && resultType != MediaTypes.Collection) - { rating = result.VoteAverage.ToString(CultureInfo.CurrentCulture); } + { rating = result.VoteAverage.ToString(CultureInfo.InvariantCulture); } var folderName = Path.GetFileName(fullFolderPath); var localPosterPath = fullFolderPath + @"\" + folderName + ".png"; @@ -167,24 +213,27 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat if (resultType == MediaTypes.Tv) { - var pickedResult = (SearchTv)result; - var year = pickedResult.FirstAirDate != null ? pickedResult.FirstAirDate.Value.Year.ToString(CultureInfo.InvariantCulture) : ""; + dynamic pickedResult = isPickedById ? (TvShow)result : (SearchTv)result; + var year = pickedResult.FirstAirDate != null ? pickedResult.FirstAirDate.Year.ToString(CultureInfo.InvariantCulture) : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, rating, fullFolderPath, folderName, - year); + year, pickedResult.Id); + id = pickedResult.Id; } else if (resultType == MediaTypes.Movie) { - var pickedResult = (SearchMovie)result; - var year = pickedResult.ReleaseDate != null ? pickedResult.ReleaseDate.Value.Year.ToString(CultureInfo.InvariantCulture) : ""; + dynamic pickedResult = isPickedById ? (Movie)result : (SearchMovie)result; + var year = pickedResult.ReleaseDate != null ? pickedResult.ReleaseDate.Year.ToString(CultureInfo.InvariantCulture) : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title, - rating, fullFolderPath, folderName, year); + rating, fullFolderPath, folderName, year, pickedResult.Id); + id = pickedResult.Id; } else if (resultType == MediaTypes.Collection) { - var searchResult = (SearchCollection)result; - Util.AddToPickedListDataTable(_listDataTable, localPosterPath, searchResult.Name, rating, fullFolderPath, - folderName); + dynamic pickedResult = isPickedById ? (Collection)result : (SearchCollection)result; + Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, rating, fullFolderPath, + folderName, "", pickedResult.Id); + id = pickedResult.Id; } else if (resultType == MediaTypes.Mtv) { @@ -193,29 +242,37 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat { case MediaType.Tv: { - SearchTv pickedResult = result; + type = "TV"; + dynamic pickedResult = isPickedById ? (TvShow)result : (SearchTv)result; var year = pickedResult.FirstAirDate != null - ? pickedResult.FirstAirDate.Value.Year.ToString(CultureInfo.InvariantCulture) + ? pickedResult.FirstAirDate.Year.ToString(CultureInfo.InvariantCulture) : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, rating, fullFolderPath, folderName, - year); + year, pickedResult.Id); + id = pickedResult.Id; break; } case MediaType.Movie: { - SearchMovie pickedResult = result; + type = "Movie"; + dynamic pickedResult = isPickedById ? (Movie)result : (SearchMovie)result; var year = pickedResult.ReleaseDate != null - ? pickedResult.ReleaseDate.Value.Year.ToString(CultureInfo.InvariantCulture) + ? pickedResult.ReleaseDate.Year.ToString(CultureInfo.InvariantCulture) : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title, rating, fullFolderPath, folderName, - year); + year, pickedResult.Id); + id = pickedResult.Id; break; } } } + if (!isPickedById && id != 0) + { + Util.SaveMediaInfo(id, type, fullFolderPath); + } var tempImage = new ImageToDownload { LocalPath = localPosterPath, @@ -265,5 +322,33 @@ public async Task SearchAsync(string query, string searchMode) }; return response; } + /// + /// Searches TMDB for a query in Specified search mode + /// + /// Title to search + /// Search Mode such as Movie,TV + /// Returns Search result with its Media Type + public ResultResponse SearchByIdAsync(int id, string mediaType) + { + object r = null; + if (mediaType == MediaTypes.Movie) + { + r = _serviceClient.GetMovieAsync(id).Result; + } + else if (mediaType == MediaTypes.Collection) + { + r = _serviceClient.GetCollectionAsync(id).Result; + } + else if (mediaType == MediaTypes.Tv) + { + r = _serviceClient.GetTvShowAsync(id).Result; + } + var response = new ResultResponse + { + Result = r, + MediaType = mediaType + }; + return response; + } } } \ No newline at end of file diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs index c6f784be..7188b756 100644 --- a/FoliCon/Modules/Util.cs +++ b/FoliCon/Modules/Util.cs @@ -26,10 +26,13 @@ using FoliCon.Properties.Langs; using HandyControl.Tools.Extension; using TMDbLib.Objects.General; +using TMDbLib.Objects.Movies; using TMDbLib.Objects.Search; +using TMDbLib.Objects.TvShows; using Vanara.PInvoke; using static Vanara.PInvoke.Gdi32; using static Vanara.PInvoke.Shell32; +using Collection = TMDbLib.Objects.Collections.Collection; using MessageBox = HandyControl.Controls.MessageBox; using PosterIcon = FoliCon.Models.PosterIcon; @@ -244,7 +247,7 @@ public static VistaFolderBrowserDialog NewFolderBrowserDialog(string description /// Short Folder Name /// Media Year public static void AddToPickedListDataTable(DataTable dataTable, string poster, string title, string rating, - string fullFolderPath, string folderName, string year = "") + string fullFolderPath, string folderName, string year = "", int id = 0) { if (rating == "0") { @@ -261,20 +264,20 @@ public static void AddToPickedListDataTable(DataTable dataTable, string poster, dataTable.Rows.Add(nRow); } - public static ObservableCollection FetchAndAddDetailsToListView(ResultResponse result, string query) + public static ObservableCollection FetchAndAddDetailsToListView(ResultResponse result, string query, bool isPickedById) { var source = new ObservableCollection(); if (result.MediaType == MediaTypes.Tv) { - var ob = (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")) { - var ob = (SearchContainer)result.Result; + dynamic ob = isPickedById ? (Collection) result.Result : (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } else @@ -282,12 +285,12 @@ public static ObservableCollection FetchAndAddDetailsToListView(Result dynamic ob; try { - ob = (SearchContainer)result.Result; + ob = isPickedById ? (Movie) result.Result : (SearchContainer)result.Result; source = Tmdb.ExtractMoviesDetailsIntoListItem(ob); } catch (Exception) { - ob = (SearchContainer)result.Result; + ob = isPickedById ? (Collection) result.Result : (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } } @@ -572,5 +575,21 @@ public static CultureInfo GetCultureInfoByLanguage(Languages language) return cultureInfo; } + + public static void SaveMediaInfo(int id, string mediaType, string folderPath) + { + var filePath = $@"{folderPath}\folicon.folicon"; + InIHelper.AddValue("ID", id.ToString(),null,filePath); + InIHelper.AddValue("MediaType", mediaType,null,filePath); + } + + public static (string ID, string MediaType) ReadMediaInfo(string folderPath) + { + var filePath = $@"{folderPath}\folicon.folicon"; + 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); + return mediaInfo; + } } } \ No newline at end of file diff --git a/FoliCon/ViewModels/MainWindowViewModel.cs b/FoliCon/ViewModels/MainWindowViewModel.cs index cd9242fe..090350b8 100644 --- a/FoliCon/ViewModels/MainWindowViewModel.cs +++ b/FoliCon/ViewModels/MainWindowViewModel.cs @@ -300,17 +300,28 @@ private async System.Threading.Tasks.Task ProcessPosterModeAsync() // TODO: Set cursor to WAIT. var isAutoPicked = false; var searchTitle = TitleCleaner.Clean(itemTitle); - var response = SearchMode == "Game" - ? await _igdbObject.SearchGameAsync(searchTitle) - : await _tmdbObject.SearchAsync(searchTitle, SearchMode); - int resultCount = SearchMode == "Game" ? response.Result.Length : response.Result.TotalResults; + var (id, mediaType) = Util.ReadMediaInfo(fullFolderPath); + var isPickedById = false; + ResultResponse response; + if (id != null && mediaType != null ) + { + isPickedById = true; + response = mediaType == "Game" ? await _igdbObject.SearchGameByIdAsync(id) : _tmdbObject.SearchByIdAsync(int.Parse(id), mediaType); + } + else + { + response = SearchMode == "Game" + ? await _igdbObject.SearchGameAsync(searchTitle) + : await _tmdbObject.SearchAsync(searchTitle, SearchMode); + } + int resultCount = isPickedById ? response.Result != null ? 1 : 0 : SearchMode == "Game" ? response.Result.Length : response.Result.TotalResults; switch (resultCount) { case 0: MessageBox.Show(CustomMessageBox.Info(LangProvider.GetLang("NothingFoundFor").Format(itemTitle), LangProvider.GetLang("NoResultFound"))); _dialogService.ShowSearchResult(SearchMode, searchTitle, fullFolderPath, response, - _tmdbObject, _igdbObject, + _tmdbObject, _igdbObject,isPickedById, r => { dialogResult = r.Result switch @@ -328,23 +339,27 @@ private async System.Threading.Tasks.Task ProcessPosterModeAsync() { if (SearchMode == "Game") { - _igdbObject.ResultPicked(response.Result[0], fullFolderPath); + var result = isPickedById + ? response.Result + : response.Result[0]; + _igdbObject.ResultPicked(result, fullFolderPath); } else { - _tmdbObject.ResultPicked(response.Result.Results[0], response.MediaType, - fullFolderPath); + var result = isPickedById + ? response.Result + : response.Result.Results[0]; + _tmdbObject.ResultPicked(result, response.MediaType, + fullFolderPath, "", isPickedById); } isAutoPicked = true; } catch (Exception ex) { - if (ex.Message == "NoPoster") - { - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), itemTitle)); - } - + MessageBox.Show(ex.Message == "NoPoster" + ? CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), itemTitle) + : CustomMessageBox.Warning(ex.Message, LangProvider.GetLang("ExceptionOccurred"))); isAutoPicked = false; } @@ -357,7 +372,7 @@ private async System.Threading.Tasks.Task ProcessPosterModeAsync() if (IsPosterWindowShown || !IsSkipAmbiguous) { _dialogService.ShowSearchResult(SearchMode, searchTitle, fullFolderPath, - response, _tmdbObject, _igdbObject, + response, _tmdbObject, _igdbObject, isPickedById, r => { dialogResult = r.Result switch diff --git a/FoliCon/ViewModels/PosterPickerViewModel.cs b/FoliCon/ViewModels/PosterPickerViewModel.cs index b058c954..596137da 100644 --- a/FoliCon/ViewModels/PosterPickerViewModel.cs +++ b/FoliCon/ViewModels/PosterPickerViewModel.cs @@ -9,8 +9,11 @@ using System.Collections.ObjectModel; using System.Globalization; using FoliCon.Properties.Langs; +using TMDbLib.Objects.Collections; using TMDbLib.Objects.General; +using TMDbLib.Objects.Movies; using TMDbLib.Objects.Search; +using TMDbLib.Objects.TvShows; namespace FoliCon.ViewModels { @@ -25,6 +28,7 @@ public class PosterPickerViewModel : BindableBase, IDialogAware public event Action RequestClose; private ResultResponse _result; private int _totalPosters; + private bool _isPickedById; #endregion #region Properties @@ -82,26 +86,27 @@ public void OnDialogOpened(IDialogParameters parameters) PickedIndex = parameters.GetValue("pickedIndex"); TmdbObject = parameters.GetValue("tmdbObject"); resultList = parameters.GetValue>("resultList"); - LoadData(Result.Result.Results[PickedIndex], Result.MediaType); + _isPickedById = parameters.GetValue("isPickedById"); + LoadData(_isPickedById ? Result.Result : Result.Result.Results[PickedIndex], Result.MediaType); } public void LoadData(dynamic result, string resultType) { ImagesWithId images = new(); if (resultType == MediaTypes.Tv) { - var pickedResult = (SearchTv)result; + dynamic pickedResult = _isPickedById ? (TvShow)result : (SearchTv)result; Title = pickedResult.Name; images = TmdbObject.SearchTvImages(pickedResult.Id); } else if (resultType == MediaTypes.Movie) { - var pickedResult = (SearchMovie)result; + dynamic pickedResult = _isPickedById ? (Movie)result : (SearchMovie)result; Title = pickedResult.Title; images = TmdbObject.SearchMovieImages(pickedResult.Id); } else if (resultType == MediaTypes.Collection) { - var pickedResult = (SearchCollection)result; + dynamic pickedResult = _isPickedById ? (Collection)result : (SearchCollection)result; Title = pickedResult.Name; images = TmdbObject.SearchCollectionImages(pickedResult.Id); } @@ -166,7 +171,8 @@ private async void LoadImages(ImagesWithId images) private void PickMethod(object parameter) { var link = (string)parameter; - Result.Result.Results[PickedIndex].PosterPath = link; + var result = _isPickedById ? Result.Result : Result.Result.Results[PickedIndex]; + result.PosterPath = link; resultList[PickedIndex].Poster = link; CloseDialog("true"); } diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index f2d2b520..76de1c98 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -29,7 +29,7 @@ public class SearchResultViewModel : BindableBase, IDialogAware private string _fullFolderPath; private readonly IDialogService _dialogService; private bool _isSearchFocused; - + private bool _isPickedById; public event Action RequestClose; private Tmdb _tmdbObject; @@ -114,6 +114,7 @@ public virtual void OnDialogOpened(IDialogParameters parameters) _tmdbObject = parameters.GetValue("tmdbObject"); _igdbObject = parameters.GetValue("igdbObject"); _fullFolderPath = parameters.GetValue("folderpath"); + _isPickedById = parameters.GetValue("isPickedById"); LoadData(SearchTitle); } @@ -140,10 +141,10 @@ private async void StartSearch(bool useBusy) private void LoadData(string searchTitle) { if (SearchResult != null - && (SearchMode == "Game" ? SearchResult.Result.Length : SearchResult.Result.TotalResults) != null - && (SearchMode == "Game" ? SearchResult?.Result.Length : SearchResult?.Result.TotalResults) != 0) + && (_isPickedById ? SearchResult.Result != null ? 1 : null : SearchMode == "Game" ? SearchResult.Result.Length : SearchResult.Result.TotalResults) != null + && (_isPickedById ? SearchResult.Result != null ? 1 : 0 : SearchMode == "Game" ? SearchResult?.Result?.Length : SearchResult?.Result?.TotalResults) != 0) { - ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, searchTitle); + ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, searchTitle,_isPickedById); if (ResultListViewData.Data.Count != 0) ResultListViewData.SelectedItem = ResultListViewData.Data[0]; } @@ -204,7 +205,7 @@ private void MouseDoubleClick() { if (SearchMode != MediaTypes.Game) { - _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data, r => { }); + _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data,_isPickedById, r => { }); } } catch (Exception ex) From 7ce21b104ca82bc66ef9f6726cac12a70554640f Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:51:14 +0530 Subject: [PATCH 2/4] Fixed count in professional mode, now only shows count of downloadable media. fixed poster picker not opening for IDPicked media, when media is not game, but search mode was game. --- FoliCon/Modules/IGDBClass.cs | 2 +- .../ViewModels/ProSearchResultViewModel.cs | 7 +- FoliCon/ViewModels/SearchResultViewModel.cs | 128 +++++++++++++++--- 3 files changed, 112 insertions(+), 25 deletions(-) diff --git a/FoliCon/Modules/IGDBClass.cs b/FoliCon/Modules/IGDBClass.cs index 7c4a1785..0bf4443c 100644 --- a/FoliCon/Modules/IGDBClass.cs +++ b/FoliCon/Modules/IGDBClass.cs @@ -54,7 +54,7 @@ public async Task SearchGameByIdAsync(string id) { Contract.Assert(_serviceClient != null); var r = await _serviceClient.QueryAsync(IGDBClient.Endpoints.Games, - $"fields name,first_release_date,total_rating,summary,cover.*; where id = {id}"); + $"fields name,first_release_date,total_rating,summary,cover.*; where id = {id};"); var response = new ResultResponse { MediaType = MediaTypes.Game, diff --git a/FoliCon/ViewModels/ProSearchResultViewModel.cs b/FoliCon/ViewModels/ProSearchResultViewModel.cs index 5557ee28..cb884238 100644 --- a/FoliCon/ViewModels/ProSearchResultViewModel.cs +++ b/FoliCon/ViewModels/ProSearchResultViewModel.cs @@ -10,6 +10,7 @@ using System.Collections.ObjectModel; using System.Data; using System.Globalization; +using System.Linq; using System.Threading.Tasks; using FoliCon.Properties.Langs; @@ -99,10 +100,10 @@ private async Task Search(string query, int offset = 0) var lastIndex = Index; if (searchResult.Results?.Length > 0) { - TotalPosters = searchResult.Results.Length + offset; + TotalPosters = searchResult.Results.Count( result => result.IsDownloadable) + offset; foreach (var item in searchResult.Results.GetEnumeratorWithIndex()) { - Index = item.Index + lastIndex; + Index += lastIndex; if (!item.Value.IsDownloadable) continue; using (var bm = await Util.GetBitmapFromUrlAsync(item.Value.Thumbs[0].Src)) @@ -114,6 +115,8 @@ private async Task Search(string query, int offset = 0) { return; } + + Index++; } if (searchResult.HasMore) { diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index 76de1c98..ff510372 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -35,22 +35,76 @@ public class SearchResultViewModel : BindableBase, IDialogAware private Tmdb _tmdbObject; private IgdbClass _igdbObject; private string customRating; + #endregion Variables #region Properties - public string Title { get => _title; set => SetProperty(ref _title, value); } - public string SearchTitle { get => _searchTitle; set => SetProperty(ref _searchTitle, value); } - public string BusyContent { get => _busyContent; set => SetProperty(ref _busyContent, value); } - public bool IsBusy { get => _isBusy; set => SetProperty(ref _isBusy, value); } - public string CustomRating { get => customRating; set => SetProperty(ref customRating, value); } - public ListViewData ResultListViewData { get => _resultListViewData; set => SetProperty(ref _resultListViewData, value); } + public string Title + { + get => _title; + set => SetProperty(ref _title, value); + } + + public string SearchTitle + { + get => _searchTitle; + set => SetProperty(ref _searchTitle, value); + } - public string SearchAgainTitle { get => _searchAgainTitle; set => SetProperty(ref _searchAgainTitle, value); } - public List FileList { get => _fileList; set => SetProperty(ref _fileList, value); } - public ResultResponse SearchResult { get => _searchResult; set => SetProperty(ref _searchResult, value); } - public string SearchMode { get => _searchMode; set => SetProperty(ref _searchMode, value); } - public bool IsSearchFocused { get => _isSearchFocused; set => SetProperty(ref _isSearchFocused, value); } + public string BusyContent + { + get => _busyContent; + set => SetProperty(ref _busyContent, value); + } + + public bool IsBusy + { + get => _isBusy; + set => SetProperty(ref _isBusy, value); + } + + public string CustomRating + { + get => customRating; + set => SetProperty(ref customRating, value); + } + + public ListViewData ResultListViewData + { + get => _resultListViewData; + set => SetProperty(ref _resultListViewData, value); + } + + public string SearchAgainTitle + { + get => _searchAgainTitle; + set => SetProperty(ref _searchAgainTitle, value); + } + + public List FileList + { + get => _fileList; + set => SetProperty(ref _fileList, value); + } + + public ResultResponse SearchResult + { + get => _searchResult; + set => SetProperty(ref _searchResult, value); + } + + public string SearchMode + { + get => _searchMode; + set => SetProperty(ref _searchMode, value); + } + + public bool IsSearchFocused + { + get => _isSearchFocused; + set => SetProperty(ref _isSearchFocused, value); + } #endregion Properties @@ -72,12 +126,15 @@ public SearchResultViewModel(IDialogService dialogService) ResultListViewData = new ListViewData { Data = null, SelectedItem = null }; PickCommand = new DelegateCommand(PickMethod); SortResultCommand = new DelegateCommand(SortResult); - SkipAllCommand = new DelegateCommand(delegate { GlobalVariables.SkipAll = true; CloseDialog("false"); }); + SkipAllCommand = new DelegateCommand(delegate + { + GlobalVariables.SkipAll = true; + CloseDialog("false"); + }); } private void SortResult() { - } protected virtual void CloseDialog(string parameter) @@ -135,16 +192,21 @@ private async void StartSearch(bool useBusy) { IsBusy = false; } + LoadData(titleToSearch); } private void LoadData(string searchTitle) { if (SearchResult != null - && (_isPickedById ? SearchResult.Result != null ? 1 : null : SearchMode == "Game" ? SearchResult.Result.Length : SearchResult.Result.TotalResults) != null - && (_isPickedById ? SearchResult.Result != null ? 1 : 0 : SearchMode == "Game" ? SearchResult?.Result?.Length : SearchResult?.Result?.TotalResults) != 0) + && (_isPickedById ? SearchResult.Result != null ? 1 : + null : + SearchMode == "Game" ? SearchResult.Result.Length : SearchResult.Result.TotalResults) != null + && (_isPickedById ? SearchResult.Result != null ? 1 : + 0 : + SearchMode == "Game" ? SearchResult?.Result?.Length : SearchResult?.Result?.TotalResults) != 0) { - ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, searchTitle,_isPickedById); + ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, searchTitle, _isPickedById); if (ResultListViewData.Data.Count != 0) ResultListViewData.SelectedItem = ResultListViewData.Data[0]; } @@ -152,6 +214,7 @@ private void LoadData(string searchTitle) { IsSearchFocused = true; } + FileList = Util.GetFileNamesFromFolder(_fullFolderPath); } @@ -167,20 +230,34 @@ private void PickMethod() { if (ResultListViewData.SelectedItem == null) return; var pickedIndex = ResultListViewData.Data.IndexOf(ResultListViewData.SelectedItem); - var rating=""; + var rating = ""; if (CustomRating is not null && customRating != "_._") { rating = CustomRating.Replace('_', '0'); } + try { - if (SearchMode == MediaTypes.Game) + if (_isPickedById) { - _igdbObject.ResultPicked(SearchResult.Result[pickedIndex], _fullFolderPath,rating); + if (SearchResult.MediaType == MediaTypes.Game) + { + _igdbObject.ResultPicked(SearchResult.Result[pickedIndex], _fullFolderPath, rating); + } + else + { + _tmdbObject.ResultPicked(SearchResult.Result.Results[pickedIndex], SearchResult.MediaType, + _fullFolderPath, rating); + } + } + else if (SearchMode == MediaTypes.Game) + { + _igdbObject.ResultPicked(SearchResult.Result[pickedIndex], _fullFolderPath, rating); } else { - _tmdbObject.ResultPicked(SearchResult.Result.Results[pickedIndex], SearchResult.MediaType, _fullFolderPath, rating); + _tmdbObject.ResultPicked(SearchResult.Result.Results[pickedIndex], SearchResult.MediaType, + _fullFolderPath, rating); } } catch (Exception ex) @@ -190,6 +267,7 @@ private void PickMethod() MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle)); } } + CloseDialog("true"); } @@ -203,9 +281,15 @@ private void MouseDoubleClick() var pickedIndex = ResultListViewData.Data.IndexOf(ResultListViewData.SelectedItem); try { - if (SearchMode != MediaTypes.Game) + if (_isPickedById) + { + _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data, + _isPickedById, r => { }); + } + else if (SearchMode != MediaTypes.Game) { - _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data,_isPickedById, r => { }); + _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data, + _isPickedById, r => { }); } } catch (Exception ex) From 659240419539d368998b00af47ef3bcaec4642d6 Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Fri, 6 Aug 2021 17:14:31 +0530 Subject: [PATCH 3/4] make folicon media info file hidden. Refector: renamed HideIcons to HideFile --- FoliCon/Modules/Util.cs | 9 +++++---- FoliCon/ViewModels/CustomIconControlViewModel.cs | 2 +- FoliCon/ViewModels/SearchResultViewModel.cs | 16 ++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs index 7188b756..247c4a18 100644 --- a/FoliCon/Modules/Util.cs +++ b/FoliCon/Modules/Util.cs @@ -412,7 +412,7 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick } if (!File.Exists(targetFile)) continue; - HideIcons(targetFile); + HideFile(targetFile); SetFolderIcon($"{i}.ico", $@"{selectedFolder}\{i}"); } ApplyChanges(selectedFolder); @@ -469,15 +469,15 @@ public static void BuildFolderIco(string iconMode, string filmFolderPath, string icon.Dispose(); } - public static void HideIcons(string icoFile) + public static void HideFile(string icoFile) { - // Set icon file attribute to "Hidden" + // Set file attribute to "Hidden" if ((File.GetAttributes(icoFile) & FileAttributes.Hidden) != FileAttributes.Hidden) { File.SetAttributes(icoFile, File.GetAttributes(icoFile) | FileAttributes.Hidden); } - // Set icon file attribute to "System" + // Set file attribute to "System" if ((File.GetAttributes(icoFile) & FileAttributes.System) != FileAttributes.System) { File.SetAttributes(icoFile, File.GetAttributes(icoFile) | FileAttributes.System); @@ -581,6 +581,7 @@ public static void SaveMediaInfo(int id, string mediaType, string folderPath) var filePath = $@"{folderPath}\folicon.folicon"; InIHelper.AddValue("ID", id.ToString(),null,filePath); InIHelper.AddValue("MediaType", mediaType,null,filePath); + Util.HideFile(filePath); } public static (string ID, string MediaType) ReadMediaInfo(string folderPath) diff --git a/FoliCon/ViewModels/CustomIconControlViewModel.cs b/FoliCon/ViewModels/CustomIconControlViewModel.cs index 954e9ac2..fccb593f 100644 --- a/FoliCon/ViewModels/CustomIconControlViewModel.cs +++ b/FoliCon/ViewModels/CustomIconControlViewModel.cs @@ -261,7 +261,7 @@ private int MakeIcons() File.Move(iconPath, newIconPath); if (!File.Exists(newIconPath)) continue; - Util.HideIcons(newIconPath); + Util.HideFile(newIconPath); Util.SetFolderIcon($"{Directories[i]}.ico", folderPath); Index++; if (StopSearch) diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index ff510372..52469b3a 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -246,8 +246,8 @@ private void PickMethod() } else { - _tmdbObject.ResultPicked(SearchResult.Result.Results[pickedIndex], SearchResult.MediaType, - _fullFolderPath, rating); + _tmdbObject.ResultPicked(SearchResult.Result, SearchResult.MediaType, + _fullFolderPath, rating,_isPickedById); } } else if (SearchMode == MediaTypes.Game) @@ -262,10 +262,9 @@ private void PickMethod() } catch (Exception ex) { - if (ex.Message == "NoPoster") - { - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle)); - } + MessageBox.Show(ex.Message == "NoPoster" + ? CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle) + : CustomMessageBox.Error(ex.Message, SearchTitle)); } CloseDialog("true"); @@ -281,12 +280,13 @@ private void MouseDoubleClick() var pickedIndex = ResultListViewData.Data.IndexOf(ResultListViewData.SelectedItem); try { - if (_isPickedById) + if (_isPickedById && SearchResult.MediaType != MediaTypes.Game) { + _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data, _isPickedById, r => { }); } - else if (SearchMode != MediaTypes.Game) + else if (SearchResult.MediaType != MediaTypes.Game) { _dialogService.ShowPosterPicker(_tmdbObject, SearchResult, pickedIndex, ResultListViewData.Data, _isPickedById, r => { }); From 5d55ce8af1140d914c5b66bb5470e53bd778bd8f Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Fri, 6 Aug 2021 20:14:02 +0530 Subject: [PATCH 4/4] added option to delete media info files(info.folicon) translation related to mediaInfo feature added. --- FoliCon/Models/GlobalVariables.cs | 2 ++ FoliCon/Modules/LangProvider.cs | 14 +++++++-- FoliCon/Modules/Util.cs | 17 ++++++++--- FoliCon/Properties/Langs/Lang.Designer.cs | 37 +++++++++++++++++++++++ FoliCon/Properties/Langs/Lang.ar.resx | 13 ++++++++ FoliCon/Properties/Langs/Lang.es.resx | 13 ++++++++ FoliCon/Properties/Langs/Lang.hi.resx | 16 ++++++++++ FoliCon/Properties/Langs/Lang.resx | 13 ++++++++ FoliCon/Properties/Langs/Lang.ru.resx | 13 ++++++++ FoliCon/ViewModels/MainWindowViewModel.cs | 19 ++++++++++++ FoliCon/Views/MainWindow.xaml | 3 ++ Folicon.sln.DotSettings | 2 ++ 12 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 Folicon.sln.DotSettings diff --git a/FoliCon/Models/GlobalVariables.cs b/FoliCon/Models/GlobalVariables.cs index a64d4595..548dc8ed 100644 --- a/FoliCon/Models/GlobalVariables.cs +++ b/FoliCon/Models/GlobalVariables.cs @@ -12,5 +12,7 @@ internal static class GlobalVariables "Alternate" => IconOverlay.Alternate, _ => IconOverlay.Alternate }; + + public static string MediaInfoFile = "info.folicon"; } } \ No newline at end of file diff --git a/FoliCon/Modules/LangProvider.cs b/FoliCon/Modules/LangProvider.cs index 95d1c1ab..c915b644 100644 --- a/FoliCon/Modules/LangProvider.cs +++ b/FoliCon/Modules/LangProvider.cs @@ -161,7 +161,10 @@ private void UpdateLangs() OnPropertyChanged(nameof(UsePosterOverlay)); OnPropertyChanged(nameof(Version)); OnPropertyChanged(nameof(Year)); - OnPropertyChanged(nameof(ExceptionOccurred)); + OnPropertyChanged(nameof(DeleteMediaInfo)); + OnPropertyChanged(nameof(DeleteMediaInfoTooltip)); + OnPropertyChanged(nameof(DeleteMediaInfoConfirmation)); + OnPropertyChanged(nameof(ConfirmMediaInfoDeletion)); } public string About => Lang.About; @@ -412,6 +415,10 @@ private void UpdateLangs() public string Year => Lang.Year; public string ExceptionOccurred => Lang.ExceptionOccurred; + public string ConfirmMediaInfoDeletion => Lang.ConfirmMediaInfoDeletion; + public string DeleteMediaInfoConfirmation => Lang.DeleteMediaInfoConfirmation; + public string DeleteMediaInfoTooltip => Lang.DeleteMediaInfoTooltip; + public string DeleteMediaInfo => Lang.DeleteMediaInfo; public event PropertyChangedEventHandler PropertyChanged; @@ -671,6 +678,9 @@ public class LangKeys public static string Year = nameof(Year); public static string ExceptionOccurred = nameof(ExceptionOccurred); - + public static string ConfirmMediaInfoDeletion = nameof(ConfirmMediaInfoDeletion); + public static string DeleteMediaInfoConfirmation = nameof(DeleteMediaInfoConfirmation); + public static string DeleteMediaInfoTooltip = nameof(DeleteMediaInfoTooltip); + public static string DeleteMediaInfo = nameof(DeleteMediaInfo); } } \ No newline at end of file diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs index 247c4a18..c5003017 100644 --- a/FoliCon/Modules/Util.cs +++ b/FoliCon/Modules/Util.cs @@ -191,6 +191,15 @@ public static void DeleteIconsFromFolder(string folderPath) File.Delete(icoFile); File.Delete(iniFile); } + + public static void DeleteMediaInfoFromSubfolders(string folderPath) + { + foreach (var folder in Directory.EnumerateDirectories(folderPath)) + { + var icoFile = Path.Combine(folder, GlobalVariables.MediaInfoFile); + File.Delete(icoFile); + } + } /// /// Checks if Web is accessible from This System /// @@ -578,15 +587,15 @@ public static CultureInfo GetCultureInfoByLanguage(Languages language) public static void SaveMediaInfo(int id, string mediaType, string folderPath) { - var filePath = $@"{folderPath}\folicon.folicon"; - InIHelper.AddValue("ID", id.ToString(),null,filePath); + var filePath = Path.Combine(folderPath, GlobalVariables.MediaInfoFile); + InIHelper.AddValue("ID", id.ToString(CultureInfo.InvariantCulture),null,filePath); InIHelper.AddValue("MediaType", mediaType,null,filePath); - Util.HideFile(filePath); + HideFile(filePath); } public static (string ID, string MediaType) ReadMediaInfo(string folderPath) { - var filePath = $@"{folderPath}\folicon.folicon"; + 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); diff --git a/FoliCon/Properties/Langs/Lang.Designer.cs b/FoliCon/Properties/Langs/Lang.Designer.cs index a46407ad..c4c1e247 100644 --- a/FoliCon/Properties/Langs/Lang.Designer.cs +++ b/FoliCon/Properties/Langs/Lang.Designer.cs @@ -267,6 +267,15 @@ public static string ConfirmIconDeletion { } } + /// + /// Looks up a localized string similar to Confirm Media Info files deletion. + /// + public static string ConfirmMediaInfoDeletion { + get { + return ResourceManager.GetString("ConfirmMediaInfoDeletion", resourceCulture); + } + } + /// /// Looks up a localized string similar to Click "Confirm" to open folder.. /// @@ -339,6 +348,34 @@ public static string DeleteIconsTooltip { } } + /// + /// Looks up a localized string similar to Delete media info. + /// + public static string DeleteMediaInfo { + get { + return ResourceManager.GetString("DeleteMediaInfo", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Are you sure you want to delete folicon media info files ?. + /// + public static string DeleteMediaInfoConfirmation { + get { + return ResourceManager.GetString("DeleteMediaInfoConfirmation", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This will delete media info files used by folicon to store media id after a title is selected for the first time. + ///This helps folicon identify media without having to chose from ambigous titles.. + /// + public static string DeleteMediaInfoTooltip { + get { + return ResourceManager.GetString("DeleteMediaInfoTooltip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Developed By Dinesh Solanki.. /// diff --git a/FoliCon/Properties/Langs/Lang.ar.resx b/FoliCon/Properties/Langs/Lang.ar.resx index afcec7d2..fe16d18e 100644 --- a/FoliCon/Properties/Langs/Lang.ar.resx +++ b/FoliCon/Properties/Langs/Lang.ar.resx @@ -499,4 +499,17 @@ حدث استثناء + + تأكيد حذف ملفات معلومات الوسائط + + + حذف معلومات الوسائط + + + هل أنت متأكد أنك تريد حذف ملفات معلومات وسائط فوليكون؟ + + + سيؤدي هذا إلى حذف ملفات معلومات الوسائط التي يستخدمها فوليكون لتخزين معرف الوسائط بعد تحديد العنوان لأول مرة. +يساعد هذا فوليكون في التعرف على الوسائط دون الحاجة إلى الاختيار من بين العناوين الغامضة. + \ No newline at end of file diff --git a/FoliCon/Properties/Langs/Lang.es.resx b/FoliCon/Properties/Langs/Lang.es.resx index 47f3e555..6478979c 100644 --- a/FoliCon/Properties/Langs/Lang.es.resx +++ b/FoliCon/Properties/Langs/Lang.es.resx @@ -499,4 +499,17 @@ y puede buscar "Juegos, películas y programas" y casi cualquier ícono de carpe Ocurrió una excepción + + Confirmar la eliminación de archivos de información multimedia + + + Eliminar información multimedia + + + ¿Está seguro de que desea eliminar los archivos de información de medios de folicon? + + + Esto eliminará los archivos de información de medios utilizados por folicon para almacenar la identificación de medios después de seleccionar un título por primera vez. +Esto ayuda a folicon a identificar los medios sin tener que elegir entre títulos ambiguos. + \ No newline at end of file diff --git a/FoliCon/Properties/Langs/Lang.hi.resx b/FoliCon/Properties/Langs/Lang.hi.resx index 629761e6..d2319533 100644 --- a/FoliCon/Properties/Langs/Lang.hi.resx +++ b/FoliCon/Properties/Langs/Lang.hi.resx @@ -496,4 +496,20 @@ संस्करण : + + मीडिया इन्फो फ़ाइलों को हटाने की पुष्टि करें + + + मीडिया जानकारी हटाएं + + + क्या आप वाकई फ़ॉलिकॉन मीडिया जानकारी फ़ाइलें हटाना चाहते हैं? + + + यह पहली बार किसी शीर्षक के चयन के बाद मीडिया आईडी को स्टोर करने के लिए फॉलिकॉन द्वारा उपयोग की जाने वाली मीडिया जानकारी फ़ाइलों को हटा देगा। +यह अस्पष्ट शीर्षकों में से चुने बिना फॉलिकॉन को मीडिया की पहचान करने में मदद करता है। + + + त्रुटी + \ No newline at end of file diff --git a/FoliCon/Properties/Langs/Lang.resx b/FoliCon/Properties/Langs/Lang.resx index ce1a4e0d..aabcb2e9 100644 --- a/FoliCon/Properties/Langs/Lang.resx +++ b/FoliCon/Properties/Langs/Lang.resx @@ -186,6 +186,9 @@ Confirm Icon Deletion + + Confirm Media Info files deletion + Click "Confirm" to open folder. @@ -210,6 +213,16 @@ This will delete existing icons from all subFolders. + + Delete media info + + + Are you sure you want to delete folicon media info files ? + + + This will delete media info files used by folicon to store media id after a title is selected for the first time. +This helps folicon identify media without having to chose from ambigous titles. + Developed By Dinesh Solanki. diff --git a/FoliCon/Properties/Langs/Lang.ru.resx b/FoliCon/Properties/Langs/Lang.ru.resx index 2acd1282..8a8420e7 100644 --- a/FoliCon/Properties/Langs/Lang.ru.resx +++ b/FoliCon/Properties/Langs/Lang.ru.resx @@ -499,4 +499,17 @@ Произошло исключение + + Подтвердите удаление файлов Media Info + + + Удалить информацию о мультимедиа + + + Вы уверены, что хотите удалить информационные файлы мультимедиа Folicon? + + + Это приведет к удалению файлов информации о мультимедиа, используемых folicon для хранения идентификатора мультимедиа после выбора заголовка в первый раз. +Это помогает фоликону идентифицировать носители без необходимости выбирать из двусмысленных названий. + \ No newline at end of file diff --git a/FoliCon/ViewModels/MainWindowViewModel.cs b/FoliCon/ViewModels/MainWindowViewModel.cs index 090350b8..bc9e1f66 100644 --- a/FoliCon/ViewModels/MainWindowViewModel.cs +++ b/FoliCon/ViewModels/MainWindowViewModel.cs @@ -176,6 +176,7 @@ public Languages AppLanguage public DelegateCommand CustomIconsCommand { get; private set; } public DelegateCommand DeleteIconsCommand { get; private set; } + public DelegateCommand DeleteMediaInfoCommand { get; private set; } public DelegateCommand HelpCommand { get; } = new(() => Util.StartProcess("https://github.com/DineshSolanki/FoliCon")); @@ -437,6 +438,7 @@ private void InitializeDelegates() PosterIconConfigCommand = new DelegateCommand(delegate { _dialogService.ShowPosterIconConfig(_ => { }); }); AboutCommand = new DelegateCommand(AboutMethod); DeleteIconsCommand = new DelegateCommand(DeleteIconsMethod); + DeleteMediaInfoCommand = new DelegateCommand(DeleteMediaInfo); CustomIconsCommand = new DelegateCommand(delegate { _dialogService.ShowCustomIconWindow( @@ -466,6 +468,23 @@ private void InitializeDelegates() }); } + private void DeleteMediaInfo() + { + if (Directory.Exists(SelectedFolder)) + { + if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("DeleteMediaInfoConfirmation"), + LangProvider.GetLang("ConfirmMediaInfoDeletion"))) == System.Windows.MessageBoxResult.Yes) + { + Util.DeleteMediaInfoFromSubfolders(SelectedFolder); + } + } + else + { + MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("DirectoryIsEmpty"), + LangProvider.GetLang("EmptyDirectory"))); + } + } + private void InitializeProperties() { Fnames = new List(); diff --git a/FoliCon/Views/MainWindow.xaml b/FoliCon/Views/MainWindow.xaml index 1f64ada1..923ecaf2 100644 --- a/FoliCon/Views/MainWindow.xaml +++ b/FoliCon/Views/MainWindow.xaml @@ -78,6 +78,9 @@ + diff --git a/Folicon.sln.DotSettings b/Folicon.sln.DotSettings new file mode 100644 index 00000000..c09c5b1d --- /dev/null +++ b/Folicon.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file