private void txtGameName_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { if (txtGameName.AutoCompleteCustomSource.Contains(txtGameName.Text)) { int index = txtGameName.Text.LastIndexOf("*"); string gameid = txtGameName.Text.Substring((index + 1), (txtGameName.Text.Length - index - 1)); txtGameName.Text = txtGameName.Text.Substring(0, index); igdb ig = new igdb(); dynamic response = ig.getIgdbResponse("https://api.igdb.com/v4/games/", constants.clientId, constants.accessToken, "fields *; where id = " + gameid + ";"); string coverid = response[0]["cover"]; dynamic response2 = ig.getIgdbResponse("https://api.igdb.com/v4/covers", constants.clientId, constants.accessToken, "fields *; where id =" + coverid + ";"); string imageurl = response2[0]["url"]; imageurl = "https:" + imageurl; imageurl = imageurl.Replace("t_thumb", "t_cover_big"); txtGameCoverUrl.Text = imageurl; } } }
private void btnSearchGame_Click(object sender, EventArgs e) { if (constants.clientId == string.Empty || constants.accessToken == string.Empty) { } else { autoComplete.Clear(); igdb ig = new igdb(); dynamic response = ig.getIgdbResponse("https://api.igdb.com/v4/games/", constants.clientId, constants.accessToken, "fields *; search \"" + txtGameName.Text + "\";"); foreach (dynamic res in response) { string game = res["name"] + "*" + res["id"]; autoComplete.Add(game); } MessageBox.Show("Results has been added to the textbox, press spacebar or clear and type again"); } }