public void Import(JsonGestureIntentStore from, bool replace = false)
        {
            if (from == null)
            {
                return;
            }

            if (replace)
            {
                GlobalApp.GestureIntents.Clear();
                GlobalApp.IsGesturingEnabled = from.GlobalApp.IsGesturingEnabled;
                Apps.Clear();
            }

            GlobalApp.ImportGestures(from.GlobalApp);

            foreach (var kv in from.Apps)
            {
                ExeApp appInSelf;
                //如果应用程序已经在列表中,则合并手势
                if (TryGetExeApp(kv.Key.ToLower(), out appInSelf))
                {
                    appInSelf.ImportGestures(kv.Value);
                    appInSelf.IsGesturingEnabled = appInSelf.IsGesturingEnabled && kv.Value.IsGesturingEnabled;
                }
                else//否则将app添加到列表中
                {
                    Add(kv.Value);
                }
            }
        }
Exemple #2
0
        public void SetLists()
        {
            if (firstRun)
            {
                firstRun  = false;
                StationID = "Workstation";
            }

            Apps.Clear();
            List_VerLbls.Clear();
            List_UninBtns.Clear();
            List_CurBtns.Clear();

            if (StationID == "Workstation")
            {
                // Update lists
                Apps.AddRange(new App[] { IPA, DVR, XBCA, Util, LCU });
                List_VerLbls.AddRange(new Label[] { lbl_IPAVer, lbl_DVRVer, lbl_XBCAVer, lbl_UtilVer, lbl_LCUVer });
                List_UninBtns.AddRange(new Button[] { btn_IPAUninstall, btn_DVRUninstall, btn_XBCAUninstall, btn_UtilUninstall, btn_LCUUninstall });
                List_CurBtns.AddRange(new Button[] { btn_IPACurrent, btn_DVRCurrent, btn_XBCACurrent, btn_UtilCurrent, btn_LCUCurrent });
            }
            else
            {
                // Update lists
                Apps.AddRange(new App[] { IPAS, Util, GECA, LCU, MP });
                List_VerLbls.AddRange(new Label[] { lbl_IPASVer, lbl_UtilVer, lbl_GECAVer, lbl_LCUVer, lbl_MPVer });
                List_UninBtns.AddRange(new Button[] { btn_IPASUninstall, btn_UtilUninstall, btn_GECAUninstall, btn_LCUUninstall, btn_MPUninstall });
                List_CurBtns.AddRange(new Button[] { btn_IPASCurrent, btn_UtilCurrent, btn_GECACurrent, btn_LCUCurrent, btn_MPCurrent });
            }

            UpdateVersions(false);
        }
Exemple #3
0
        public override async void UpdateAppList()
        {
            try
            {
                if (IsUpdatingAppList)
                {
                    return;
                }

                IsUpdatingAppList = true;

                Apps.Clear();

                if (!Directory.Exists(FullPath))
                {
                    IsUpdatingAppList = false;
                    return;
                }

                await Directory.EnumerateFiles(FullPath, "installerdata.xml", SearchOption.AllDirectories)
                .ParallelForEachAsync(
                    async filePath =>
                {
                    await Functions.Origin.ParseAppDetailsAsync(new StreamReader(filePath).BaseStream, filePath, this);
                });

                await Directory.EnumerateFiles(FullPath, "*.zip", SearchOption.TopDirectoryOnly).ParallelForEachAsync(async originCompressedArchive =>
                {
                    using (var archive = ZipFile.OpenRead(originCompressedArchive))
                    {
                        if (archive.Entries.Count > 0)
                        {
                            foreach (var archiveEntry in archive.Entries.Where(x => x.Name.Contains("installerdata.xml")))
                            {
                                await Functions.Origin.ParseAppDetailsAsync(archiveEntry.Open(), originCompressedArchive, this, true);
                            }
                        }
                    }
                });

                if (SLM.CurrentSelectedLibrary != null && SLM.CurrentSelectedLibrary == this)
                {
                    Functions.App.UpdateAppPanel(this);
                }

                IsUpdatingAppList = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.OriginUpdateAppListException)), new { FullPath, ex }));
                Logger.Fatal(ex);
            }
        }
 private async void App_AppAdded(object sender, EventArgs e)
 {
     await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         Apps.Clear();
         var list = await database.GetAll();
         foreach (var item in list)
         {
             Apps.Add(item);
         }
     });
 }
