Пример #1
0
 //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);
     }
 }
Пример #2
0
        async Task BethesdaAddApplication(string appId, string appName, string appIcon, string installDir)
        {
            try
            {
                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Check if application is installed
                if (!Directory.Exists(installDir))
                {
                    Debug.WriteLine("Bethesda game is not installed: " + appId);
                    return;
                }

                //Get launch argument
                string runCommand = "bethesdanet://run/" + appId;
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("Bethesda app already in list: " + appId);
                    return;
                }

                //Get application image
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appIcon, "Bethesda" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.Bethesda,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    PathLaunch     = installDir,
                    StatusLauncher = vImagePreloadBethesda
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added Bethesda app: " + appName);
            }
            catch
            {
                Debug.WriteLine("Failed adding Bethesda app: " + appId);
            }
        }
Пример #3
0
        async Task UwpAddApplication(Package appPackage, AppxDetails appxDetails)
        {
            try
            {
                //Get application name
                string appName = appxDetails.DisplayName;

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get basic application information
                string runCommand = appPackage.Id.FamilyName;
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("UWP app already in list: " + appIds);
                    return;
                }

                //Load the application image
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appxDetails.SquareLargestLogoPath, appxDetails.WideLargestLogoPath, "Microsoft" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Type           = ProcessType.UWP,
                    Launcher       = AppLauncher.UWP,
                    Category       = AppCategory.Launcher,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    StatusLauncher = vImagePreloadMicrosoft
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added UWP app: " + appName);
            }
            catch
            {
                Debug.WriteLine("Failed adding UWP app: " + appxDetails.DisplayName);
            }
        }
Пример #4
0
        //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 { }
        }
Пример #5
0
        async Task EpicAddApplication(string appNameId, string installLocation, List <EpicInstalledManifest> installedManifests)
        {
            try
            {
                //Check if application is installed
                if (!Directory.Exists(installLocation))
                {
                    Debug.WriteLine("Epic game is not installed: " + appNameId);
                    return;
                }

                //Get application manifest
                EpicInstalledManifest appManifest = installedManifests.Where(x => x.AppName.ToLower() == appNameId.ToLower()).FirstOrDefault();

                //Get launch argument
                string runCommand = "com.epicgames.launcher://apps/" + appNameId + "?action=launch&silent=true";
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("Epic app already in list: " + appIds);
                    return;
                }

                //Get application name
                string appName = appManifest.DisplayName;

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get application image
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, "Epic" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.Epic,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    StatusLauncher = vImagePreloadEpic
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added epic app: " + appNameId);
            }
            catch
            {
                Debug.WriteLine("Failed adding epic app: " + appNameId);
            }
        }
Пример #6
0
        async Task EADesktopAddApplication(string localContentAppPath)
        {
            try
            {
                //Get application mfst files
                string   appIds            = string.Empty;
                string[] localContentFiles = Directory.GetFiles(localContentAppPath, "*.mfst");

                //Check if application is installed
                if (!localContentFiles.Any())
                {
                    Debug.WriteLine("EADesktop game is not installed: " + localContentAppPath);
                    return;
                }

                //Get application ids
                foreach (string localFile in localContentFiles)
                {
                    try
                    {
                        //Fix Open mfst > get dipinstallpath > get exe path from reg > image from exe
                        string appId = Path.GetFileNameWithoutExtension(localFile);
                        if (appId.StartsWith("OFB-EAST"))
                        {
                            appId = appId.Replace("OFB-EAST", "OFB-EAST:");
                        }
                        appIds += appId + ",";
                    }
                    catch { }
                }
                appIds = AVFunctions.StringRemoveEnd(appIds, ",");

                //Set run command
                string runCommand = "origin://LaunchGame/" + appIds;
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("EADesktop app already in list: " + appIds);
                    return;
                }

                //Get application name
                string appName = Path.GetFileName(localContentAppPath);

                //Replace characters in name
                appName = appName.Replace("(TM)", "™");

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get application image
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, "EA Desktop" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.EADesktop,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    StatusLauncher = vImagePreloadEADesktop
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added EADesktop app: " + appIds + "/" + appName);
            }
            catch
            {
                Debug.WriteLine("Failed adding EADesktop app: " + localContentAppPath);
            }
        }
