public MainWindow() { InitializeComponent(); this.running = true; this._auctions = new Auctions(); this._controller = new Controller("127.0.0.1", 12346); this.worker = new Thread(new ThreadStart(Task)); this.worker.Start(); }
public static Auctions InterpretAuction(string command) { if (command == "/listAuction null") return new Auctions(); var list = new Auctions(); var input = command.Split(' '); input = input[1].Split('{'); for (int i = 0; i < input[0].Length; i++) { if (input[0][i] == ':') { var temp = input[1].Split(';'); int id = -1; string description = string.Empty; double price = -1D; bool ok = true; description = temp[1].Split('=')[1]; if (!int.TryParse(temp[0].Split('=')[1], out id)) ok = false; if (!double.TryParse(temp[2].Split('=')[1].Split('}')[0], out price)) ok = false; if (!ok) return new Auctions(); list.Add(new Auction(id, description, price)); break; } } if (list.Count < 1) { for (int i = 1; i < input.Length; i++) { var temp = input[i].Split(';'); int id = -1; string description = string.Empty; double price = -1D; bool ok = true; description = temp[1].Split('=')[1]; if (!int.TryParse(temp[0].Split('=')[1], out id)) ok = false; if (!double.TryParse(temp[2].Split('=')[1].Split('}')[0], out price)) ok = false; if (ok) list.Add(new Auction(id, description, price)); } } return list; }
private void ListAuctionUpdate(Auctions list) { this._auctions = list; var temp = new List<DG>(); foreach (var item in this._auctions.List) temp.Add((DG)item); object selObj = null; this.Dispatcher.Invoke((Action)(() => { string[] txt = { this.txtBidID.Text, this.txtBidAmount.Text }; if (this.dgvAuctionList.SelectedIndex != -1) selObj = this.dgvAuctionList.SelectedItem; this.dgvAuctionList.ItemsSource = temp; if (selObj != null) { int count = -1; foreach (var item in this.dgvAuctionList.ItemsSource) { count++; if (((DG)item).ID == ((DG)selObj).ID) { this.dgvAuctionList.SelectedIndex = count; this.txtBidID.Text = txt[0]; this.txtBidAmount.Text = txt[1]; } } } })); }