private void TrackProgress(SteamLibrary.TrackingItem item) { Stopwatch stop = new Stopwatch(); string gameid = SteamLibrary.GetApp(item.Game).AppID; try { stop.Start(); SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(item.hashname, gameid, cookieCont); item.StartPrice = Convert.ToSingle(price.P1); item.PreMedianPrice = item.MedianPrice; item.MedianPrice = Convert.ToSingle(price.P2); stop.Stop(); } catch { } try { if (((item.StartPrice / item.MedianPrice * 100) < item.BuyPercent) && (item.Buy) && (item.StartPrice > 0) && (item.MedianPrice / item.MedianPrice < 1.2)) { pricecheck = item.StartPrice; BuyThreadExcute(item.Link, true, true, true); } } catch { } doMessage(flag.Track_progress, Convert.ToInt32(stop.ElapsedMilliseconds), item, true); }
public void DoTrack(string name, string game, string hashname, int buyPer, int sellPer, int interval) { SteamLibrary.TrackingItem item = new SteamLibrary.TrackingItem(name, game, 0, 0, buyPer, sellPer, false, false, false, "", 0); item.hashname = hashname; string gameid = SteamLibrary.GetApp(game).AppID; try { SteamLibrary.StrParam price = SteamParseSite.ParseItemPrice(hashname, gameid, cookieCont); item.StartPrice = Convert.ToSingle(price.P1); item.MedianPrice = Convert.ToSingle(price.P2); } catch { } item.Link = "http://steamcommunity.com/market/listings/" + SteamLibrary.GetApp(game).AppID + "/" + name; int index = TrackingList.Count; TrackingList.Add(item); item.index = index; doMessage(flag.Add_track, 0, item, true); item.Refresh = new System.Timers.Timer(); item.Refresh.Elapsed += new System.Timers.ElapsedEventHandler(delegate { TrackProgress(item); }); item.Refresh.Interval = interval; item.Refresh.AutoReset = true; item.Refresh.Start(); }
private void LoadTrackList(object sender, DoWorkEventArgs e) { object[] parameters = e.Argument as object[]; string username = Convert.ToString(parameters[0]); int interval = Convert.ToInt32(parameters[1]); if (File.Exists(Application.StartupPath + @"\Tracks\" + username + ".ini")) { TrackingList.Clear(); TextReader config_reader = new StreamReader(Application.StartupPath + @"\Tracks\" + username + ".ini"); string input; int i = 0; while ((input = config_reader.ReadLine()) != "//") { if (input.Equals("[Item " + i + "]")) { string game = config_reader.ReadLine(); string name = config_reader.ReadLine(); string lp = config_reader.ReadLine(); string mp = config_reader.ReadLine(); string buy = config_reader.ReadLine(); string sell = config_reader.ReadLine(); string bper = config_reader.ReadLine(); string sper = config_reader.ReadLine(); string pur = config_reader.ReadLine(); string link = config_reader.ReadLine(); string purprice = config_reader.ReadLine(); string purdate = config_reader.ReadLine(); string hashname = config_reader.ReadLine(); double lowp1 = Convert.ToSingle(lp.Split(' ')[1]); double medp1 = Convert.ToSingle(mp.Split(' ')[1]); int bpe = Convert.ToInt32(bper); int spe = Convert.ToInt32(sper); double purp = 0; if (!purprice.Equals("")) { purp = Convert.ToSingle(purprice.Split(' ')[1]); } bool b = false; bool s = false; bool p = false; if (buy.Equals("x")) { b = true; } if (sell.Equals("x")) { s = true; } if (pur.Equals("x")) { p = true; } SteamLibrary.TrackingItem item = new SteamLibrary.TrackingItem(name, game, lowp1, medp1, bpe, spe, b, s, p, link, purp); item.hashname = hashname; item.purchasedate = purdate; item.index = i; TrackingList.Add(item); item.Refresh = new System.Timers.Timer(); item.Refresh.Elapsed += new System.Timers.ElapsedEventHandler(delegate { TrackProgress(item); }); item.Refresh.Interval = interval; item.Refresh.AutoReset = true; if (p == false) { item.Refresh.Start(); } i++; } } config_reader.Close(); doMessage(flag.Load_progress, 0, "Loading done!", true); } else { MessageBox.Show("Error loading tracks!", "Error"); } }
public void Event_Message(object sender, object data, int searchId, flag myflag, bool isMain) { if (data == null) { return; } string message = data.ToString(); switch (myflag) { case flag.Already_logged: StatusLabel1.Text = "Ready"; StatusPB.Image = null; SteamLibrary.AddtoLog("Already logged"); GetAccInfo((SteamLibrary.StrParam)data); break; case flag.Login_success: StatusLabel1.Text = "Ready"; StatusPB.Image = null; SteamLibrary.AddtoLog("Login succesful"); GetAccInfo((SteamLibrary.StrParam)data); break; case flag.Login_cancel: MessageBox.Show("Error logging in! " + message + "!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning); StatusPB.Image = null; StatusLabel1.Text = message; break; case flag.Logout_: StatusLabel1.Text = "Ready"; StatusPB.Image = null; LoginB.Text = "Login"; break; case flag.Search_success: ScanLV.Enabled = true; button15.Enabled = true; if (SteamAutoFunction.sppos.CurrentPos == 1) { int found = Convert.ToInt32(message); SteamAutoFunction.sppos.PageCount = found / SteamAutoFunction.SearchResCount; if (found % SteamAutoFunction.SearchResCount != 0) { SteamAutoFunction.sppos.PageCount++; } } label5.Text = string.Format("{0}/{1}", SteamAutoFunction.sppos.CurrentPos.ToString(), SteamAutoFunction.sppos.PageCount.ToString()); if (SteamAutoFunction.sppos.PageCount > 1) { prepageBT.Visible = true; nextpageBT.Visible = true; button16.Visible = false; button17.Visible = false; } else { prepageBT.Visible = false; nextpageBT.Visible = false; button16.Visible = false; button17.Visible = false; } ScanLV.Items.Clear(); for (int i = 0; i < SteamAutoFunction.SearchList.Count; i++) { var ourItem = SteamAutoFunction.SearchList[i]; string[] row = { ourItem.Game, ourItem.Name, SteamParsing.Currencies.GetName() + " " + ourItem.StartPrice, ourItem.Quantity, SteamParsing.Currencies.GetName() + " " + ourItem.MedianPrice, ourItem.Hashname }; var lstItem = new ListViewItem(row); ScanLV.Items.Add(lstItem); } button2.Enabled = true; StatusPB.Image = null; StatusLabel1.Text = "Ready"; break; case flag.Advance_search_success: ScanLV.Enabled = true; button15.Enabled = true; SteamAutoFunction.searchDone = true; if (SteamAutoFunction.sppos.CurrentPos == 1) { int found = Convert.ToInt32(message); SteamAutoFunction.sppos.PageCount = found / SteamAutoFunction.SearchResCount; if (found % SteamAutoFunction.SearchResCount != 0) { SteamAutoFunction.sppos.PageCount++; } } label5.Text = string.Format("{0}/{1}", SteamAutoFunction.sppos.CurrentPos.ToString(), SteamAutoFunction.sppos.PageCount.ToString()); if (SteamAutoFunction.sppos.PageCount > 1) { prepageBT.Visible = false; nextpageBT.Visible = false; button16.Visible = true; button17.Visible = true; } else { prepageBT.Visible = false; nextpageBT.Visible = false; button16.Visible = false; button17.Visible = false; } ScanLV.Items.Clear(); for (int i = 0; i < SteamAutoFunction.SearchList.Count; i++) { var ourItem = SteamAutoFunction.SearchList[i]; string[] row = { ourItem.Game, ourItem.Name, SteamParsing.Currencies.GetName() + " " + ourItem.StartPrice, ourItem.Quantity, SteamParsing.Currencies.GetName() + " " + ourItem.MedianPrice, ourItem.Hashname }; var lstItem = new ListViewItem(row); ScanLV.Items.Add(lstItem); } button2.Enabled = true; StatusPB.Image = null; StatusLabel1.Text = "Ready"; break; case flag.Add_track: SteamLibrary.TrackingItem item = (SteamLibrary.TrackingItem)data; string lp = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item.StartPrice); string mp = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item.MedianPrice); string[] row1 = { item.Game, item.Name, lp, mp, "", "", item.BuyPercent.ToString(), item.SellPercent.ToString(), "", item.Link, "", "", item.hashname, "" }; var lst1 = new ListViewItem(row1); TraItemLV.Items.Add(lst1); break; case flag.Track_progress: SteamLibrary.TrackingItem item1 = (SteamLibrary.TrackingItem)data; string lp1 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item1.StartPrice); string mp1 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", item1.MedianPrice); TraItemLV.Items[item1.index].SubItems[2].Text = lp1; TraItemLV.Items[item1.index].SubItems[3].Text = mp1; TraItemLV.Items[item1.index].SubItems[13].Text = searchId.ToString(); break; /*case flag.Error_scan: * * string mess = GetScanErrMess(message); * button12.Enabled = true; * button3.Enabled = true; * break;*/ case flag.Success_buy: string[] price = message.Split(';'); double itemcost = Math.Round(Convert.ToSingle(WalletL.Text.Remove(0, 2)) - Convert.ToSingle(price[0]), 2); FlashWindow.Flash(this); WalletL.Text = SteamParsing.Currencies.GetName() + " " + price[0]; button3.Enabled = true; button12.Enabled = true; for (int i = 0; i < SteamAutoFunction.TrackingList.Count; i++) { if (SteamAutoFunction.TrackingList[i].Name.Equals(price[1])) { SteamAutoFunction.TrackingList[i].Purchased = true; TraItemLV.Items[i].SubItems[8].Text = "x"; TraItemLV.Items[i].SubItems[10].Text = SteamParsing.Currencies.GetName() + " " + itemcost; TraItemLV.Items[i].SubItems[11].Text = DateTime.Today.AddDays(7).ToString(); if (SteamAutoFunction.TrackingList[i].Buy == true) { SteamAutoFunction.TrackingList[i].Buy = false; TraItemLV.Items[i].SubItems[4].Text = ""; } if (SteamAutoFunction.TrackingList[i].Buying == true) { SteamAutoFunction.TrackingList[i].Buying = false; } SteamAutoFunction.TrackingList[i].Refresh.Stop(); break; } } break; case flag.Error_buy: button3.Enabled = true; break; case flag.Load_progress: for (int a = 0; a < SteamAutoFunction.TrackingList.Count; a++) { SteamAutoFunction.TrackingList[a].index = a; string lp2 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].StartPrice); string mp2 = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].MedianPrice); string buy = ""; string sell = ""; string pured = ""; string pp = ""; if (SteamAutoFunction.TrackingList[a].Buy) { buy = "x"; } if (SteamAutoFunction.TrackingList[a].Sell) { sell = "x"; } if (SteamAutoFunction.TrackingList[a].Purchased) { pured = "x"; pp = SteamParsing.Currencies.GetName() + " " + string.Format("{0:N2}", SteamAutoFunction.TrackingList[a].PurchasePrice); } string[] row2 = { SteamAutoFunction.TrackingList[a].Game, SteamAutoFunction.TrackingList[a].Name, lp2, mp2, buy, sell, SteamAutoFunction.TrackingList[a].BuyPercent.ToString(), SteamAutoFunction.TrackingList[a].SellPercent.ToString(),pured, SteamAutoFunction.TrackingList[a].Link, pp, SteamAutoFunction.TrackingList[a].purchasedate, SteamAutoFunction.TrackingList[a].hashname, "" }; var lst2 = new ListViewItem(row2); TraItemLV.Items.Add(lst2); } break; case flag.Inventory_Loaded: button9.Enabled = true; InvenLV.Enabled = true; StatusPB.Image = null; StatusLabel1.Text = "Ready"; //SetInvFilter(); //label4.Text = filteredInvList.Count.ToString(); button1.Enabled = true; if (searchId == 0) { FillInventoryList(); button7.Enabled = true; if (comboBox1.SelectedIndex != 8) { button10.Enabled = true; } else { button10.Enabled = false; } } else { InvenLV.Items.Clear(); button10.Enabled = false; MessageBox.Show("Inventory section is empty!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } break; case flag.InvPrice: SteamLibrary.InventItem ourItem1 = (SteamLibrary.InventItem)data; string priceRes = SteamParsing.Currencies.GetName() + " " + SteamLibrary.DoFracture(ourItem1.BuyPrice); string priceMes = SteamParsing.Currencies.GetName() + " " + ourItem1.MedianPrice.ToString(); InvenLV.Items[searchId].SubItems[2].Text = priceRes; InvenLV.Items[searchId].SubItems[3].Text = priceMes; textBox2.Text = SteamLibrary.DoFracture(ourItem1.BuyPrice); textBox2_KeyUp(this, null); textBox2.ReadOnly = false; button11.Enabled = true; InvenLV.Enabled = true; break; case flag.Items_Sold: if (searchId != 1) { StatusLabel1.Text = "Ready"; StatusPB.Image = null; button10.Text = "Set price"; int app = comboBox1.SelectedIndex; SteamAuto.InventoryThreadExcute(app); } break; } }