private void DeleteAccountButtonClick(object sender, EventArgs e) { try { var cell = this.ItemsToTradeGridView.CurrentCell; if (cell == null) { Logger.Warning("No accounts selected"); return; } if (cell.RowIndex < 0) { return; } ItemsToSaleGridUtils.DeleteButtonClick( this.AllSteamItemsToTradeGridView, this.ItemsToTradeGridView, cell.RowIndex); } catch (Exception ex) { Logger.Critical(ex); } }
private void ItemsToSaleGridViewCellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } if (this.ItemsToSaleGridView.Rows.Count == 1) { this.ItemsToSaleGridViewCurrentCellChanged(sender, e); } if (e.ColumnIndex != 2) { return; } if (!this.ManualPriceRadioButton.Checked) { this.ItemToSalePriceColumn.ReadOnly = true; } else { this.ItemToSalePriceColumn.ReadOnly = false; ItemsToSaleGridUtils.CellClick(this.ItemsToSaleGridView, e.RowIndex); } } catch (Exception ex) { Logger.Critical(ex); } }
private static void SetItemToSaleRowCurrentPrices(DataGridViewRow row) { try { var currentPriceCell = ItemsToSaleGridUtils.GetGridCurrentPriceTextBoxCell(itemsToSaleGrid, row.Index); var averagePriceCell = ItemsToSaleGridUtils.GetGridAveragePriceTextBoxCell(itemsToSaleGrid, row.Index); var prices = GetItemsToSaleRowPrice(row).Result; var currentPrice = prices.Item1; if (currentPrice != -1) { currentPriceCell.Value = currentPrice; } var averagePrice = prices.Item2; if (averagePrice != -1) { averagePriceCell.Value = averagePrice; } } catch (Exception ex) { Logger.Warning("Error on parsing item price", ex); } }
private void SendTradeButtonClick(object sender, EventArgs e) { try { if (CurrentSession.SteamManager == null) { MessageBox.Show( @"You should login first", @"Error sending trade offer", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error on inventory loading. No signed in account found."); return; } if (string.IsNullOrEmpty(this.TradeParthenIdTextBox.Text) || string.IsNullOrEmpty(this.TradeTokenTextBox.Text)) { MessageBox.Show( @"You should chose target partner first", @"Error sending trade offer", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error sending trade offer. No target partner selected."); return; } var itemsToSale = new List <FullRgItem>(); for (var i = 0; i < this.ItemsToTradeGridView.Rows.Count; i++) { var itemsList = ItemsToSaleGridUtils.GetRowItemsList(this.ItemsToTradeGridView, i); itemsToSale.AddRange(itemsList); } var response = CurrentSession.SteamManager.SendTradeOffer( itemsToSale, this.TradeParthenIdTextBox.Text, this.TradeTokenTextBox.Text, out var offerId); if (this.Confirm2FACheckBox.Checked && response == true) { CurrentSession.SteamManager.ConfirmTradeTransactions(new List <ulong> { ulong.Parse(offerId) }); } MessageBox.Show( $@"Trade sent - {response}", @"Trade info", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { Logger.Critical(ex); } }
private async void ItemsForSaleUpdateOneButtonClickClick(object sender, EventArgs e) { try { await Task.Run( async () => { try { var selectedRows = this.ItemsToSaleGridView.SelectedRows.Cast<DataGridViewRow>(); foreach (var row in selectedRows) { var item = ItemsToSaleGridUtils.GetFullRgItems(this.ItemsToSaleGridView, row.Index) .FirstOrDefault(); if (item == null) { continue; } var averagePrice = CurrentSession.SteamManager.GetAveragePrice( item.Asset.Appid, item.Description.MarketHashName, SavedSettings.Get().SettingsAveragePriceParseDays); if (averagePrice.HasValue) { PriceLoader.AveragePricesCache.Cache( item.Description.MarketHashName, averagePrice.Value); } var currentPrice = await CurrentSession.SteamManager.GetCurrentPrice(item.Asset.Appid, item.Description.MarketHashName); PriceLoader.CurrentPricesCache.Cache( item.Description.MarketHashName, currentPrice.Value); row.Cells[ItemsToSaleGridUtils.CurrentColumnIndex].Value = currentPrice; row.Cells[ItemsToSaleGridUtils.AverageColumnIndex].Value = averagePrice; } } catch (Exception ex) { Logger.Error("Error on update item price", ex); } }); } catch (Exception ex) { Logger.Critical(ex); } }
private static void ClearAllPriceCells(ETableToLoad tableToLoad) { DataGridViewTextBoxCell cell; switch (tableToLoad) { case ETableToLoad.AllItemsTable: { foreach (var row in allItemsGrid.Rows.Cast <DataGridViewRow>()) { cell = allItemsListGridUtils.GetGridCurrentPriceTextBoxCell(row.Index).Cell; if (cell != null) { cell.Value = null; } cell = allItemsListGridUtils.GetGridAveragePriceTextBoxCell(row.Index).Cell; if (cell != null) { cell.Value = null; } } break; } case ETableToLoad.ItemsToSaleTable: foreach (var row in itemsToSaleGrid.Rows.Cast <DataGridViewRow>()) { cell = ItemsToSaleGridUtils.GetGridCurrentPriceTextBoxCell(itemsToSaleGrid, row.Index); if (cell != null) { cell.Value = null; } cell = ItemsToSaleGridUtils.GetGridAveragePriceTextBoxCell(itemsToSaleGrid, row.Index); if (cell != null) { cell.Value = null; } } break; case ETableToLoad.RelistTable: // todo break; default: throw new ArgumentOutOfRangeException(nameof(tableToLoad), tableToLoad, null); } }
private void ItemsToSaleGridViewCurrentCellChanged(object sender, EventArgs e) { try { var cell = this.ItemsToTradeGridView.CurrentCell; if (cell == null) { return; } var row = cell.RowIndex; if (row < 0) { return; } int rowIndex; if (this.ItemsToTradeGridView.SelectedRows.Count > 1) { rowIndex = this.ItemsToTradeGridView.SelectedRows[this.ItemsToTradeGridView.SelectedRows.Count - 1] .Cells[0].RowIndex; } else { rowIndex = row; } ItemsToSaleGridUtils.RowClick( this.ItemsToTradeGridView, row, AllDescriptionsDictionary, this.AllSteamItemsToTradeGridView, this.ItemDescriptionTextBox, this.ItemImageBox, this.ItemNameLable); var list = ItemsToSaleGridUtils.GetFullRgItems(this.ItemsToTradeGridView, rowIndex); if (list != null && list.Count > 0) { LastSelectedItemDescription = list[0].Description; } } catch (Exception ex) { Logger.Critical(ex); } }
private List <FullRgItem> GetGridItemsList(int index) { var items = new List <FullRgItem>(); var row = ItemsToSaleGridUtils.GetGridHidenItemsListCell(Grid, index); if (row?.Value == null) { return(items); } items = row.Value as List <FullRgItem>; if (items != null && items.Count == 0) { return(null); } return(items); }
private void DeleteSelectedItemButtonClick(object sender, EventArgs e) { try { var cell = this.ItemsToSaleGridView.CurrentCell; if (cell == null || cell.RowIndex < 0) { return; } ItemsToSaleGridUtils.DeleteButtonClick( this.AllSteamItemsGridView, this.ItemsToSaleGridView, cell.RowIndex); } catch (Exception ex) { Logger.Critical("Error on 'Market sell' - 'Delete items to sale selected item' button click", ex); } }
private double?GetGridAveragePrice(int index) { var row = ItemsToSaleGridUtils.GetGridAveragePriceTextBoxCell(Grid, index); if (row?.Value == null) { return(null); } if (!this.GetDouble(row.Value, out var price)) { return(null); } if (price <= 0) { return(null); } return(price); }
private static async Task <Tuple <double?, double?> > GetItemsToSaleRowPrice(DataGridViewRow row) { try { var itemsCell = ItemsToSaleGridUtils.GetGridHidenItemsListCell(itemsToSaleGrid, row.Index); if (itemsCell == null || itemsCell.Value == null) { return(new Tuple <double?, double?>(-1, -1)); } var item = ItemsToSaleGridUtils.GetRowItemsList(itemsToSaleGrid, row.Index).FirstOrDefault(); if (item == null) { return(new Tuple <double?, double?>(-1, -1)); } double?currentPrice = null; if (isForced == false) { var cachedCurrentPrice = CurrentPricesCache.Get(item.Description.MarketHashName); if (cachedCurrentPrice != null) { currentPrice = cachedCurrentPrice.Price; } } if (currentPrice == null) { currentPrice = await CurrentSession.SteamManager.GetCurrentPrice( item.Asset.Appid, item.Description.MarketHashName); if (currentPrice != null && currentPrice != 0) { CurrentPricesCache.Cache(item.Description.MarketHashName, currentPrice.Value); } } double?averagePrice = null; if (isForced == false) { var cachedCurrentPrice = AveragePricesCache.Get(item.Description.MarketHashName); if (cachedCurrentPrice != null) { averagePrice = cachedCurrentPrice.Price; } } if (averagePrice != null) { return(new Tuple <double?, double?>(currentPrice, averagePrice)); } averagePrice = CurrentSession.SteamManager.GetAveragePrice( item.Asset.Appid, item.Description.MarketHashName, SavedSettings.Get().SettingsAveragePriceParseDays); if (averagePrice != null && averagePrice != 0) { AveragePricesCache.Cache(item.Description.MarketHashName, averagePrice.Value); } return(new Tuple <double?, double?>(currentPrice, averagePrice)); } catch (Exception ex) { Logger.Debug($"Error on parsing item price - {ex.Message}"); return(new Tuple <double?, double?>(0, 0)); } }
private static IEnumerable <DataGridViewRow> GetItemsToSaleRowsWithNoPrice() { return(itemsToSaleGrid.Rows.Cast <DataGridViewRow>().Where( r => ItemsToSaleGridUtils.GetRowItemPrice(itemsToSaleGrid, r.Index).Equals(null) || ItemsToSaleGridUtils.GetRowAveragePrice(itemsToSaleGrid, r.Index).Equals(null))); }