Пример #7
0
        async Task SteamAddApplication(string appmanifestPath, string steamMainPath)
        {
            try
            {
                KeyValue keyValue = new KeyValue();
                keyValue.ReadFileAsText(appmanifestPath);

                //Get application id
                string appId = keyValue["appID"].Value;

                //Get launch argument
                string runCommand = "steam://rungameid/" + appId;
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("Steam app already in list: " + appId);
                    return;
                }

                //Check if application id is in blacklist
                if (vSteamIdBlacklist.Contains(appId))
                {
                    Debug.WriteLine("Steam id is blacklisted: " + appId);
                    return;
                }

                //Get application name
                string appName = keyValue["name"].Value;
                if (string.IsNullOrWhiteSpace(appName) || appName.Contains("appid"))
                {
                    appName = keyValue["installDir"].Value;
                }

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get application image
                string      libraryImageName = steamMainPath + "\\appcache\\librarycache\\" + appId + "_library_600x900.jpg";
                string      logoImageName    = steamMainPath + "\\appcache\\librarycache\\" + appId + "_logo.png";
                BitmapImage iconBitmapImage  = FileToBitmapImage(new string[] { appName, libraryImageName, logoImageName, "Steam" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.Steam,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    StatusLauncher = vImagePreloadSteam
                };
                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added steam app: " + appId + "/" + appName);
            }
            catch
            {
                Debug.WriteLine("Failed adding steam app: " + appmanifestPath);
            }
        }
Пример #8
0
        async Task LoadLauncherApplications()
        {
            try
            {
                //Check if already refreshing
                if (vBusyRefreshingLaunchers)
                {
                    Debug.WriteLine("Launchers are already refreshing, cancelling.");
                    return;
                }

                //Update the refreshing status
                vBusyRefreshingLaunchers = true;

                //Show the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Launchers_Loading.Show();
                });

                //Check if sorting is required
                bool sortByName = !List_Launchers.Any();

                //Clear the app remove check list
                vLauncherAppAvailableCheck.Clear();

                //Scan and add library from Steam
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibrarySteam")))
                {
                    await SteamScanAddLibrary();
                }

                //Scan and add library from EA Desktop
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryEADesktop")))
                {
                    await EADesktopScanAddLibrary();
                }

                //Scan and add library from Epic
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryEpic")))
                {
                    await EpicScanAddLibrary();
                }

                //Scan and add library from Ubisoft
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryUbisoft")))
                {
                    await UbisoftScanAddLibrary();
                }

                //Scan and add library from GoG
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryGoG")))
                {
                    await GoGScanAddLibrary();
                }

                //Scan and add library from Battle.net
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryBattleNet")))
                {
                    await BattleNetScanAddLibrary();
                }

                //Scan and add library from Bethesda
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryBethesda")))
                {
                    await BethesdaScanAddLibrary();
                }

                //Scan and add library from Rockstar
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryRockstar")))
                {
                    await RockstarScanAddLibrary();
                }

                //Scan and add library from Amazon
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryAmazon")))
                {
                    await AmazonScanAddLibrary();
                }

                //Scan and add library from UWP games
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryUwp")))
                {
                    await UwpScanAddLibrary();
                }

                //Remove deleted launcher applications
                Func <DataBindApp, bool> filterLauncherApp = x => x.Category == AppCategory.Launcher && !vLauncherAppAvailableCheck.Any(y => y == x.PathExe);
                await ListBoxRemoveAll(lb_Launchers, List_Launchers, filterLauncherApp);
                await ListBoxRemoveAll(lb_Search, List_Search, filterLauncherApp);

                //Sort applications and select first item
                if (sortByName)
                {
                    SortFunction <DataBindApp> sortFuncName = new SortFunction <DataBindApp>();
                    sortFuncName.function = x => x.Name;

                    List <SortFunction <DataBindApp> > orderListLaunchers = new List <SortFunction <DataBindApp> >();
                    orderListLaunchers.Add(sortFuncName);

                    SortObservableCollection(lb_Launchers, List_Launchers, orderListLaunchers, null);

                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        lb_Launchers.SelectedIndex = 0;
                    });
                }

                //Hide the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Launchers_Loading.Hide();
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading launchers: " + ex.Message);
            }
            //Update the refreshing status
            vBusyRefreshingLaunchers = false;
        }
