コード例 #1
0
        private void _watcher_Created(object sender, FileSystemEventArgs e)
        {
            Action onChange = new Action(() =>
            {
                SteamApp newGame;
                try
                {
                    newGame = new SteamApp(e.FullPath);
                }
                catch (Exception)
                {
                    return;
                }
                if (string.IsNullOrWhiteSpace(newGame.GameName) || string.IsNullOrWhiteSpace(newGame.AppId) || string.IsNullOrWhiteSpace(newGame.InstallDir))
                {
                    return;
                }

                if (GetGameById(newGame.AppId) == null)
                {
                    var matches = (from game in _Games
                                   where game?.InstallDir?.ToLower() == newGame?.InstallDir?.ToLower()
                                   select game).ToList();

                    if (matches.Any())
                    {
                        matches.Add(newGame);
                        var bundle = new SteamBundle(matches);
                        _Games.Insert(0, bundle);
                        foreach (var match in matches)
                        {
                            _Games.Remove(match);
                        }
                    }
                    else
                    {
                        _Games.Insert(0, newGame);
                    }
                }
            });

            if (SteamBase.UiDispatcher != null)
            {
                SteamBase.UiDispatcher.BeginInvoke(onChange);
            }
            else
            {
                onChange();
            }
        }
コード例 #2
0
        private void _watcher_Changed(object sender, FileSystemEventArgs e)
        {
            Action onChange = new Action(() =>
            {
                var appId = e.Name.ToLower().Replace(".acf", "").Replace("appmanifest_", "");
                var game  = GetGameOrBundleById(appId);
                if (game != null)
                {
                    game.RefreshFromAcf();
                }
                else
                {
                    try
                    {
                        game = new SteamApp(e.FullPath);
                    }
                    catch (Exception)
                    {
                        return;
                    }
                    if (GetGameById(game.AppId) == null)
                    {
                        _Games.Insert(0, game);
                    }
                }
            });

            if (SteamBase.UiDispatcher != null)
            {
                SteamBase.UiDispatcher.BeginInvoke(onChange);
            }
            else
            {
                onChange();
            }
        }