public void SimulateRequestBet(string content) { string[] arr = content.Split(':'); string tableno = arr[0]; decimal potsize = Convert.ToDecimal(arr[1]); decimal currentbet = Convert.ToDecimal(arr[2]); decimal maxraisebet = Convert.ToDecimal(arr[3]); string comment = arr[4]; { // Flash the seat with a time ticker //this.origColor = this.splitContainer2.Panel2.BackColor; //Console.WriteLine("Inside SimulateRequest for " + this._vm_seat.UserName + " for " + comment); if (!this.IsHandleCreated) { Console.WriteLine("While simulating requst bet , handle is not created"); return; } this.Invoke((MethodInvoker) delegate { counter = 50; //Dialogs.BetCollectorControl ctrl = new Dialogs.BetCollectorControl(); //this.Parent.Controls.Add(ctrl); //ctrl.Dock = DockStyle.Bottom; timer1.Enabled = true; timer1.Interval = 200; timer1.Start(); View_Table vt = (View_Table)(this.Parent.Parent); vt.threadSync.Reset(); }); } Console.WriteLine("Done with SimulateRequestBet function call"); }
private async void SoftBlink(Control ctrl, string swap, Color c1, Color c2, short CycleTime_ms, bool BkClr) { var sw = new Stopwatch(); sw.Start(); short halfCycle = (short)Math.Round(CycleTime_ms * 0.5); View_Table vt = (View_Table)(this.Parent.Parent); string swapped = this.labelChipsCount.Text; Color origColor = this.labelChipsCount.BackColor; while (vt.simulatePlayerAction == this._vm_seat.SeatNo) { await Task.Delay(500); var n = sw.ElapsedMilliseconds % CycleTime_ms; var per = (double)Math.Abs(n - halfCycle) / halfCycle; var red = (short)Math.Round((c2.R - c1.R) * per) + c1.R; var grn = (short)Math.Round((c2.G - c1.G) * per) + c1.G; var blw = (short)Math.Round((c2.B - c1.B) * per) + c1.B; var clr = Color.FromArgb(red, grn, blw); if (BkClr) { ctrl.BackColor = clr; } else { ctrl.ForeColor = clr; } this.labelChipsCount.Text = this.labelChipsCount.Text == swapped ? swap : swapped; } this.labelChipsCount.Text = swapped; this.labelChipsCount.BackColor = origColor; }
private void AddToScreen(View_Table vt) { if (_cache_ViewTables.Count() <= 2) { splitContainer1.Invoke(new Action(() => tableLayoutPanel1.Controls.Add(vt, 0, _cache_ViewTables.Count() % 2))); } else { splitContainer1.Invoke(new Action(() => tableLayoutPanel1.Controls.Add(vt, 1, _cache_ViewTables.Count() % 2))); } }
private async void Blink(string swap) { string swapped = this.labelChipsCount.Text; View_Table vt = (View_Table)this.Parent; while (vt.simulatePlayerAction == this._vm_seat.SeatNo) { await Task.Delay(50); this.labelChipsCount.Text = this.labelChipsCount.Text == swapped ? swap : swapped; } }
private void splitContainer1_Panel2_SizeChanged(object sender, EventArgs e) { Panel p = (Panel)sender; if (p.Controls.Count > 0) { if (p.Controls[0] is Views.View_Table) { View_Table vt = (View_Table)p.Controls[0]; vt.Height = p.Height; vt.Width = p.Width; } } }
private void StopTimer() { this.Invoke((MethodInvoker) delegate { if (timer1.Enabled == false) { return; } timer1.Stop(); timer1.Enabled = false; this.labelChipsCount.Text = this._vm_seat.UserName; View_Table vt = (View_Table)(this.Parent.Parent); vt.threadSync.Set(); }); }
private void SetDetailPanel(string tableno) { this.Invoke((MethodInvoker) delegate { //vm.UserName = this.UserName; View_Table vt = GetViewTable(tableno); if (_currentViewTable != null) { // _currentViewTable.Visible = false; } _currentViewTable = vt; _currentViewTable.Visible = true; _currentViewTable.Invalidate(); _currentViewTable.Update(); _currentViewTable.repaint(); _detailPanelModel = _casinoModel.GetVMTable(tableno); }); }
private View_Table GetViewTable(string tableno) { View_Table vt; ViewModel_Table vm = _casinoModel.GetVMTable(tableno); vm.UserName = this.UserName; vm.UserServices = _casinoModel.UserServices; if (this._cache_ViewTables.ContainsKey(tableno)) { vt = _cache_ViewTables[tableno]; vt.SetViewModel(vm); } else { vt = new View_Table(vm); vt.JoinedTableEvent += Vt_JoinedTableEvent; vt.ReceiveBetEvent += Vt_ReceiveBetEvent; lock (this.CardEvent) { this.CardEvent[vm.TableNo] = new Action <Shared.Message>(vt.ProcessMessage); } lock (this.BetEvent) { this.BetEvent[vm.TableNo] = new Action <Shared.Message>(vt.ProcessMessage); } vt.Visible = false; vt.Height = splitContainer1.Panel2.Height; vt.Width = splitContainer1.Panel2.Width; //splitContainer1.Invoke(new Action(() => splitContainer1.Panel2.Controls.Add(vt))); _cache_ViewTables[tableno] = vt; AddToScreen(vt); } return(vt); }