//Combine all the saved lists to make comparison IEnumerable <DataBindApp> CombineAppLists(bool includeShortcuts, bool includeProcesses, bool includeLaunchers) { try { IEnumerable <DataBindApp> combinedLists = List_Apps.ToList(); combinedLists = combinedLists.Concat(List_Games.ToList()); combinedLists = combinedLists.Concat(List_Emulators.ToList()); if (includeShortcuts) { combinedLists = combinedLists.Concat(List_Shortcuts.ToList()); } if (includeProcesses) { combinedLists = combinedLists.Concat(List_Processes.ToList()); } if (includeLaunchers) { combinedLists = combinedLists.Concat(List_Launchers.ToList()); } return(combinedLists); } catch (Exception ex) { Debug.WriteLine("Failed combining application lists: " + ex.Message); return(null); } }
//Check for empty lists and hide them void ShowHideEmptyList() { try { Visibility visibilityGames = List_Games.Any() ? Visibility.Visible : Visibility.Collapsed; Visibility visibilityApps = List_Apps.Any() ? Visibility.Visible : Visibility.Collapsed; Visibility visibilityEmulators = List_Emulators.Any() ? Visibility.Visible : Visibility.Collapsed; Visibility visibilityLaunchers = List_Launchers.Any() ? Visibility.Visible : Visibility.Collapsed; Visibility visibilityShortcuts = List_Shortcuts.Any() && Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherShortcuts")) ? Visibility.Visible : Visibility.Collapsed; Visibility visibilityProcesses = List_Processes.Any() && Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherProcesses")) ? Visibility.Visible : Visibility.Collapsed; AVActions.ActionDispatcherInvoke(delegate { sp_Games.Visibility = visibilityGames; sp_Apps.Visibility = visibilityApps; sp_Emulators.Visibility = visibilityEmulators; sp_Launchers.Visibility = visibilityLaunchers; sp_Shortcuts.Visibility = visibilityShortcuts; sp_Processes.Visibility = visibilityProcesses; }); } catch { } }
//Get all the shortcuts and update the list async Task RefreshListShortcuts(bool showStatus) { try { //Check if shortcuts need to be updated if (!Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherShortcuts"))) { //Debug.WriteLine("Shortcuts don't need to be updated, cancelling."); return; } //Check if already refreshing if (vBusyRefreshingShortcuts) { Debug.WriteLine("Shortcuts are already refreshing, cancelling."); return; } //Update the refreshing status vBusyRefreshingShortcuts = true; //Show the loading gif AVActions.ActionDispatcherInvoke(delegate { gif_Shortcuts_Loading.Show(); }); //Show refresh status message if (showStatus) { await Notification_Send_Status("Refresh", "Refreshing shortcuts"); } //Get all files from the shortcut directories IEnumerable <FileInfo> directoryShortcuts = Enumerable.Empty <FileInfo>(); foreach (ProfileShared shortcutFolder in vCtrlLocationsShortcut) { try { string editedShortcutFolder = shortcutFolder.String1; editedShortcutFolder = editedShortcutFolder.Replace("%DESKTOPUSER%", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); editedShortcutFolder = editedShortcutFolder.Replace("%DESKTOPPUBLIC%", Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)); if (Directory.Exists(editedShortcutFolder)) { DirectoryInfo directoryInfo = new DirectoryInfo(editedShortcutFolder); IEnumerable <FileInfo> filterShortcuts = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).Where(x => x.Name.ToLower().EndsWith(".url") || x.Name.ToLower().EndsWith(".lnk")); directoryShortcuts = directoryShortcuts.Concat(filterShortcuts); } } catch { } } //Sort and filter the list by shortcut name directoryShortcuts = directoryShortcuts.OrderBy(x => x.Name); //Remove shortcuts that are no longer available from the list Func <DataBindApp, bool> filterShortcutApp = x => x.Category == AppCategory.Shortcut && !directoryShortcuts.Any(y => StripShortcutFilename(y.Name) == x.Name); await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, filterShortcutApp); await ListBoxRemoveAll(lb_Search, List_Search, filterShortcutApp); //Get shortcut information and add it to the list foreach (FileInfo file in directoryShortcuts) { try { //Read shortcut file information ShortcutDetails shortcutDetails = ReadShortcutFile(file.FullName); string targetTitleLower = shortcutDetails.Title.ToLower(); string targetPathLower = shortcutDetails.TargetPath.ToLower(); string targetArgumentLower = shortcutDetails.Argument.ToLower(); //Check if already in combined list and remove it if (CombineAppLists(false, false, true).Any(x => x.Name.ToLower() == targetTitleLower || x.PathExe.ToLower() == targetPathLower)) { //Debug.WriteLine("Shortcut is in the combined list skipping: " + fileNameStripped.ToLower()); await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower); continue; } //Check if shortcut name is in shortcut blacklist if (vCtrlIgnoreShortcutName.Any(x => x.String1.ToLower() == targetTitleLower)) { //Debug.WriteLine("Shortcut is on the blacklist skipping: " + fileNameStripped.ToLower()); await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower); continue; } //Check if shortcut uri is in shortcut uri blacklist if (vCtrlIgnoreShortcutUri.Any(x => targetPathLower.Contains(x.String1.ToLower()))) { //Debug.WriteLine("Shortcut uri is on the uri blacklist skipping: " + targetPathLower); await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower); continue; } //Check if shortcut is already in the shortcut list DataBindApp shortcutExistCheck = List_Shortcuts.Where(x => x.PathExe.ToLower() == targetPathLower && x.Argument.ToLower() == targetArgumentLower).FirstOrDefault(); if (shortcutExistCheck != null) { //Debug.WriteLine("Shortcut is already in list, updating: " + targetPathLower); shortcutExistCheck.Name = shortcutDetails.Title; shortcutExistCheck.ShortcutPath = shortcutDetails.ShortcutPath; continue; } //Add shortcut to the shortcuts list await ShortcutAddToListWithDetails(shortcutDetails); } catch { } } //Hide the loading gif AVActions.ActionDispatcherInvoke(delegate { gif_Shortcuts_Loading.Hide(); }); } catch (Exception ex) { Debug.WriteLine("Failed loading shortcuts: " + ex.Message); } //Update the refreshing status vBusyRefreshingShortcuts = false; }