private void txtsteamidforce_Validated(object sender, EventArgs e) { try { int n = -1; int.TryParse(txtsteamidforce.Text, out n); if (n > 0) { if (OldSteamIdForce != n) { // search if this steam id exist and force it RelatedSteamGame = SteamApps.GetSteamAppById(n); } OldSteamIdForce = n; } } catch (Exception) { // ignore errors } }
private void sgll_OnSteamGameLinkLabelMouseUp(object sender, OnSteamAppLinkLabelMouseUpEventArgs e) { // define the related steam game RelatedSteamGame = e.SteamApp; setChoicePanVisibleStatus(false); }
/// <summary> /// Search a steam app with a string, return the result count /// </summary> /// <param name="only1result">Set to true to avoid displaying the choice and stop function if a strict result was found</param> private int steamRelatedAppSearchAndBind(string t, bool only1result = false) { int resultcount = 0; if (App.CurrentConfig.SteamIntegrationActivated) { // search first for an exact mach then a contain t = t.ToLower().Trim(); if (t.Length > 0) { bool uwc = UseWaitCursor; UseWaitCursor = true; setChoicePanVisibleStatus(false); // treat the end * as a joker var maybe = SteamApps.Apps.Where(el => el.Value.Name.ToLower().Trim() == t); if (maybe.Count() == 0) maybe = SteamApps.Apps.Where(el => el.Value.Name.ToLower().Trim().Contains(t)); if (maybe.Count() == 1) RelatedSteamGame = maybe.ToList()[0].Value; else if (maybe.Count() > 0) { if (!only1result) { List<KeyValuePair<int, SteamApp>> lst2scan = maybe.Take(10).OrderBy(sg => sg.Value.Name).ToList(); int choicecount = 0; for (int k = 0; k < 10; k++) { if (k + 1 <= maybe.Count()) { sglllist[k].SteamApp = lst2scan[k].Value; choicecount++; } else sglllist[k].SteamApp = new SteamApp(); } // display the choice panel if needed if (choicecount > 0) { choicepan.Height = Math.Min(choicecount, 5) * (sgll0.Height + 15); setChoicePanVisibleStatus(true); } } } else for (int k = 0; k < 8; k++) sglllist[k].SteamApp = new SteamApp(); resultcount = maybe.Count(); UseWaitCursor = uwc; } } return resultcount; }
private void GameUpd_Shown(object sender, EventArgs e) { lblinfo.Text = ""; // if it's a new record, maybe we have to check clipboard if (EditedGame.Id == 0) { if (App.CurrentConfig.ClipboardAnalyze) { string t = Clipboard.GetText(); if (t.Length > 0) { Game newgame = Functions.ExtractKeysFromLine(t); // warning: that force the TextBox.text_changed ! EditedGame.Text = newgame.Text; txtgame.Text = newgame.Text; // maybe we can autobind this game with a steam app id int steamappfound = steamRelatedAppSearchAndBind(newgame.Text, true); // steam app found, key not empty, in theory the user can directly click on OK if (steamappfound == 1) if (newgame.Keys.Count > 0) kOK.Focus(); // add the key or focus on keytextbox bool addkey = true; if (newgame.Keys.Count > 0) foreach (GameKey gk in newgame.Keys) { if (keyExist(gk.Key)) { addkey = (MessageBox.Show(Functions.Translation("Warning, this key/link already exist for this game") + ": " + gk.Key + " !" + Environment.NewLine + Environment.NewLine + Functions.Translation("Do you want to add it anyway") + " ?", App.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes); } if (addkey) EditedKeys.Add(new GameKey() { Added = DateTime.Now, Key = gk.Key }); } else txtkey.Focus(); // last, case, if the game name seem wrong with autobind or empty, focus and select all game name if (newgame.Text.Length == 0 || steamappfound > 1 || (steamappfound == 0 && App.CurrentConfig.SteamIntegrationActivated)) { txtgame.Focus(); txtgame.SelectAll(); } if (EditedGame.Text.Length > 0) gameExist(); // empty the clipboard if needed if (App.CurrentConfig.ClipboardClearAfterImport && addkey) Clipboard.Clear(); } } } else { // if the game is already binded with steam focus on cancel to avoid any false manipulation // for next version this code can be revised when all collections are full binded to avoid more web request if (EditedGame.SteamId == 0) txtgame.Focus(); } // key dgv binding and format keysBindingSource.DataSource = EditedKeys; dgkeys.DataSource = keysBindingSource; dgkeys.ReadOnly = false; dgkeys.AllowUserToAddRows = false; foreach (DataGridViewColumn c in dgkeys.Columns) if (c.Name != "Image") c.Name = c.DataPropertyName; dgkeys.Columns["Added"].ReadOnly = true; dgkeys.Columns["Number"].HeaderText = Functions.Translation("Nr"); dgkeys.Columns["Number"].ReadOnly = true; dgkeys.Columns["GivenDate"].ReadOnly = true; dgkeys.Columns["Added"].HeaderText = Functions.Translation("Added"); dgkeys.Columns["Key"].HeaderText = Functions.Translation("Key"); dgkeys.Columns["Recipient"].HeaderText = Functions.Translation("Receiver"); dgkeys.Columns["GivenDate"].HeaderText = ""; dgkeys.Columns["Image"].HeaderText = ""; dgkeys.Columns["Comment"].HeaderText = Functions.Translation("Comment"); dgkeys.Columns["Given"].HeaderText = Functions.Translation("Given"); ((DataGridViewImageColumn)dgkeys.Columns["Image"]).DefaultCellStyle.NullValue = null; ts.Refresh(); // binded steam game if (EditedGame.SteamId > 0) RelatedSteamGame = SteamApps.GetSteamAppById(EditedGame.SteamId); // form caption if (EditedGame.Id != 0 && EditedGame.Text.Length > 0) Text += " - " + EditedGame.Text; // save steam id OldSteamIdForce = EditedGame.SteamId; }