public void AddPilot(CachedPilot cp) { lock (_cachedPilotsById) { _cachedPilotsById.Add(cp.CharID, cp); } }
private void buttonAdd_Click(object sender, EventArgs e) { var cachedPilot = new Core.CachedPilot(); if (radioButtonPilot.Checked) { cachedPilot.Name = textBoxName.Text; int charID; if (!int.TryParse(textBoxID.Text, out charID)) { MessageBox.Show("The character ID must be a valid integer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxID.SelectAll(); } else { if (!Core.StealthBot.PilotCache.CachedPilotsById.ContainsKey(charID)) { cachedPilot.CharID = charID; Core.StealthBot.PilotCache.AddPilot(cachedPilot); } else { MessageBox.Show("Pilot has already been added.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxID.SelectAll(); } } } else { int corpID; if (!int.TryParse(textBoxID.Text, out corpID)) { MessageBox.Show("The corporation ID must be a valid integer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxID.SelectAll(); } else { if (!Core.StealthBot.CorporationCache.CachedCorporationsById.ContainsKey(corpID)) { Core.StealthBot.CorporationCache.GetCorporationInfo(corpID); var sanityCheck = 200; while (!Core.StealthBot.CorporationCache.CachedCorporationsById.ContainsKey(corpID) && sanityCheck-- > 0) { Thread.Sleep(50); } if (sanityCheck <= 0) { MessageBox.Show("Could not look up corporation info. Are you sure the corporation ID is correct?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } Close(); }
public ManuallyAddPilotEventArgs(Core.CachedPilot cachedObject, bool isPilot) { CachedObject = cachedObject; IsPilot = isPilot; }
public void AddPilot(Pilot pilot, string corporationName, string allianceName) { var cachedPilot = new CachedPilot(pilot, corporationName, allianceName); AddPilot(cachedPilot); }