//Event tick của panel chứa các nút chức năng private void Timer2_Tick(object sender, EventArgs e) { //OpPanel_Sliding if (IsShown) { if (IsFinished) { OpPanel.Width -= 10; if (OpPanel.Width <= 0) { Timer2.Stop(); IsShown = false; IsFinished = false; this.Update(); tButton.Enabled = true; } } } else { IsFinished = false; OpPanel.Width += 10; if (OpPanel.Width >= (OPanel.Width - EPanel.Width)) { Timer2.Stop(); IsShown = true; IsFinished = true; this.Update(); } } }
private void start_Click(object sender, EventArgs e) { if (m_timer == null) { if (eventBased.Checked) { m_timer = new Timer2(); m_timer.Elapsed += new ElapsedEventHandler(m_timer_Elapsed); } else { m_timer = new Timer2Subclass(); m_timer.UseCallback = true; } m_timer.SynchronizingObject = status; m_timer.Interval = int.Parse(interval.Text); m_timer.Resolution = int.Parse(precision.Text); m_timer.AutoReset = true; m_timer.Start(); start.Text = "Stop"; } else { m_timer.Stop(); m_timer.Dispose(); m_timer = null; start.Text = "Start"; } }
public void Pause_ShotClock() { if (Timer2 == null) { MessageBox.Show("NULL"); return; } Timer2.Stop(); }
private void Check_End_Shot_Time() { if (ShotTime <= 0) { Timer2.Stop(); Play_horn(); Reset_Timer2(); } }
public void Pause_Time() { if (Timer1 == null) { MessageBox.Show("NULL"); return; } Timer1.Stop(); Timer2.Stop(); }
//Timer2 void Timer2_Tick(object sender, EventArgs e) { if (Bottom > 4) { Top--; } else { Timer2.Stop(); } }
public void Timer2_Tick(object sender, EventArgs e) { if (Panel1.Width < 371) { Panel1.Width = Panel1.Width + 20; } else { Timer2.Stop(); } }
//Huỳnh Viết Thám //Các thao tác thực hiện sau mỗi lần thời gian 2 tick private void Timer2_Tick(object sender, EventArgs e) { player[1].time--; lbTime2.Text = string.Format("{0:00}:{1:00}", player[1].time / 60, player[1].time % 60); if (player[1].time == 0) { Timer1.Stop(); Timer2.Stop(); MessageBox.Show("Time out! You still can continue, but time will be stuck at 00:00!", "Chess ITUS Time Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Check_End_Time() { if (Minute == 0 && Second == 0) { Play_Sub_Horn(); Timer1.Stop(); Timer2.Stop(); Reset_Timer1(); Reset_Timer2(); } }
/// <summary> /// Tạo một thể hiện mới với các tham số được truyền vào /// </summary> /// <param name="frm">Form chứa Border này</param> /// <param name="backcolor">màu nền của Border</param> /// <param name="textcolor">Màu chữ tiêu đề của Border</param> /// <param name="textsize">Kích thước chữ tiêu đề của Border</param> /// <param name="controlmoveable">Các control có thể được di chuyển như Border khi dùng Border này</param> public Border(Form frm, Color backcolor, Color textcolor, bool backgroundMoveable, bool resizeable) { _frm = frm; _frm.FormBorderStyle = FormBorderStyle.None; BackgroundMoveable = backgroundMoveable; Resizeable = resizeable; AddFormMoveableControls(this, Title); InitializeComponent(backcolor, textcolor); // add event to control frm.MouseMove += delegate(object sender, MouseEventArgs e) { if (e.Y < Height / 2) { Timer1.Start(); Timer2.Stop(); } else { Timer2.Start(); Timer1.Stop(); } }; frm.SizeChanged += delegate(object sender, EventArgs e) { this.Width = frm.Width; CloseBox.Location = new Point(Width - CloseBox.Width, 0); NormnalBox.Location = new Point(Width - NormnalBox.Width * 2, 0); MiniBox.Location = new Point(Width - MiniBox.Width * 3, 0); OpacityTrackbar.Location = new Point(MiniBox.Left - OpacityTrackbar.Width - 5, 2); Title.Width = OpacityTrackbar.Left; frm.Refresh(); }; frm.Paint += delegate(object sender, PaintEventArgs e) { e.Graphics.DrawRectangle(new Pen(Title.BackColor), new Rectangle(0, 0, frm.Width - 1, frm.Height - 1)); }; Controls.Add(Title); Controls.Add(OpacityTrackbar); Controls.Add(MiniBox); Controls.Add(NormnalBox); Controls.Add(CloseBox); frm.Controls.Add(this); this.BringToFront(); }
private void shadowEffectFadeInMethod(object sender) { if (IsFullScreen) { if (Timer2 != null) { Timer2.Stop(); } Timer3 = new DispatcherTimer(); Timer3.Interval = System.TimeSpan.FromMilliseconds(5); Timer3.Tick += FadeIn; Timer3.Start(); } }
private void TimerClosing_Tick(object sender, EventArgs e) { Form_Main fm = new Form_Main(this); this.Opacity -= 0.05; if (this.Opacity == 0) { TimerClosing.Stop(); Timer2.Stop(); Timer1.Stop(); flag = false; this.Visible = false; fm.Show(); fm.WindowState = FormWindowState.Maximized; } }
void SetState(int cState) { if (InvokeRequired) { this.Invoke(new Action <int>(SetState), new object[] { cState }); return; } TxtState.Text = cState.ToString(); if (cState == 1) { Timer2.Start(); } else { Timer2.Stop(); } }
private void play_Click(object sender, EventArgs e) { //активируем таймеры SetTimer1(); SetTimer2(); SetTimer3(); IsActive = true; play.Enabled = false; //Пока барабаны крутятся кнопка "ИГРАТЬ!" заблокирована. Timer1.Stop(); Timer1.Dispose(); Timer2.Stop(); Timer2.Dispose(); Timer3.Stop(); Timer3.Dispose(); this.Refresh(); }
public void StopRunningTimerTest() { int interval = 500; m_timer = new Timer2(interval); m_timer.AutoReset = true; m_timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); m_hasFired = false; m_timer.Start(); Thread.Sleep(interval + 1); Assert.IsTrue(m_hasFired, "Timer didn't fire first time"); m_hasFired = false; m_timer.Stop(); Thread.Sleep(interval + 1); Assert.IsFalse(m_hasFired, "Timer fired after diabling"); }
private void Timer2_Tick(object sender, EventArgs e) { if (hidden2) { pnlRight.Width = pnlRight.Width + 10; if (pnlRight.Width >= 320) { Timer2.Stop(); hidden2 = false; this.Refresh(); } } else { pnlRight.Width = pnlRight.Width - 10; if (pnlRight.Width <= 10) { Timer2.Stop(); hidden2 = true; this.Refresh(); } } }
//Lê Thanh Tâm + Nguyễn Quang Thạch + Huỳnh Viết Thám //Khởi tạo vị trí quân cờ khi load lại game, đọc từ chuỗi 128 kí tự được lưu trên file từ trước public void BuildChessBoardFromString(string t) { RestartBoard(); string str1 = t.Substring(0, 128); t = t.Remove(0, str1.Length + 1); int n = 0; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { string s = str1.Substring(n, 2); int c = 0; AbstractChessPiece p = new AbstractChessPiece(); if (s[1] == '0') { p = new AbstractChessPiece(i, j); } else if (s[0] == 'b') { c = 1; } switch (s[1]) { case 'R': p = new Rook(i, j, c); break; case 'N': p = new Knight(i, j, c); break; case 'B': p = new Bishop(i, j, c); break; case 'Q': p = new Queen(i, j, c); break; case 'K': p = new King(i, j, c); break; case 'P': { if (c == 0) { p = new WhitePawn(i, j); } else { p = new BlackPawn(i, j); } }; break; } if (cw[i, j] == null) { cw[i, j] = p; Controls.Add(cw[i, j]); } else if (cw[i, j].Get_name != p.Get_name) { cw[i, j].Dispose(); cw[i, j] = p; Controls.Add(cw[i, j]); } n += 2; } } string str2 = t.Substring(0, t.IndexOf("\n")); t = t.Remove(0, str2.Length + 1); Int32.TryParse(str2, out turn); turn = turn % 2; pbDevil.Location = pt[turn]; string str3 = t.Substring(0, t.IndexOf("\n")); t = t.Remove(0, str3.Length + 1); Int32.TryParse(str3, out player[0].time); string str4 = t.Substring(0, t.IndexOf("\n")); t = t.Remove(0, str4.Length + 1); Int32.TryParse(str4, out player[1].time); string str5 = t.Substring(0, t.IndexOf("\n")); t = t.Remove(0, str5.Length + 1); Int32.TryParse(str5, out player[0].score); string str6 = t.Substring(0, t.IndexOf("\n")); t = t.Remove(0, str6.Length + 1); Int32.TryParse(str6, out player[1].score); string str7 = t.Substring(0, t.IndexOf("\n")); player[0].eaten = str7; t = t.Remove(0, str7.Length + 1); string str8 = t.Substring(0, t.IndexOf("\n")); player[1].eaten = str8; t = t.Remove(0, str8.Length + 1); if (turn % 2 == 0) { Timer1.Start(); Timer2.Stop(); } else { Timer2.Start(); Timer1.Stop(); } cw[0, 0].GetAdvantage(); Player.LoadPlayerInfo(); }
private void StopButton_Click(object sender, EventArgs e) { StartButton.BringToFront(); Timer2.Stop(); }