diff --git a/FoliCon/Models/IgdbJotTrackerStore.cs b/FoliCon/Models/IgdbJotTrackerStore.cs index d98c67ce..e25ead88 100644 --- a/FoliCon/Models/IgdbJotTrackerStore.cs +++ b/FoliCon/Models/IgdbJotTrackerStore.cs @@ -8,7 +8,7 @@ public class IgdbJotTrackerStore : BindableBase, ITokenStore { private TwitchAccessToken _currentToken; private TwitchAccessToken CurrentToken { get => _currentToken; set => SetProperty(ref _currentToken, value); } - public IgdbJotTrackerStore() + public IgdbJotTrackerStore() { Services.Tracker.Configure() .Property(p => p._currentToken) diff --git a/FoliCon/Modules/DArt.cs b/FoliCon/Modules/DArt.cs index efc4bc77..9103619a 100644 --- a/FoliCon/Modules/DArt.cs +++ b/FoliCon/Modules/DArt.cs @@ -86,7 +86,7 @@ public async Task Browse(string query, int offset = 0) "&limit=20&access_token=" + ClientAccessToken; using var response = await Services.HttpC.GetAsync(new Uri(url)); var jsonData = await response.Content.ReadAsStringAsync(); - var serializerSettings = new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore}; + var serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var result = JsonConvert.DeserializeObject(jsonData, serializerSettings); return result; } diff --git a/FoliCon/Modules/DialogServiceExtensions.cs b/FoliCon/Modules/DialogServiceExtensions.cs index cb92b881..3b5d29b4 100644 --- a/FoliCon/Modules/DialogServiceExtensions.cs +++ b/FoliCon/Modules/DialogServiceExtensions.cs @@ -57,6 +57,6 @@ public static void ShowAboutBox(this IDialogService dialogService, Action - /// https://stackoverflow.com/a/15275682/8076598 - /// - public static IEnumerable OrderBySequence( - this IEnumerable source, - IEnumerable order, - Func idSelector) + /// + /// https://stackoverflow.com/a/15275682/8076598 + /// + public static IEnumerable OrderBySequence( + this IEnumerable source, + IEnumerable order, + Func idSelector) { var lookup = source.ToLookup(idSelector, t => t); foreach (var id in order) @@ -29,12 +29,12 @@ public static IEnumerable OrderBySequence( } } } - /// - /// https://stackoverflow.com/a/13257600/8076598 - /// - public static ObservableCollection ToObservableCollection(this IEnumerable col) - { - return new(col); - } + /// + /// https://stackoverflow.com/a/13257600/8076598 + /// + public static ObservableCollection ToObservableCollection(this IEnumerable col) + { + return new(col); + } } } \ No newline at end of file diff --git a/FoliCon/Modules/FocusExtension.cs b/FoliCon/Modules/FocusExtension.cs index 77f250fd..1ec761de 100644 --- a/FoliCon/Modules/FocusExtension.cs +++ b/FoliCon/Modules/FocusExtension.cs @@ -29,7 +29,7 @@ public static class FocusExtension { public static bool GetIsFocused(DependencyObject depObj) { - return (bool) depObj.GetValue(IsFocusedProperty); + return (bool)depObj.GetValue(IsFocusedProperty); } public static void SetIsFocused(DependencyObject depObj, bool isFocused) @@ -47,14 +47,14 @@ private static void OnIsFocusedPropertyChanged(DependencyObject depObj, Dependen { if (!(depObj is UIElement element)) return; // Don't care about false values. - if (!(bool) args.NewValue) return; + if (!(bool)args.NewValue) return; // only focusable if these two are true // optional to raise exception if they aren't rather than just ignoring. //if (element.Focusable && element.IsVisible) if (!element.Focusable) return; - var action = new Action(() => element.Dispatcher.BeginInvoke((Action) (() => element.Focus()))); + var action = new Action(() => element.Dispatcher.BeginInvoke((Action)(() => element.Focus()))); Task.Factory.StartNew(action); - var action2 = new Action(() => element.Dispatcher.BeginInvoke((Action) (() => Keyboard.Focus(element)))); + var action2 = new Action(() => element.Dispatcher.BeginInvoke((Action)(() => Keyboard.Focus(element)))); Task.Factory.StartNew(action2); FocusManager.SetFocusedElement(FocusManager.GetFocusScope(element), element); } diff --git a/FoliCon/Modules/FolderDragDropHelper.cs b/FoliCon/Modules/FolderDragDropHelper.cs index 546fa905..5339ffce 100644 --- a/FoliCon/Modules/FolderDragDropHelper.cs +++ b/FoliCon/Modules/FolderDragDropHelper.cs @@ -14,7 +14,7 @@ public class FolderDragDropHelper { public static bool GetIsFileDragDropEnabled(DependencyObject obj) { - return (bool) obj.GetValue(IsFileDragDropEnabledProperty); + return (bool)obj.GetValue(IsFileDragDropEnabledProperty); } public static void SetIsFileDragDropEnabled(DependencyObject obj, bool value) @@ -24,7 +24,7 @@ public static void SetIsFileDragDropEnabled(DependencyObject obj, bool value) public static bool GetFileDragDropTarget(DependencyObject obj) { - return (bool) obj.GetValue(FileDragDropTargetProperty); + return (bool)obj.GetValue(FileDragDropTargetProperty); } public static void SetFileDragDropTarget(DependencyObject obj, bool value) @@ -66,7 +66,7 @@ private static void OnDrop(object sender, DragEventArgs dragEventArgs) // if (_dragEventArgs.Data.GetDataPresent(DataFormats.FileDrop)) // { - fileTarget.OnFileDrop((string[]) dragEventArgs.Data.GetData(DataFormats.FileDrop), ((Control) sender).Name ); + fileTarget.OnFileDrop((string[])dragEventArgs.Data.GetData(DataFormats.FileDrop), ((Control)sender).Name); // } } diff --git a/FoliCon/Modules/IGDBClass.cs b/FoliCon/Modules/IGDBClass.cs index 61af90d3..45e89ea3 100644 --- a/FoliCon/Modules/IGDBClass.cs +++ b/FoliCon/Modules/IGDBClass.cs @@ -1,4 +1,7 @@ -using System; +using FoliCon.Models; +using IGDB; +using IGDB.Models; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; @@ -6,9 +9,6 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using FoliCon.Models; -using IGDB; -using IGDB.Models; namespace FoliCon.Modules { @@ -54,13 +54,13 @@ public static ObservableCollection ExtractGameDetailsIntoListItem(Game { var items = new ObservableCollection(); foreach (var (mediaName, year, overview, poster) in from item in result - let mediaName = item.Name - let year = item.FirstReleaseDate != null ? item.FirstReleaseDate.Value.Year.ToString() : "" - let overview = item.Summary - let poster = item.Cover != null - ? "https://" + ImageHelper.GetImageUrl(item.Cover.Value.ImageId, ImageSize.HD720).Substring(2) - : null - select (mediaName, year, overview, poster)) + let mediaName = item.Name + let year = item.FirstReleaseDate != null ? item.FirstReleaseDate.Value.Year.ToString() : "" + let overview = item.Summary + let poster = item.Cover != null + ? "https://" + ImageHelper.GetImageUrl(item.Cover.Value.ImageId, ImageSize.HD720).Substring(2) + : null + select (mediaName, year, overview, poster)) { items.Add(new ListItem(mediaName, year, "", overview, poster)); } diff --git a/FoliCon/Modules/TMDB.cs b/FoliCon/Modules/TMDB.cs index 1216eb0b..fa04d761 100644 --- a/FoliCon/Modules/TMDB.cs +++ b/FoliCon/Modules/TMDB.cs @@ -1,11 +1,11 @@ -using System; +using FoliCon.Models; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Globalization; using System.IO; using System.Threading.Tasks; -using FoliCon.Models; using TMDbLib.Client; using TMDbLib.Objects.General; using TMDbLib.Objects.Search; @@ -83,25 +83,25 @@ public static ObservableCollection ExtractResourceDetailsIntoListItem( switch (mediaType) { case MediaType.Tv: - { - var res = (SearchTv) item; - mediaName = res.Name; - year = res.FirstAirDate != null ? res.FirstAirDate.Value.Year.ToString() : ""; - rating = res.VoteAverage.ToString(CultureInfo.CurrentCulture); - overview = res.Overview; - poster = res.PosterPath != null ? SmallPosterBase + res.PosterPath : null; - break; - } + { + var res = (SearchTv)item; + mediaName = res.Name; + year = res.FirstAirDate != null ? res.FirstAirDate.Value.Year.ToString() : ""; + rating = res.VoteAverage.ToString(CultureInfo.CurrentCulture); + overview = res.Overview; + poster = res.PosterPath != null ? SmallPosterBase + res.PosterPath : null; + break; + } case MediaType.Movie: - { - var res = (SearchMovie) item; - mediaName = res.Title; - year = res.ReleaseDate != null ? res.ReleaseDate.Value.Year.ToString() : ""; - rating = res.VoteAverage.ToString(CultureInfo.CurrentCulture); - overview = res.Overview; - poster = res.PosterPath != null ? SmallPosterBase + res.PosterPath : null; - break; - } + { + var res = (SearchMovie)item; + mediaName = res.Title; + year = res.ReleaseDate != null ? res.ReleaseDate.Value.Year.ToString() : ""; + rating = res.VoteAverage.ToString(CultureInfo.CurrentCulture); + overview = res.Overview; + poster = res.PosterPath != null ? SmallPosterBase + res.PosterPath : null; + break; + } } items.Add(new ListItem(mediaName, year, rating, overview, poster)); @@ -145,7 +145,7 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat string posterUrl = string.Concat(PosterBase, result.PosterPath); if (resultType == MediaTypes.Tv) { - var pickedResult = (SearchTv) result; + var pickedResult = (SearchTv)result; var year = pickedResult.FirstAirDate != null ? pickedResult.FirstAirDate.Value.Year.ToString() : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, @@ -153,14 +153,14 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat } else if (resultType == MediaTypes.Movie) { - var pickedResult = (SearchMovie) result; + var pickedResult = (SearchMovie)result; var year = pickedResult.ReleaseDate != null ? pickedResult.ReleaseDate.Value.Year.ToString() : ""; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title, pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, year); } else if (resultType == MediaTypes.Collection) { - var searchResult = (SearchCollection) result; + var searchResult = (SearchCollection)result; Util.AddToPickedListDataTable(_listDataTable, localPosterPath, searchResult.Name, "", fullFolderPath, folderName); } @@ -170,27 +170,27 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat switch (mediaType) { case MediaType.Tv: - { - SearchTv pickedResult = result; - var year = pickedResult.FirstAirDate != null - ? pickedResult.FirstAirDate.Value.Year.ToString() - : ""; - Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, - pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, - year); - break; - } + { + SearchTv pickedResult = result; + var year = pickedResult.FirstAirDate != null + ? pickedResult.FirstAirDate.Value.Year.ToString() + : ""; + Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, + pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, + year); + break; + } case MediaType.Movie: - { - SearchMovie pickedResult = result; - var year = pickedResult.ReleaseDate != null - ? pickedResult.ReleaseDate.Value.Year.ToString() - : ""; - Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title, - pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, - year); - break; - } + { + SearchMovie pickedResult = result; + var year = pickedResult.ReleaseDate != null + ? pickedResult.ReleaseDate.Value.Year.ToString() + : ""; + Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title, + pickedResult.VoteAverage.ToString(CultureInfo.CurrentCulture), fullFolderPath, folderName, + year); + break; + } } } diff --git a/FoliCon/Modules/Util.cs b/FoliCon/Modules/Util.cs index 7c892b40..c05ff720 100644 --- a/FoliCon/Modules/Util.cs +++ b/FoliCon/Modules/Util.cs @@ -1,4 +1,10 @@ -using System; +using FoliCon.Models; +using FoliCon.Views; +using HandyControl.Controls; +using HandyControl.Data; +using IGDB.Models; +using Ookii.Dialogs.Wpf; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; @@ -15,12 +21,6 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; -using FoliCon.Models; -using FoliCon.Views; -using HandyControl.Controls; -using HandyControl.Data; -using IGDB.Models; -using Ookii.Dialogs.Wpf; using TMDbLib.Objects.General; using TMDbLib.Objects.Search; using Vanara.PInvoke; @@ -67,7 +67,7 @@ public static void CheckForUpdate() Growl.InfoGlobal(info); } } - else Growl.ErrorGlobal(new GrowlInfo {Message = "Network not available!", ShowDateTime = false}); + else Growl.ErrorGlobal(new GrowlInfo { Message = "Network not available!", ShowDateTime = false }); } /// @@ -128,7 +128,7 @@ public static void KillExplorer() WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = true }; - using var process = new Process {StartInfo = taskKill}; + using var process = new Process { StartInfo = taskKill }; process.Start(); process.WaitForExit(); } @@ -173,7 +173,7 @@ public static void DeleteIconsFromSubfolders(string folderPath) } RefreshIconCache(); // SHChangeNotify(SHCNE.SHCNE_UPDATEDIR, SHCNF.SHCNF_PATHW | SHCNF.SHCNF_FLUSHNOWAIT,folderPath); - SHChangeNotify(SHCNE.SHCNE_ASSOCCHANGED, SHCNF.SHCNF_IDLIST | SHCNF.SHCNF_FLUSHNOWAIT,folderPath); + SHChangeNotify(SHCNE.SHCNE_ASSOCCHANGED, SHCNF.SHCNF_IDLIST | SHCNF.SHCNF_FLUSHNOWAIT, folderPath); } public static void DeleteIconsFromFolder(string folderPath) @@ -199,7 +199,7 @@ public static bool IsNetworkAvailable() if (reply != null && reply.Status == IPStatus.Success) result = true; } - catch(Exception) + catch (Exception) { // ignored } @@ -213,8 +213,8 @@ 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; @@ -264,14 +264,14 @@ public static ObservableCollection FetchAndAddDetailsToListView(Result if (result.MediaType == MediaTypes.Tv) { - var ob = (SearchContainer) result.Result; + var ob = (SearchContainer)result.Result; source = Tmdb.ExtractTvDetailsIntoListItem(ob); } - else if (result.MediaType == MediaTypes.Movie) + else if (result.MediaType == MediaTypes.Movie || result.MediaType == MediaTypes.Collection) { if (query.ToLower().Contains("collection")) { - var ob = (SearchContainer) result.Result; + var ob = (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } else @@ -279,24 +279,24 @@ public static ObservableCollection FetchAndAddDetailsToListView(Result dynamic ob; try { - ob = (SearchContainer) result.Result; + ob = (SearchContainer)result.Result; source = Tmdb.ExtractMoviesDetailsIntoListItem(ob); } catch (Exception) { - ob = (SearchContainer) result.Result; + ob = (SearchContainer)result.Result; source = Tmdb.ExtractCollectionDetailsIntoListItem(ob); } } } else if (result.MediaType == MediaTypes.Mtv) { - var ob = (SearchContainer) result.Result; + var ob = (SearchContainer)result.Result; source = Tmdb.ExtractResourceDetailsIntoListItem(ob); } else if (result.MediaType == MediaTypes.Game) { - var ob = (Game[]) result.Result; + var ob = (Game[])result.Result; source = IgdbClass.ExtractGameDetailsIntoListItem(ob); } @@ -347,9 +347,9 @@ public static BitmapSource LoadBitmap(Bitmap source) /// Bitmap object public static async Task GetBitmapFromUrlAsync(string url) { - var myRequest = (HttpWebRequest) WebRequest.Create(new Uri(url)); + var myRequest = (HttpWebRequest)WebRequest.Create(new Uri(url)); myRequest.Method = "GET"; - var myResponse = (HttpWebResponse) await myRequest.GetResponseAsync().ConfigureAwait(false); + var myResponse = (HttpWebResponse)await myRequest.GetResponseAsync().ConfigureAwait(false); var bmp = new Bitmap(myResponse.GetResponseStream()); myResponse.Close(); return bmp; @@ -402,7 +402,7 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick SetFolderIcon(i + ".ico", selectedFolder + "\\" + i); } ApplyChanges(selectedFolder); - SHChangeNotify(SHCNE.SHCNE_UPDATEITEM, SHCNF.SHCNF_PATHW,selectedFolder); + SHChangeNotify(SHCNE.SHCNE_UPDATEITEM, SHCNF.SHCNF_PATHW, selectedFolder); return iconProcessedCount; } @@ -484,7 +484,7 @@ public static void SetFolderIcon(string icoFile, string folderPath) { dwMask = FOLDERCUSTOMSETTINGSMASK.FCSM_ICONFILE, pszIconFile = icoFile, - dwSize =(uint) Marshal.SizeOf(typeof(SHFOLDERCUSTOMSETTINGS)), + dwSize = (uint)Marshal.SizeOf(typeof(SHFOLDERCUSTOMSETTINGS)), cchIconFile = 0 }; //FolderSettings.iIconIndex = 0; @@ -505,8 +505,8 @@ public static void ApplyChanges(string folderPath) // CultureInfo ci = new CultureInfo("en-US"); // System.Threading.Thread.CurrentThread.CurrentCulture = ci //var pidl = ILCreateFromPath(folderPath); - - SHChangeNotify(SHCNE.SHCNE_UPDATEDIR, SHCNF.SHCNF_PATHW,folderPath); + + SHChangeNotify(SHCNE.SHCNE_UPDATEDIR, SHCNF.SHCNF_PATHW, folderPath); } #endregion IconUtil diff --git a/FoliCon/String2BooleanConvertor.cs b/FoliCon/String2BooleanConvertor.cs index d592c143..9d871ed6 100644 --- a/FoliCon/String2BooleanConvertor.cs +++ b/FoliCon/String2BooleanConvertor.cs @@ -5,7 +5,7 @@ namespace FoliCon { - public class String2BooleanConvertor :ResourceDictionary, IValueConverter + public class String2BooleanConvertor : ResourceDictionary, IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { @@ -14,7 +14,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return value != null && (bool) value ? parameter : DependencyProperty.UnsetValue; + return value != null && (bool)value ? parameter : DependencyProperty.UnsetValue; } } } \ No newline at end of file diff --git a/FoliCon/ViewModels/ApiConfigurationViewModel.cs b/FoliCon/ViewModels/ApiConfigurationViewModel.cs index 24a4ab23..7fa9d538 100644 --- a/FoliCon/ViewModels/ApiConfigurationViewModel.cs +++ b/FoliCon/ViewModels/ApiConfigurationViewModel.cs @@ -36,13 +36,13 @@ public ApiConfigurationViewModel() private void SaveMethod() { - if (string.IsNullOrEmpty(TmdbKey) || string.IsNullOrEmpty(IgdbClientSecret) ||string.IsNullOrEmpty(IgdbClientId) || string.IsNullOrEmpty(DArtClient) || string.IsNullOrEmpty(DArtClientId)) + if (string.IsNullOrEmpty(TmdbKey) || string.IsNullOrEmpty(IgdbClientSecret) || string.IsNullOrEmpty(IgdbClientId) || string.IsNullOrEmpty(DArtClient) || string.IsNullOrEmpty(DArtClientId)) { MessageBox.Error("All fields are required!", "Invalid Value"); } else { - Util.WriteApiConfiguration(TmdbKey, IgdbClientId,IgdbClientSecret, DArtClient, DArtClientId); + Util.WriteApiConfiguration(TmdbKey, IgdbClientId, IgdbClientSecret, DArtClient, DArtClientId); MessageBox.Success("API configuration Saved.", "Success"); CloseDialog("true"); } diff --git a/FoliCon/ViewModels/CustomIconControlViewModel.cs b/FoliCon/ViewModels/CustomIconControlViewModel.cs index 0a1c6123..c02d1a12 100644 --- a/FoliCon/ViewModels/CustomIconControlViewModel.cs +++ b/FoliCon/ViewModels/CustomIconControlViewModel.cs @@ -1,16 +1,16 @@ -using System; +using FoliCon.Modules; +using HandyControl.Controls; +using HandyControl.Data; +using Prism.Commands; +using Prism.Mvvm; +using Prism.Services.Dialogs; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.IO; using System.Linq; using System.Windows; -using FoliCon.Modules; -using HandyControl.Controls; -using HandyControl.Data; -using Prism.Commands; -using Prism.Mvvm; -using Prism.Services.Dialogs; using static Vanara.PInvoke.Shell32; using MessageBox = HandyControl.Controls.MessageBox; // ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault @@ -155,7 +155,7 @@ private void LoadDirectoryMethod() { var folderBrowserDialog = Util.NewFolderBrowserDialog("Select Folder"); var dialogResult = folderBrowserDialog.ShowDialog(); - if (dialogResult != null && (bool) !dialogResult) return; + if (dialogResult != null && (bool)!dialogResult) return; _backupDirectories.Clear(); SelectedDirectory = folderBrowserDialog.SelectedPath; } @@ -164,7 +164,7 @@ private void LoadIconsMethod() { var folderBrowserDialog = Util.NewFolderBrowserDialog("Select Icons Directory"); var dialogResult = folderBrowserDialog.ShowDialog(); - if (dialogResult != null && (bool) !dialogResult) return; + if (dialogResult != null && (bool)!dialogResult) return; _backupIcons.Clear(); SelectedIconsDirectory = folderBrowserDialog.SelectedPath; } @@ -252,7 +252,7 @@ private int MakeIcons() { var icon = new ProIcon(iconPath).RenderToBitmap(); iconPath = iconPath.Replace(Path.GetExtension(Icons[i])!, ".ico"); - PngToIcoService.Convert(icon,iconPath ); + PngToIcoService.Convert(icon, iconPath); icon.Dispose(); } diff --git a/FoliCon/ViewModels/MainWindowViewModel.cs b/FoliCon/ViewModels/MainWindowViewModel.cs index 5e092ced..27f41d2d 100644 --- a/FoliCon/ViewModels/MainWindowViewModel.cs +++ b/FoliCon/ViewModels/MainWindowViewModel.cs @@ -198,7 +198,7 @@ private void LoadMethod() { var folderBrowserDialog = Util.NewFolderBrowserDialog("Select Folder"); var dialogResult = folderBrowserDialog.ShowDialog(); - if (dialogResult != null && (bool) !dialogResult) return; + if (dialogResult != null && (bool)!dialogResult) return; SelectedFolder = folderBrowserDialog.SelectedPath; StatusBarProperties.ResetData(); IsMakeEnabled = true; @@ -292,60 +292,60 @@ private async System.Threading.Tasks.Task ProcessPosterModeAsync() }); break; case 1: - { - try { - if (SearchMode == "Game") - { - _igdbObject.ResultPicked(response.Result[0], fullFolderPath); - } - else + try { - _tmdbObject.ResultPicked(response.Result.Results[0], response.MediaType, - fullFolderPath); - } + if (SearchMode == "Game") + { + _igdbObject.ResultPicked(response.Result[0], fullFolderPath); + } + else + { + _tmdbObject.ResultPicked(response.Result.Results[0], response.MediaType, + fullFolderPath); + } - isAutoPicked = true; - } - catch (Exception ex) - { - if (ex.Message == "NoPoster") + isAutoPicked = true; + } + catch (Exception ex) { - var p = new DialogParameters + if (ex.Message == "NoPoster") + { + var p = new DialogParameters { {"title", "No Poster"}, {"message", "No poster found."} }; - _dialogService.ShowDialog("MessageBox", p, _ => { }); + _dialogService.ShowDialog("MessageBox", p, _ => { }); + } + + isAutoPicked = false; } - isAutoPicked = false; + break; } - - break; - } default: - { - if (resultCount > 1) { - if (!IsSkipAmbiguous) + if (resultCount > 1) { - _dialogService.ShowSearchResult(SearchMode, searchTitle, fullFolderPath, - response, _tmdbObject, _igdbObject, - r => - { - dialogResult = r.Result switch + if (!IsSkipAmbiguous) + { + _dialogService.ShowSearchResult(SearchMode, searchTitle, fullFolderPath, + response, _tmdbObject, _igdbObject, + r => { - ButtonResult.None => false, - ButtonResult.OK => true, - ButtonResult.Cancel => false, - _ => false - }; - }); + dialogResult = r.Result switch + { + ButtonResult.None => false, + ButtonResult.OK => true, + ButtonResult.Cancel => false, + _ => false + }; + }); + } } - } - break; - } + break; + } } if (isAutoPicked || dialogResult) @@ -402,13 +402,13 @@ private void InitializeDelegates() ); LoadCommand = new DelegateCommand(LoadMethod); SearchAndMakeCommand = new DelegateCommand(SearchAndMakeMethod); - IconModeChangedCommand = new DelegateCommand(delegate(object parameter) + IconModeChangedCommand = new DelegateCommand(delegate (object parameter) { - IconMode = (string) parameter; + IconMode = (string)parameter; }); - SearchModeChangedCommand = new DelegateCommand(delegate(object parameter) + SearchModeChangedCommand = new DelegateCommand(delegate (object parameter) { - SearchMode = (string) parameter; + SearchMode = (string)parameter; }); ListViewDoubleClickCommand = new DelegateCommand(ListViewDoubleClickMethod); DownloadCancelCommand = new DelegateCommand(delegate { StopIconDownload = true; }); @@ -466,12 +466,12 @@ public void InitPickedListDataTable() { _pickedListDataTable.Columns.Clear(); _pickedListDataTable.Rows.Clear(); - var column1 = new DataColumn("Poster") {DataType = typeof(string)}; - var column2 = new DataColumn("Title") {DataType = typeof(string)}; - var column3 = new DataColumn("Year") {DataType = typeof(string)}; - var column4 = new DataColumn("Rating") {DataType = typeof(string)}; - var column5 = new DataColumn("Folder") {DataType = typeof(string)}; - var column6 = new DataColumn("FolderName") {DataType = typeof(string)}; + var column1 = new DataColumn("Poster") { DataType = typeof(string) }; + var column2 = new DataColumn("Title") { DataType = typeof(string) }; + var column3 = new DataColumn("Year") { DataType = typeof(string) }; + var column4 = new DataColumn("Rating") { DataType = typeof(string) }; + var column5 = new DataColumn("Folder") { DataType = typeof(string) }; + var column6 = new DataColumn("FolderName") { DataType = typeof(string) }; _pickedListDataTable.Columns.Add(column1); _pickedListDataTable.Columns.Add(column2); _pickedListDataTable.Columns.Add(column3); diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index 9c8164b4..95007635 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -105,7 +105,7 @@ public virtual void OnDialogOpened(IDialogParameters parameters) _tmdbObject = parameters.GetValue("tmdbObject"); _igdbObject = parameters.GetValue("igdbObject"); _fullFolderPath = parameters.GetValue("folderpath"); - LoadData(); + LoadData(SearchTitle); } private async void StartSearch(bool useBusy) @@ -120,8 +120,8 @@ private async void StartSearch(bool useBusy) ResultResponse result; if (SearchMode == MediaTypes.Game) { - - result = await _igdbObject.SearchGameAsync(titleToSearch.Replace(@"\"," ")); + + result = await _igdbObject.SearchGameAsync(titleToSearch.Replace(@"\", " ")); } else { @@ -132,24 +132,24 @@ private async void StartSearch(bool useBusy) { IsBusy = false; } - LoadData(); + LoadData(titleToSearch); } - private void LoadData() + 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) { - ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, SearchTitle); - if(ResultListViewData.Data.Count!=0) + ResultListViewData.Data = Util.FetchAndAddDetailsToListView(SearchResult, _searchTitle); + if (ResultListViewData.Data.Count != 0) ResultListViewData.SelectedItem = ResultListViewData.Data[0]; } else { IsSearchFocused = true; } - FileList = new ArrayList {Util.GetFileNamesFromFolder(_fullFolderPath)}; + FileList = new ArrayList { Util.GetFileNamesFromFolder(_fullFolderPath) }; } private void SearchAgainMethod() diff --git a/FoliCon/ViewModels/posterIconConfigViewModel.cs b/FoliCon/ViewModels/posterIconConfigViewModel.cs index 9f3d6d9e..d2c65153 100644 --- a/FoliCon/ViewModels/posterIconConfigViewModel.cs +++ b/FoliCon/ViewModels/posterIconConfigViewModel.cs @@ -1,8 +1,8 @@ -using Prism.Mvvm; +using Prism.Commands; +using Prism.Mvvm; using Prism.Services.Dialogs; using System; using System.Globalization; -using Prism.Commands; namespace FoliCon.ViewModels { @@ -17,9 +17,9 @@ public PosterIconConfigViewModel() .Property(p => p.IconOverlay, defaultValue: "Alternate") .PersistOn(nameof(PropertyChanged)); Services.Tracker.Track(this); - IconOverlayChangedCommand = new DelegateCommand(delegate(object parameter) + IconOverlayChangedCommand = new DelegateCommand(delegate (object parameter) { - IconOverlay = (string) parameter; + IconOverlay = (string)parameter; }); } @@ -47,7 +47,7 @@ protected virtual void CloseDialog(string parameter) RaiseRequestClose(new DialogResult(result)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) => + public virtual void RaiseRequestClose(IDialogResult dialogResult) => RequestClose?.Invoke(dialogResult); public virtual bool CanCloseDialog() => true; diff --git a/FoliCon/Views/AboutBox.xaml.cs b/FoliCon/Views/AboutBox.xaml.cs index 1ba3caae..5f7f6862 100644 --- a/FoliCon/Views/AboutBox.xaml.cs +++ b/FoliCon/Views/AboutBox.xaml.cs @@ -15,12 +15,12 @@ public AboutBox() private void TextBlock_MouseEnter(object sender, MouseEventArgs e) { - Cursor=Cursors.Hand; + Cursor = Cursors.Hand; } private void TextBlock_MouseLeave(object sender, MouseEventArgs e) { - Cursor=Cursors.Arrow; + Cursor = Cursors.Arrow; } //private void W_Deactivated(object sender, System.EventArgs e)