Пример #9
0
        async Task GoGAddApplication(string gogGamePath, string icoFilePath, GoGGameInfo gogGameInfo)
        {
            try
            {
                //Check if information is dlc
                if (!gogGameInfo.playTasks.Any())
                {
                    Debug.WriteLine("Skipping GoG dlc: " + gogGameInfo.name);
                    return;
                }

                //Add game playtasks
                IEnumerable <GoGPlayTasks> gameTasks = gogGameInfo.playTasks.Where(x => x.isPrimary || x.category == GoGAppCategory.game);
                foreach (GoGPlayTasks gameTask in gameTasks)
                {
                    try
                    {
                        //Get executable launch path
                        string runCommand = Path.Combine(gogGamePath, gameTask.path);
                        runCommand = runCommand.Replace("/", "\\");
                        runCommand = Regex.Replace(runCommand, @"\s*(\\){2,}\s*", "\\");
                        vLauncherAppAvailableCheck.Add(runCommand);

                        //Check if application is already added
                        DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                        if (launcherExistCheck != null)
                        {
                            //Debug.WriteLine("GoG app already in list: " + appIds);
                            continue;
                        }

                        //Get application name
                        string appName = gameTask.name;
                        if (string.IsNullOrWhiteSpace(appName))
                        {
                            appName = gogGameInfo.name;
                        }

                        //Check application name
                        string   appNameLower    = appName.ToLower();
                        string[] nameFilterCheck = { "run", "launch", "launcher" };
                        bool     replaceName     = nameFilterCheck.Any(x => appNameLower.StartsWith(x));
                        if (replaceName)
                        {
                            appName      = gogGameInfo.name;
                            appNameLower = appName.ToLower();
                        }

                        //Check if application name is ignored
                        if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                        {
                            //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                            await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                            continue;
                        }

                        //Get application launch argument
                        string launchArgument = gameTask.arguments;

                        //Get application image
                        string       appImage     = string.Empty;
                        GoGPlayTasks playtaskIcon = gogGameInfo.playTasks.Where(x => !string.IsNullOrWhiteSpace(x.icon)).FirstOrDefault();
                        if (playtaskIcon != null)
                        {
                            appImage = Path.Combine(gogGamePath, playtaskIcon.icon);
                            //Debug.WriteLine("Set GoG image to: " + appImage);
                        }
                        BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appImage, icoFilePath, "GoG" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                        //Check the application category
                        Visibility categoryLauncher = gameTask.category == GoGAppCategory.launcher ? Visibility.Visible : Visibility.Collapsed;

                        //Add the application to the list
                        DataBindApp dataBindApp = new DataBindApp()
                        {
                            Category          = AppCategory.Launcher,
                            Launcher          = AppLauncher.GoG,
                            Name              = appName,
                            ImageBitmap       = iconBitmapImage,
                            PathExe           = runCommand,
                            Argument          = launchArgument,
                            StatusLauncher    = vImagePreloadGoG,
                            StatusUrlProtocol = categoryLauncher
                        };

                        await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                        //Debug.WriteLine("Added GoG game: " + appName + "/" + gameTask.category);
                    }
                    catch { }
                }
            }
            catch
            {
                Debug.WriteLine("Failed adding GoG game: " + gogGameInfo.name);
            }
        }
Пример #10
0
        async Task UbisoftAddApplication(string appId, string installDir)
        {
            try
            {
                //Check if application is installed
                if (!Directory.Exists(installDir))
                {
                    Debug.WriteLine("Ubisoft game is not installed: " + appId);
                    return;
                }

                //Get launch argument
                string runCommand = "uplay://launch/" + appId + "/0";
                vLauncherAppAvailableCheck.Add(runCommand);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("Ubisoft app already in list: " + appIds);
                    return;
                }

                //Get application name
                string appName = Path.GetFileName(installDir);

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get application image
                //Fix open yaml configurations and look for image (Ubisoft Launcher\cache\assets)
                //string configurationsPath = Path.Combine(UbisoftInstallPath(), "cache\\configuration\\configurations"); > thumbimage
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, "Ubisoft" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.Ubisoft,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = runCommand,
                    StatusLauncher = vImagePreloadUbisoft
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added Ubisoft app: " + appName);
            }
            catch
            {
                Debug.WriteLine("Failed adding Ubisoft app: " + appId);
            }
        }
Пример #11
0
        async Task BattleNetAddApplication(ProductInstall productInstall, string launcherExePath)
        {
            try
            {
                //Get application details
                //Improve find way to load proper uid
                string appUid     = productInstall.uid;
                string installDir = productInstall.settings.installPath;

                //Check if application id is in blacklist
                if (vBattleNetUidBlacklist.Contains(appUid))
                {
                    Debug.WriteLine("BattleNet uid is blacklisted: " + appUid);
                    return;
                }

                //Check if application is installed
                if (!Directory.Exists(installDir))
                {
                    Debug.WriteLine("BattleNet game is not installed: " + appUid);
                    return;
                }

                //Set application launch argument
                string launchArgument = "--exec=\"launch_uid " + appUid + "\"";
                vLauncherAppAvailableCheck.Add(launcherExePath);

                //Check if application is already added
                DataBindApp launcherExistCheck = List_Launchers.Where(x => !string.IsNullOrWhiteSpace(x.Argument) && x.Argument.ToLower() == launchArgument.ToLower()).FirstOrDefault();
                if (launcherExistCheck != null)
                {
                    //Debug.WriteLine("BattleNet app already in list: " + appUid);
                    return;
                }

                //Get application branch
                string appBranch = productInstall.settings.branch;
                appBranch = appBranch.Replace("_", string.Empty);
                foreach (string branchReplace in vBattleNetBranchReplace)
                {
                    appBranch = appBranch.Replace(branchReplace, string.Empty);
                }
                appBranch = AVFunctions.ToTitleCase(appBranch);

                //Get application name
                string appName = Path.GetFileName(installDir);
                if (!string.IsNullOrWhiteSpace(appBranch))
                {
                    appName += " (" + appBranch + ")";
                }

                //Check if application name is ignored
                string appNameLower = appName.ToLower();
                if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                {
                    //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                    await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                    return;
                }

                //Get application image
                BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, "Battle.Net" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                //Add the application to the list
                DataBindApp dataBindApp = new DataBindApp()
                {
                    Category       = AppCategory.Launcher,
                    Launcher       = AppLauncher.BattleNet,
                    Name           = appName,
                    ImageBitmap    = iconBitmapImage,
                    PathExe        = launcherExePath,
                    Argument       = launchArgument,
                    StatusLauncher = vImagePreloadBattleNet,
                    LaunchKeyboard = true
                };

                await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                //Debug.WriteLine("Added BattleNet app: " + appName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed adding BattleNet app: " + ex.Message);
            }
        }