Exemple #5
0
        public void Reload()
        {
            AppInfo.FetchApps(Context, Settings.Instance.Blacklist, true, Settings.RENAME_MAPPINGS, r => {
                Apps.Clear();
                Apps.AddRange(r);

                Settings.Instance.SanitizeAppOrder(Apps);

                Sort();

                Context.RunOnUiThread(NotifyDataSetChanged);
            });
        }
Exemple #6
0
        private async Task LoadAppsAsync()
        {
            var appBankContents = await Pebble.GetAppbankContentsAsync();

            Apps.Clear();
            if (appBankContents != null && appBankContents.AppBank != null && appBankContents.AppBank.Apps != null)
            {
                foreach (var app in appBankContents.AppBank.Apps)
                {
                    Apps.Add(app);
                }
            }
        }
Exemple #7
0
        private void UpdateAppListData(RzAppListDataProvider app)
        {
            Apps.Clear();
            Pids.Clear();
            CurrentApp = app.CurrentAppExecutable;
            for (int i = 0; i < app.AppCount; i++)
            {
                Apps.Add(app.GetExecutableName(i));
                Pids.Add(app.GetPid(i));
            }

            AppListUpdated?.Invoke(this, EventArgs.Empty);
        }
        public void Reload()
        {
            AppInfo.FetchApps(Context, false, r => {
                Apps.Clear();
                Apps.AddRange(r);

                Settings.Instance.SanitizeAppOrder(Apps);

                Sort();

                Context.RunOnUiThread(NotifyDataSetChanged);
            });
        }
        async void RefreshAppList()
        {
            try
            {
                Refreshing = true;

                await Task.Run(() =>
                {
                    var apps = AppInfoFactory.GetVisibleAppsInfo();

                    var expandedApps = apps.Select(a => new ExpandedAppInfo(a)).ToList();

                    var urls = new List <ExpandedAppInfo>();

                    foreach (var app in expandedApps)
                    {
                        if (!string.IsNullOrWhiteSpace(app.AppInfo.Domain))
                        {
                            urls.Add(new ExpandedAppInfo(app.AppInfo.Copy()));
                            app.AppInfo.Domain = string.Empty;
                        }
                    }

                    var uniqueApps = expandedApps.GroupBy(x => x.AppInfo.Description).Select(a => a.First()).ToList();

                    uniqueApps.AddRange(urls);

                    App.Current.Dispatcher.Invoke(() =>
                    {
                        Apps.Clear();
                        foreach (var app in uniqueApps)
                        {
                            Apps.Add(app);
                        }
                    });
                });
            }
            finally
            {
                Refreshing = false;
            }
        }
        public override async void UpdateAppList()
        {
            try
            {
                if (IsUpdatingAppList)
                {
                    return;
                }

                IsUpdatingAppList = true;

                DirectoryList["SteamApps"].Refresh();

                if (!DirectoryList["SteamApps"].Exists)
                {
                    DirectoryList["SteamApps"].Create();
                    DirectoryList["SteamApps"].Refresh();

                    if (!DirectoryList["SteamApps"].Exists)
                    {
                        MessageBox.Show(Framework.StringFormat.Format(
                                            Functions.SLM.Translate(nameof(Properties.Resources.SteamAppsFolderNotExists)),
                                            new { SteamAppsFolderFullPath = DirectoryList["SteamApps"].FullName }));
                        return;
                    }
                }

                if (Apps.Count > 0)
                {
                    Apps.Clear();
                }

                // Foreach *.acf file found in library
                await DirectoryList["SteamApps"].EnumerateFiles("appmanifest_*.acf", SearchOption.TopDirectoryOnly)
                .ParallelForEachAsync(
                    async acfFile =>
                {
                    // Define a new value and call KeyValue
                    var keyValReader = new Framework.KeyValue();

                    // Read the *.acf file as text
                    keyValReader.ReadFileAsText(acfFile.FullName);

                    // If key doesn't contains a child (value in acf file)
                    if (keyValReader.Children.Count == 0)
                    {
                        if (List.IgnoredJunkItems.Contains(acfFile.FullName))
                        {
                            return;
                        }

                        List.LcProgress.Report(new List.JunkInfo
                        {
                            FSInfo  = new FileInfo(acfFile.FullName),
                            Size    = Functions.FileSystem.FormatBytes(acfFile.Length),
                            Library = this,
                            Tag     = JunkType.CorruptedDataFile
                        });

                        return;
                    }

                    await Functions.App.AddSteamAppAsync(Convert.ToInt32(keyValReader["appid"].Value),
                                                         keyValReader["name"].Value ?? keyValReader["UserConfig"]["name"].Value,
                                                         keyValReader["installdir"].Value, Convert.ToInt32(keyValReader["StateFlags"].Value),
                                                         this, Convert.ToInt64(keyValReader["SizeOnDisk"].Value),
                                                         Convert.ToInt64(keyValReader["LastUpdated"].Value), false).ConfigureAwait(false);
                }).ConfigureAwait(false);

                // Do a loop for each *.zip file in library
                await Directory.EnumerateFiles(DirectoryList["SteamApps"].FullName, "*.zip", SearchOption.TopDirectoryOnly)
                .ParallelForEachAsync(async archive => { await Task.Run(() => Functions.App.ReadDetailsFromZip(archive, this)).ConfigureAwait(false); }).ConfigureAwait(false);

                DirectoryList["SteamBackups"].Refresh();
                if (Type == LibraryType.SLM && DirectoryList["SteamBackups"].Exists)
                {
                    await DirectoryList["SteamBackups"].EnumerateFiles("*.sis", SearchOption.AllDirectories).ParallelForEachAsync(
                        async skuFile =>
                    {
                        var keyValReader = new Framework.KeyValue();

                        keyValReader.ReadFileAsText(skuFile.FullName);

                        var appNames = System.Text.RegularExpressions.Regex.Split(keyValReader["name"].Value, " and ");

                        var i       = 0;
                        var appSize = Functions.FileSystem.GetDirectorySize(skuFile.Directory, true);
                        foreach (var app in keyValReader["apps"].Children)
                        {
                            if (Apps.Count(x => x.AppId == Convert.ToInt32(app.Value) && x.IsSteamBackup) > 0)
                            {
                                continue;
                            }

                            await Functions.App.AddSteamAppAsync(Convert.ToInt32(app.Value), appNames[i],
                                                                 skuFile.DirectoryName, 4, this, appSize, skuFile.LastWriteTimeUtc.ToUnixTimestamp(),
                                                                 false, true).ConfigureAwait(false);

                            if (appNames.Length > 1)
                            {
                                i++;
                            }
                        }
                    }).ConfigureAwait(false);
                }

                if (SLM.CurrentSelectedLibrary != null && SLM.CurrentSelectedLibrary == this)
                {
                    Functions.App.UpdateAppPanel(this);
                }

                IsUpdatingAppList = false;
            }
            catch (UnauthorizedAccessException ex)
            {
                await Main.FormAccessor.AppView.AppPanel.Dispatcher.Invoke(
                    async delegate
                {
                    await Main.FormAccessor.ShowMessageAsync(
                        Functions.SLM.Translate(nameof(Properties.Resources.UnauthorizedAccessException)),
                        Framework.StringFormat.Format(
                            Functions.SLM.Translate(nameof(Properties.Resources.UnauthorizedAccessExceptionMessage)),
                            new { FullPath, ExceptionMessage = ex.Message })).ConfigureAwait(true);
                }, System.Windows.Threading.DispatcherPriority.Normal).ConfigureAwait(true);

                IsUpdatingAppList = false;
            }
            catch (DirectoryNotFoundException ex)
            {
                await Main.FormAccessor.AppView.AppPanel.Dispatcher.Invoke(
                    async delegate
                {
                    await Main.FormAccessor.ShowMessageAsync(
                        Functions.SLM.Translate(nameof(Properties.Resources.DirectoryNotFoundException)),
                        Framework.StringFormat.Format(
                            Functions.SLM.Translate(nameof(Properties.Resources.DirectoryNotFoundExceptionMessage)),
                            new { FolderfullPath = FullPath, ExceptionMessage = ex.Message }))
                    .ConfigureAwait(true);
                }, System.Windows.Threading.DispatcherPriority.Normal).ConfigureAwait(true);

                IsUpdatingAppList = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Logger.Fatal(ex);
                IsUpdatingAppList = false;
            }
        }
        public override void UpdateAppList()
        {
            try
            {
                if (IsUpdatingAppList)
                {
                    return;
                }

                IsUpdatingAppList = true;

                Apps.Clear();

                if (!Directory.Exists(FullPath))
                {
                    IsUpdatingAppList = false;
                    return;
                }

                foreach (var directoryPath in Directory.EnumerateDirectories(FullPath, "*",
                                                                             SearchOption.TopDirectoryOnly))
                {
                    var dirInfo = new DirectoryInfo(directoryPath);

                    if (!File.Exists(Path.Combine(dirInfo.FullName, "uplay_install.state")))
                    {
                        if (List.IgnoredJunkItems.Contains(dirInfo.FullName))
                        {
                            continue;
                        }

                        List.LcProgress.Report(new List.JunkInfo
                        {
                            FSInfo  = dirInfo,
                            Size    = Functions.FileSystem.FormatBytes(Functions.FileSystem.GetDirectorySize(dirInfo, true)),
                            Library = this,
                            Tag     = Enums.JunkType.HeadlessFolder
                        });
                        continue;
                    }

                    Functions.Uplay.ParseAppDetails(dirInfo.Name, dirInfo, this);
                }

                foreach (var archivePath in Directory.EnumerateFiles(FullPath, "*.zip", SearchOption.TopDirectoryOnly))
                {
                    var fileInfo = new FileInfo(archivePath);
                    Functions.Uplay.ParseAppDetails(fileInfo.Name.Replace(".zip", ""), fileInfo.Directory, this, true);
                }

                if (SLM.CurrentSelectedLibrary != null && SLM.CurrentSelectedLibrary == this)
                {
                    Functions.App.UpdateAppPanel(this);
                }

                IsUpdatingAppList = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.Uplay_UpdateAppListError)), new { FullPath, ex }));
                Logger.Fatal(ex);
            }
        }
        public override async void UpdateAppListAsync()
        {
            try
            {
                Apps.Clear();

                if (!Directory.Exists(FullPath))
                {
                    return;
                }

                var appIds = new List <KeyValuePair <string, string> >();

                if (Directory.Exists(Directories.Origin.LocalContentDirectoy))
                {
                    //foreach (var originApp in Directory.EnumerateFiles(Directories.Origin.LocalContentDirectoy, "*.mfst", SearchOption.AllDirectories))
                    await Directory.EnumerateFiles(Directories.Origin.LocalContentDirectoy, "*.mfst",
                                                   SearchOption.AllDirectories).ParallelForEachAsync(
                        async originApp =>
                    {
                        var appId = Path.GetFileNameWithoutExtension(originApp);

                        if (!appId.StartsWith("Origin"))
                        {
                            // Get game id by fixing file via adding : before integer part of the name
                            // for example OFB-EAST52017 converts to OFB-EAST:52017
                            var match = System.Text.RegularExpressions.Regex.Match(appId, @"^(.*?)(\d+)$");
                            if (!match.Success)
                            {
                                return;
                            }

                            appId = match.Groups[1].Value + ":" + match.Groups[2].Value;
                        }

                        appIds.Add(new KeyValuePair <string, string>(new FileInfo(originApp).Directory.Name, appId));
                    });
                }

                await Directory.EnumerateFiles(FullPath, "installerdata.xml", SearchOption.AllDirectories)
                .ParallelForEachAsync(
                    async originApp =>
                {
                    if (new FileInfo(originApp).Directory.Parent.Parent.Name !=
                        new DirectoryInfo(FullPath).Name)
                    {
                        return;
                    }

                    var installerLog    = Path.Combine(Directory.GetParent(originApp).FullName, "InstallLog.txt");
                    var installedLocale = "en_US";

                    if (File.Exists(installerLog))
                    {
                        foreach (var line in File.ReadAllLines(installerLog))
                        {
                            if (!line.Contains("Install Locale:"))
                            {
                                continue;
                            }

                            installedLocale = line.Split(new string[] { "Install Locale:" },
                                                         StringSplitOptions.None)[1];
                            break;
                        }

                        installedLocale = installedLocale.Replace(" ", "");
                    }

                    var xml             = XDocument.Load(originApp);
                    var manifestVersion = new Version((xml.Root.Name.LocalName == "game")
                                ? xml.Root.Attribute("manifestVersion").Value
                                : ((xml.Root.Name.LocalName == "DiPManifest")
                                    ? xml.Root.Attribute("version").Value
                                    : "1.0"));

                    OriginAppInfo originAppInfo = null;

                    if (manifestVersion == new Version("4.0"))
                    {
                        originAppInfo = new OriginAppInfo(Library,
                                                          xml.Root.Element("gameTitles")?.Elements("gameTitle")
                                                          ?.First(x => x.Attribute("locale").Value == "en_US")?.Value,
                                                          Convert.ToInt32(xml.Root.Element("contentIDs")?.Elements()
                                                                          .FirstOrDefault(x => int.TryParse(x.Value, out int appId))?.Value),
                                                          new FileInfo(originApp).Directory.Parent,
                                                          new Version(xml.Root.Element("buildMetaData")?.Element("gameVersion")
                                                                      ?.Attribute("version")?.Value),
                                                          xml.Root.Element("installMetaData")?.Element("locales")?.Value.Split(','),
                                                          installedLocale,
                                                          xml.Root.Element("touchup")?.Element("filePath")?.Value,
                                                          xml.Root.Element("touchup")?.Element("parameters")?.Value,
                                                          xml.Root.Element("touchup")?.Element("updateParameters")?.Value,
                                                          xml.Root.Element("touchup")?.Element("repairParameters")?.Value);
                    }
                    else if (manifestVersion >= new Version("1.1") && manifestVersion <= new Version("3.0"))
                    {
                        var locales = new List <string>();
                        foreach (var locale in xml.Root.Element("metadata")?.Elements("localeInfo")
                                 ?.Attributes()?.Where(x => x.Name == "locale"))
                        {
                            locales.Add(locale.Value);
                        }

                        originAppInfo = new OriginAppInfo(Library,
                                                          xml.Root.Element("metadata")?.Elements("localeInfo")
                                                          ?.First(x => x.Attribute("locale").Value == "en_US")?.Element("title").Value,
                                                          Convert.ToInt32(xml.Root.Element("contentIDs")?.Element("contentID")?.Value
                                                                          .Replace("EAX", "")),
                                                          new FileInfo(originApp).Directory.Parent,
                                                          new Version(xml.Root.Attribute("gameVersion").Value),
                                                          locales.ToArray(),
                                                          installedLocale,
                                                          xml.Root.Element("executable")?.Element("filePath")?.Value,
                                                          xml.Root.Element("executable")?.Element("parameters")?.Value);
                    }
                    else
                    {
                        MessageBox.Show(Framework.StringFormat.Format(
                                            Functions.SLM.Translate(nameof(Properties.Resources.OriginUnknownManifestFile)),
                                            new { ManifestVersion = manifestVersion, OriginApp = originApp }));
                        return;
                    }

                    if (appIds.Count(x => x.Key == originAppInfo.InstallationDirectory.Name) > 0)
                    {
                        var appId = appIds.First(x => x.Key == originAppInfo.InstallationDirectory.Name);

                        var appLocalData = GetGameLocalData(appId.Value);

                        if (appLocalData != null)
                        {
                            originAppInfo.GameHeaderImage = string.Concat(
                                appLocalData["customAttributes"]["imageServer"],
                                appLocalData["localizableAttributes"]["packArtLarge"]);
                        }
                    }

                    Apps.Add(originAppInfo);
                });

                if (SLM.CurrentSelectedLibrary != null && SLM.CurrentSelectedLibrary == Library)
                {
                    Functions.App.UpdateAppPanel(Library);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }