示例#1
0
        /// <summary>
        /// Adds the cheat to the selected library.
        /// </summary>
        /// <param name="cheat">The cheat to add.</param>
        private void AddCheatToLibrary(Cheat cheat)
        {
            if (!this.CheatsAvailable.Contains(cheat))
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Unable to add cheat to library");
                return;
            }

            AccessTokens accessTokens = SettingsViewModel.GetInstance().AccessTokens;

            try
            {
                SqualrApi.AddCheatToLibrary(accessTokens.AccessToken, this.ActiveLibrary.LibraryId, cheat.CheatId);

                cheat.LoadDefaultStreamSettings();

                this.cheatsAvailable.Remove(cheat);
                this.cheatsInLibrary.Insert(0, cheat);
                this.RaisePropertyChanged(nameof(this.CheatsAvailable));
                this.RaisePropertyChanged(nameof(this.CheatsInLibrary));
            }
            catch (Exception ex)
            {
                OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Error, "Error adding cheat to library", ex);
            }
        }