/// <summary> /// Handles the Load event of the MineralWorksheet control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void MineralWorksheet_Load(object sender, EventArgs e) { if (DesignMode || this.IsDesignModeHosted()) { return; } MineralDataRequest.Initialize(); EveMonClient.SettingsChanged += EveMonClient_SettingsChanged; Disposed += OnDiposed; UpdateVisuals(); foreach (MineralTile mineralTile in Tiles) { mineralTile.SubtotalChanged += TileSubtotal_Changed; } foreach (IMineralParser parser in MineralDataRequest.Parsers) { ToolStripMenuItem menuItem; using (ToolStripMenuItem item = new ToolStripMenuItem()) { item.Text = parser.Title; item.Tag = parser.Name; item.Click += menuItem_Click; menuItem = item; } tsddFetch.DropDownItems.Add(menuItem); } }
/// <summary> /// Handles the RunWorkerCompleted event of the bckgrndWrkrGetPrices control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.RunWorkerCompletedEventArgs"/> instance containing the event data.</param> private void bckgrndWrkrGetPrices_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { ExceptionHandler.LogException(e.Error, true); MessageBox.Show($"Failed to retrieve mineral pricing data:\n{e.Error.Message}", @"Failed to Retrieve Data", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } else { IDictionary <string, Decimal> prices = e.Result as IDictionary <string, Decimal>; if (prices == null) { return; } foreach (MineralTile mt in Tiles) { mt.PricePerUnit = prices.ContainsKey(mt.MineralName) ? prices[mt.MineralName] : 0m; } tslCourtesy.Text = $"Mineral Prices Courtesy of {MineralDataRequest.GetCourtesyText(m_source)}"; m_courtesyUrl = MineralDataRequest.GetCourtesyUrl(m_source).AbsoluteUri; tslCourtesy.Visible = true; } }
private void bckgrndWrkrGetPrices_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { ExceptionHandler.LogException(e.Error, true); MessageBox.Show(String.Format("Failed to retrieve mineral pricing data:\n{0}", e.Error.Message), "Failed to Retrieve Data", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { IDictionary <string, Decimal> prices = e.Result as IDictionary <string, Decimal>; if (prices != null) { foreach (MineralTile mt in Tiles) { if (prices.ContainsKey(mt.MineralName)) { mt.PricePerUnit = prices[mt.MineralName]; } } tslCourtesy.Text = String.Format("Mineral Prices Courtesy of {0}", MineralDataRequest.GetCourtesyText(m_source)); m_courtesyUrl = MineralDataRequest.GetCourtesyUrl(m_source); tslCourtesy.Visible = true; } } }
/// <summary> /// Handles the DoWork event of the bckgrndWrkrGetPrices control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param> private void bckgrndWrkrGetPrices_DoWork(object sender, DoWorkEventArgs e) { IDictionary <string, Decimal> prices = new Dictionary <string, decimal>(); string source = e.Argument as string; if (source != null) { foreach (MineralPrice mineralPrice in MineralDataRequest.Prices(source)) { prices[mineralPrice.Name] = mineralPrice.Price; } } e.Result = prices; }