private void AddOrUpdate(LauncherInfo li)
        {
            foreach (var item in Launchers)
            {
                if (item.Id == li.Id)
                {
                    item.Update(li);
                    return;
                }
            }

            li.PropertyChanged += launcher_PropertyChanged;
            Launchers.Add(li);
        }
 public LauncherInfo(LauncherInfo other)
 {
     CopyFrom(other);
 }
        public void Update(LauncherInfo other)
        {
            if (Id != other.Id)
                throw new Exception("Ids don't match");
            if (IsOfficialGame != other.IsOfficialGame)
                throw new Exception("IsOfficialGame don't match");

            DisplayName = other.DisplayName;
            PlayerCount = other.PlayerCount;

            if (!IsOfficialGame)
            {
                FilePath = other.FilePath;
                Arguments = other.Arguments;
            }
        }
        public LauncherInfo CopyFrom(LauncherInfo other)
        {
            Id = other.Id;
            DisplayName = other.DisplayName;
            PlayerCount = other.PlayerCount;

            IsOfficialGame = other.IsOfficialGame;
            FilePath = other.FilePath;
            Arguments = other.Arguments;

            return this;
        }
 private void dataGridLauncher_PreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Right)
     {
         LauncherInfo launcher;
         if (dataGridLauncher.TryGetRowItem(e, out launcher))
         {
             _rightClickLauncher = launcher;
         }
     }
 }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var settingsList = UserDataManager.UserData.Settings.LauncherList;
            if (settingsList == null)
                settingsList = new List<HomeTab.LauncherInfo>();

            foreach (var launcher in settingsList)
                AddOrUpdate(new LauncherInfo(launcher));

            Launchers.CollectionChanged += _launchers_CollectionChanged;

            RestResponse<GameList> response = null;
            _userData.PgSession.BeginAndCallback(delegate
            {
                var url = _userData.PgSession.GetWebAppFunction("/api", "/games");
                var client = new RestClient(url);
                var request = new RestRequest(Method.GET);
                response = (RestResponse<GameList>)client.Execute<GameList>(request);
            }, delegate
            {
                if (response.IsOk())
                {
                    var games = response.Data.games;
                    foreach (var game in games)
                    {
                        var li = new LauncherInfo(game);
                        AddOrUpdate(li);
                    }
                }
            });
        }
 private void JoinLobby(LauncherInfo launcher)
 {
     if (!launcher.IsOfficialGame)
         return;
     _userData.JoinChat(SessionManager.PrefixGameLobby + launcher.Id);
 }
 public bool TryGetGame(string gameId, out LauncherInfo info)
 {
     foreach (var item in Launchers)
     {
         if (item.Id == gameId)
         {
             info = item;
             return true;
         }
     }
     info = null;
     return false;
 }