Пример #12
0
        async Task EADesktopScanAddLibrary()
        {
            try
            {
                //Open the Windows registry
                using (RegistryKey registryKeyLocalMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                {
                    using (RegistryKey registryKeyUninstall = registryKeyLocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
                    {
                        if (registryKeyUninstall != null)
                        {
                            foreach (string uninstallApp in registryKeyUninstall.GetSubKeyNames())
                            {
                                try
                                {
                                    using (RegistryKey installDetails = registryKeyUninstall.OpenSubKey(uninstallApp))
                                    {
                                        string uninstallString = installDetails.GetValue("UninstallString")?.ToString();
                                        if (uninstallString.Contains("EAInstaller"))
                                        {
                                            string appName    = installDetails.GetValue("DisplayName")?.ToString();
                                            string appIcon    = installDetails.GetValue("DisplayIcon")?.ToString().Replace("\"", string.Empty);
                                            string installDir = installDetails.GetValue("InstallLocation")?.ToString().Replace("\"", string.Empty);
                                            await EADesktopAddApplication(appName, appIcon, installDir);
                                        }
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            catch
            {
                Debug.WriteLine("Failed adding EA Desktop library.");
            }

            string EADesktopGetContentID(string installDir)
            {
                try
                {
                    //Open installer data xml file
                    string xmlDataPath = Path.Combine(installDir, @"__Installer\InstallerData.xml");
                    //Debug.WriteLine("EA install xml path: " + xmlDataPath);

                    //Get content ids from data
                    string      contentIds  = string.Empty;
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(xmlDataPath);

                    XmlNodeList nodeIdsList = xmlDocument.GetElementsByTagName("contentIDs");
                    foreach (XmlNode nodeIds in nodeIdsList)
                    {
                        XmlNodeList nodeIdList = nodeIds.SelectNodes("contentID");
                        foreach (XmlNode nodeId in nodeIdList)
                        {
                            contentIds += nodeId.InnerText + ",";
                            contentIds += nodeId.InnerText + "_pc,";
                        }
                    }

                    return(AVFunctions.StringRemoveEnd(contentIds, ","));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Failed to get EA contentID: " + ex.Message);
                    return(string.Empty);
                }
            }

            async Task EADesktopAddApplication(string appName, string appIcon, string installDir)
            {
                try
                {
                    //Get contentIds
                    string contentIds = EADesktopGetContentID(installDir);
                    if (string.IsNullOrWhiteSpace(contentIds))
                    {
                        Debug.WriteLine("No EA contentId found for: " + appName);
                        return;
                    }

                    //Set run command
                    string runCommand = "origin://LaunchGame/" + contentIds;
                    vLauncherAppAvailableCheck.Add(runCommand);

                    //Check if application is already added
                    DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault();
                    if (launcherExistCheck != null)
                    {
                        //Debug.WriteLine("EA Desktop app already in list: " + appIds);
                        return;
                    }

                    //Get application name
                    string appNameLower = appName.ToLower();

                    //Check if application name is ignored
                    if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower))
                    {
                        //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName);
                        await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower);

                        return;
                    }

                    //Get application image
                    BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appIcon, "EA Desktop" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                    //Add the application to the list
                    DataBindApp dataBindApp = new DataBindApp()
                    {
                        Category       = AppCategory.Launcher,
                        Launcher       = AppLauncher.EADesktop,
                        Name           = appName,
                        ImageBitmap    = iconBitmapImage,
                        PathExe        = runCommand,
                        StatusLauncher = vImagePreloadEADesktop
                    };

                    await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false);

                    //Debug.WriteLine("Added EA Desktop app: " + appIds + "/" + appName);
                }
                catch
                {
                    Debug.WriteLine("Failed adding EA Desktop app: " + appName);
                }
            }
        }