/// <summary> /// Downloads the given loadout /// </summary> /// <param name="loadout"></param> private void DownloadLoadout(SerializableLoadout loadout) { // See the cursor to wait Cursor.Current = Cursors.WaitCursor; // Retrieve the selected loadout m_selectedLoadout = loadout; // Set the headings lblLoadoutName.Text = m_selectedLoadout.LoadoutName; lblAuthor.Text = m_selectedLoadout.Author; lblSubmitDate.Text = m_selectedLoadout.SubmissionDate.ToString(); // Download the loadout details string url = String.Format(CultureConstants.DefaultCulture, NetworkConstants.BattleclinicLoadoutDetails, m_selectedLoadout.LoadoutId.ToString()); Util.DownloadXMLAsync<SerializableLoadoutFeed>(url, null, OnLoadoutDownloaded); }
/// <summary> /// Occurs when we downloaded a loadouts feed from BattleClinic /// </summary> /// <param name="feed"></param> /// <param name="errorMessage"></param> /// <returns></returns> private void OnLoadoutFeedDownloaded(SerializableLoadoutFeed feed, string errorMessage) { if (this.IsDisposed) return; // Restore the default cursor instead of the waiting one Cursor.Current = Cursors.Default; m_selectedLoadout = null; btnPlan.Enabled = false; // Was there an error ? if (!String.IsNullOrEmpty(errorMessage)) { lblLoadouts.Text = String.Format(CultureConstants.DefaultCulture, "There was a problem connecting to BattleClinic, it may be down for maintainance.\r\n{0}", errorMessage); return; } // Are there no feeds ? if (feed.Race == null || feed.Race.Loadouts.Length == 0) { lblLoadouts.Text = String.Format(CultureConstants.DefaultCulture, "There are no loadouts for {0}, why not submit one to BattleClinic?", m_ship.Name); return; } // Add the listview items for every loadout lvLoadouts.Items.Clear(); foreach (SerializableLoadout loadout in feed.Race.Loadouts) { ListViewItem lvi = new ListViewItem(loadout.LoadoutName); lvi.Text = loadout.LoadoutName; lvi.SubItems.Add(loadout.Author); lvi.SubItems.Add(loadout.rating.ToString()); lvi.SubItems.Add(loadout.SubmissionDate.ToString()); lvi.Tag = loadout; lvLoadouts.Items.Add(lvi); } // Update the header lblLoadouts.Text = String.Format(CultureConstants.DefaultCulture, "Found {0} loadouts", lvLoadouts.Items.Count); // Update the listview's comparer and sort lvLoadouts.Sort(); }
/// <summary> /// When the user clicks cancel, we quit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCancel_Click(object sender, EventArgs e) { m_selectedLoadout = null; this.DialogResult = DialogResult.Cancel; this.Close(); }