public async Task UpdatePublisherInfo() { var request = new RestRequest("/publisher/" + publisherID); var cTokeS = new CancellationTokenSource(); var response = await Utils.Client.ExecuteGetAsync(request, cTokeS.Token); var data = JObject.Parse(response.Content); if (data.ContainsKey("success")) { if ((bool)data["success"] == false) { if ((string)data["error_code"] == "OSG-U1") { var loadingWindow = new Windows.loading(); loadingWindow.Show(); Application.Current.MainWindow.IsEnabled = false; Console.WriteLine("Not logged in."); await Account.Logout(); Utils.RestartApp(); } new Windows.msgBox(data["error_message"].ToString()).ShowDialog(); return; } else if ((bool)data["success"] == true) { var publisherInfo = data["publisher"]; publisherName.Text = (string)publisherInfo["name"]; publisherWebLink = (string)publisherInfo["website"]; Uri publisherUri = new Uri((string)publisherInfo["website"]); publisherWebsite.Text = publisherUri.Host; publisherMail.Text = (string)publisherInfo["email"]; publisherJoin.Text = Convert.ToString(DateTime.Parse((string)publisherInfo["joined"]).Year); publisherAbout.Text = (string)publisherInfo["about"]; if (await Utils.CheckUrl((string)publisherInfo["background"]) && await Utils.UrlIsImage((string)publisherInfo["background"])) { var imageBrush = Utils.UniformImageBrush(new BitmapImage(new Uri((string)publisherInfo["background"])), (int)blurBackground.Width, (int)blurBackground.Height); blurBackground.Fill = imageBrush; } else { // pass } if (await Utils.CheckUrl((string)publisherInfo["profile_picture"]) && await Utils.UrlIsImage((string)publisherInfo["profile_picture"])) { publisherLogo.Source = new BitmapImage(new Uri((string)publisherInfo["profile_picture"])); } return; } } }
private async Task UpdateGameInfo() { var request = new RestRequest("/game/" + gameID); var cTokeS = new CancellationTokenSource(); var response = await Utils.Client.ExecuteGetAsync(request, cTokeS.Token); var data = JObject.Parse(response.Content); if (data.ContainsKey("success")) { if ((bool)data["success"] == false) { if ((string)data["error_code"] == "OSG-U1") { var loadingWindow = new Windows.loading(); loadingWindow.Show(); Application.Current.MainWindow.IsEnabled = false; Console.WriteLine("Not logged in."); await Account.Logout(); Utils.RestartApp(); } new Windows.msgBox(data["error_message"].ToString()).ShowDialog(); return; } else if ((bool)data["success"] == true) { gameName.Text = (string)data["game"]["name"]; gameNameCode = (string)data["game"]["name"]; gamePrice.Text = ((float)data["game"]["price"]).ToString("C"); gamePriceCode = ((float)data["game"]["price"]).ToString("C"); gameVersion.Text = ((string)data["game"]["version"]); gameDescription.Text = (string)data["game"]["description"]; gameTags.Text = (string)data["game"]["tags"]; gameDownloadCount.Text = Utils.FormatNumber((int)data["game"]["downloads"]); gameDownloadSize.Text = Utils.SizeSuffix((int)data["game"]["download_size"]); gameRequiredSpace.Text = Utils.SizeSuffix((int)data["game"]["install_size"]); if ((string)data["game"]["license"] == null) { gameLicense.Text = "Not know"; gameLicenseBuy.Text = "Not known"; } else { gameLicense.Text = (string)data["game"]["license"]; gameLicenseBuy.Text = (string)data["game"]["license"]; } sourceCode = (string)data["game"]["source_code"]; if (data["publisher"] != null) { donationLink = (string)data["publisher"]["donation_link"]; publisherID = (int)data["publisher"]["ID"]; publisherText.Text = (string)data["publisher"]["name"]; Console.WriteLine("Publisher Account found"); } else { Console.WriteLine("No Publisher account found for this game"); } if (donationLink == "") { publisherDonate.Visibility = Visibility.Hidden; } if (sourceCode == "") { SourceCodeButton.Visibility = Visibility.Hidden; } if (publisherID == -1) { publisherButton.Visibility = Visibility.Hidden; } if ((bool)data["game_owned"]) { gameStatusBarShop.Visibility = Visibility.Hidden; gameStatusBarOwned.Visibility = Visibility.Visible; var GameInstalledCheck = Account.CheckGameInstalled(gameID); if (GameInstalledCheck is string) { Console.WriteLine("Game Installed into " + (string)GameInstalledCheck); if (Account.CheckGameInstalling(gameID) == true) { btnPlay.Visibility = Visibility.Hidden; btnInstall.Visibility = Visibility.Visible; Console.WriteLine("Game installing"); btnInstall.Content = "Installing..."; btnInstall.IsEnabled = false; } else { btnPlay.Visibility = Visibility.Visible; btnInstall.Visibility = Visibility.Hidden; } } else { btnPlay.Visibility = Visibility.Hidden; btnInstall.Visibility = Visibility.Visible; btnInstall.Content = "Install"; btnInstall.IsEnabled = true; } if (Account.CheckGameRunning(runningGameProcess)) { btnPlay.Content = "Stop"; btnPlay.IsEnabled = true; } if ((int)data["game_user_stats"]["times_played"] > 0) { gamePlaytime.Text = Utils.FormatRushTime(TimeSpan.FromMinutes((int)data["game_user_stats"]["mins_played"])); gameLastPlayed.Text = ((DateTime)data["game_user_stats"]["last_played"]).ToString("d", CultureInfo.CreateSpecificCulture("de-DE")); } else { gamePlaytime.Text = "You have never played the game"; gameLastPlayed.Text = "You have never played the game"; } } else { gameStatusBarShop.Visibility = Visibility.Visible; gameStatusBarOwned.Visibility = Visibility.Hidden; } if (Account.CheckGameInstalling(gameID)) { btnInstall.Content = "Installing..."; } if (data["game"]["banner"] != null && !bannerLoaded) { if (await Utils.CheckUrl((string)data["game"]["banner"])) { if (await Utils.UrlIsImage((string)data["game"]["banner"])) { var imageBrush = Utils.UniformImageBrush(new BitmapImage(new Uri((string)data["game"]["banner"])), (int)gameBannerRectangel.Width, (int)gameBannerRectangel.Height); gameBannerRectangel.Fill = imageBrush; gameBlurBackground.Fill = imageBrush; bannerLoaded = true; } } } return; } } }