private void Form1_KeyUp(object sender, KeyEventArgs e) {//при нажатии на пробел запускаем игру и придаем игроку ускорение в верх if (e.KeyCode == Keys.Space) { if (isGlowingOn) { pen.Width = 10; } DrawTimer.Start(); playerVelocity -= 20; DrawTimer.Start(); PlayerTimer.Start(); TubesTimer.Start(); } else if (e.KeyCode == Keys.Escape) { TubesTimer.Enabled = !TubesTimer.Enabled; PlayerTimer.Enabled = !DrawTimer.Enabled; DrawTimer.Enabled = !DrawTimer.Enabled; TubesTimer.Stop(); DrawTimer.Enabled = !DrawTimer.Enabled; button5.Visible = true; button5.Enabled = true; } else if (e.KeyCode == Keys.L) { DrawTimer.Stop(); new LiderboardForm2(score).Show(); } }
//Point last = new Point(); private void DrawForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { UpdateTimer.Start(); DrawTimer.Start(); lasttime = DateTime.Now; } if (e.KeyCode == Keys.C) { UpdateTimer.Stop(); DrawTimer.Stop(); } if (e.KeyCode == Keys.D) { //camera.View = camera.View * Matrix4.Translate(0f, coeff, 0f); rocket.Move(new Vector3(rocket.Position.X + 10 * coeff, rocket.Position.Y, rocket.Position.Z)); } if (e.KeyCode == Keys.A) { rocket.Move(new Vector3(rocket.Position.X - 10 * coeff, rocket.Position.Y, rocket.Position.Z)); //camera.View = camera.View * Matrix4.Translate(0f, -coeff, 0f); } if (e.KeyCode == Keys.W) { rocket.Move(new Vector3(rocket.Position.X, rocket.Position.Y - 10 * coeff, rocket.Position.Z)); //camera.View = camera.View * Matrix4.Translate(0f, 0f, coeff); } if (e.KeyCode == Keys.S) { rocket.Move(new Vector3(rocket.Position.X, rocket.Position.Y + 10 * coeff, rocket.Position.Z)); //camera.View = camera.View * Matrix4.Translate(0f, 0f, -coeff); } }
private void GliderBTN_Click(object sender, EventArgs e) { if (gameModeClassic == true) { CGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; CGame.setCellAlive(1, 2); CGame.setCellAlive(2, 3); CGame.setCellAlive(3, 1); CGame.setCellAlive(3, 2); CGame.setCellAlive(3, 3); } if (gameModeNewRules == true) { NRGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; NRGame.setCellAlive(1, 2); NRGame.setCellAlive(2, 3); NRGame.setCellAlive(3, 1); NRGame.setCellAlive(3, 2); NRGame.setCellAlive(3, 3); } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { // При нажатии на пробел запускаем игру и // придаем игроку ускорение вверх if (e.KeyCode == Keys.Space) { pen.Width = 10; playerVelocity -= 20; DrawTimer.Start(); TubeTimer.Start(); PlayerTimer.Start(); } else if (e.KeyCode == Keys.Escape) { DrawTimer.Enabled = !DrawTimer.Enabled; PlayerTimer.Enabled = !DrawTimer.Enabled; TubeTimer.Enabled = !DrawTimer.Enabled; button1.Visible = !true; button1.Enabled = !true; button2.Visible = !true; button2.Enabled = !true; button3.Visible = !true; button3.Enabled = !true; button4.Visible = !true; button4.Enabled = !true; } else if (e.KeyCode == Keys.L) { DrawTimer.Stop(); new LeaderBoardForm(score).Show(); } }
/// <summary> /// Form closing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DungeonForm_FormClosed(object sender, FormClosedEventArgs e) { DrawTimer.Stop(); if (Dungeon != null) { Dungeon.Dispose(); } Dungeon = null; if (SpriteBatch != null) { SpriteBatch.Dispose(); } SpriteBatch = null; if (Icons != null) { Icons.Dispose(); } Icons = null; if (CheckerBoard != null) { CheckerBoard.Dispose(); } CheckerBoard = null; }
/// <summary> /// Draw Timer tick /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DrawTimer_Tick(object sender, EventArgs e) { // If not floating panel and the panel is active and AutoRefresh is OK if (this.DockAreas != DockAreas.Float && DockPanel.ActiveDocument == this) { int elapsed = Environment.TickCount - Time; Time = Environment.TickCount; // Stop the drawtimer DrawTimer.Stop(); //Animation.Update(TimeSpan.FromMilliseconds(elapsed)); Animation.Update(new GameTime(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.FromMilliseconds(elapsed))); GlFramesControl.Invalidate(); GlTilesControl.Invalidate(); GlPreviewControl.Invalidate(); // Restart the draw timer DrawTimer.Start(); } }
private void RandomBTN_Click(object sender, EventArgs e) { if (gameModeClassic == true) { CGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; CGame.Random(); } if (gameModeNewRules == true) { NRGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; NRGame.Random(); } }
private void NodeForm_FormClosed(object sender, FormClosedEventArgs e) { DrawTimer.Stop(); if (exampleBitmap != null) { exampleBitmap.Dispose(); } }
/// <summary> /// Draw timer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DrawTimer_Tick(object sender, EventArgs e) { DrawTimer.Stop(); GlControl_Paint(null, null); DrawTimer.Start(); }
private void ClearScreen_Click(object sender, EventArgs e) { ListOfInstances.Clear(); CurrentState.DrawTime = 0; DrawTimer.Stop(); DrawTimeLabel.Text = "Draw Time: 0 s"; CurrentState.IsMoveShape = false; CurrentState.IsFill = false; }
private void BackBtn_Click(object sender, EventArgs e) { DrawTimer.Stop(); CityList.Items.Clear(); VisitedCityList.Items.Clear(); visiting.Clear(); visitcompleted.Clear(); DrawPathBorder.Visible = false; AddCityPanel.Visible = true; }
private void LionHeartBTN_Click(object sender, EventArgs e) { if (gameModeClassic == true) { CGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; //code to preset the specified cells to alive so the user doesnt need to enter them manually CGame.setCellAlive(21, 23); CGame.setCellAlive(21, 24); CGame.setCellAlive(21, 26); CGame.setCellAlive(21, 27); CGame.setCellAlive(22, 22); CGame.setCellAlive(22, 25); CGame.setCellAlive(22, 28); CGame.setCellAlive(23, 22); CGame.setCellAlive(23, 28); CGame.setCellAlive(24, 22); CGame.setCellAlive(24, 28); CGame.setCellAlive(25, 23); CGame.setCellAlive(25, 27); CGame.setCellAlive(26, 24); CGame.setCellAlive(26, 26); CGame.setCellAlive(27, 25); } if (gameModeNewRules == true) { NRGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; //code to preset the specified cells to alive so the user doesnt need to enter them manually NRGame.setCellAlive(21, 23); NRGame.setCellAlive(21, 24); NRGame.setCellAlive(21, 26); NRGame.setCellAlive(21, 27); NRGame.setCellAlive(22, 22); NRGame.setCellAlive(22, 25); NRGame.setCellAlive(22, 28); NRGame.setCellAlive(23, 22); NRGame.setCellAlive(23, 28); NRGame.setCellAlive(24, 22); NRGame.setCellAlive(24, 28); NRGame.setCellAlive(25, 23); NRGame.setCellAlive(25, 27); NRGame.setCellAlive(26, 24); NRGame.setCellAlive(26, 26); NRGame.setCellAlive(27, 25); } }
public void ResetZoomLens() { // Stop timer, and hide drawing form and zoom form DrawTimer.Stop(); drawingForm.ClearForm(); drawingForm.Refresh(); drawingForm.Close(); drawingForm = new DrawingForm(); Hide(); Location = new Point(-200, -200); }
/// <summary> /// Draw timer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DrawTimer_Tick(object sender, EventArgs e) { DrawTimer.Stop(); GlControl_Paint(null, null); if (GlPreviewControl.Created) { GlPreviewControl_Paint(null, null); } DrawTimer.Start(); }
private void PlayBTN_Click(object sender, EventArgs e) { if (DrawTimer.Enabled) { DrawTimer.Stop(); PlayBTN.Text = "Play"; } else { DrawTimer.Interval = 500; DrawTimer.Start(); PlayBTN.Text = "Pause"; } }
private void UpdateTimer_Tick(object sender, EventArgs e) { camera.View = rocket.Translation; rocket.Move(new Vector3(rocket.Position.X, rocket.Position.Y, rocket.Position.Z + coeff)); //camera.View = camera.View * Matrix4.Scale(1 + coeff, 1 + coeff, 1 + coeff); hit = target.CheckHit(rocket); if (hit) { MessageBox.Show("Попал!"); UpdateTimer.Stop(); DrawTimer.Stop(); } Invalidate(); }
//When an algorithm is finished this timer is started private void DrawTimer_Tick(object sender, EventArgs e) { if (_remainder != null && _remainder.Any()) { PaintNodes(_remainder, Color.LightSkyBlue); return; } if (_path.Any()) { PaintNodes(_path, Color.CornflowerBlue); return; } //When the stack returns null and the stack is empty the timer stops DrawTimer.Stop(); }
private void DrawTimer_Tick(object sender, EventArgs e) { g.DrawLine(pen, Convert.ToInt64(citypositions[visitcompleted[counter]].x * MapImage.Width), Convert.ToInt64(citypositions[visitcompleted[counter]].y * MapImage.Height), Convert.ToInt64(citypositions[visitcompleted[counter + 1]].x * MapImage.Width), Convert.ToInt64(citypositions[visitcompleted[counter + 1]].y * MapImage.Height)); counter++; VisitedCityList.SelectedIndex = counter + 1; if (CityList.Items.Contains(cityname[visitcompleted[counter]])) { g.DrawString(cityname[visitcompleted[counter]], new Font("Arial", 12, FontStyle.Bold), new SolidBrush(drawcolor), new Point(Convert.ToInt32(citypositions[visitcompleted[counter]].x * MapImage.Width), Convert.ToInt32(citypositions[visitcompleted[counter]].y * MapImage.Height - 20))); g.DrawRectangle(pen, Convert.ToInt32(citypositions[visitcompleted[counter]].x * MapImage.Width) - 3, Convert.ToInt32(citypositions[visitcompleted[counter]].y * MapImage.Height) - 3, 6, 6); drawcolor = Color.FromArgb(255, rastgele.Next(0, 255), rastgele.Next(0, 255), rastgele.Next(0, 255)); pen.Color = drawcolor; } if (counter == visitcompleted.Count - 1) { DrawTimer.Stop(); } }
/// <summary> /// Time to paint my dear ! /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RenderControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { RenderControl.MakeCurrent(); // Stop the draw timer DrawTimer.Stop(); // Clear the background Display.ClearBuffers(); Batch.Begin(); // Background texture // Background texture Rectangle dst = new Rectangle(Point.Empty, RenderControl.Size); Batch.Draw(CheckerBoard, dst, dst, Color.White); // Draw the layout CurrentLayout.Draw(Batch); // Draw the selection box SelectionBox.Draw(Batch); // If no action and mouse over an element, draw its bounding box if (SelectionBox.MouseTool == MouseTools.NoTool) { Control elem = FindElementAt(RenderControl.PointToClient(System.Windows.Forms.Control.MousePosition)); if (elem != null) { //Display.DrawRectangle(elem.Rectangle, Color.White); } } Batch.End(); RenderControl.SwapBuffers(); // Start the draw timer DrawTimer.Start(); }
/// <summary> /// Form closing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ParentForm_FormClosing(object sender, FormClosingEventArgs e) { DrawTimer.Stop(); if (Batch != null) { Batch.Dispose(); } Batch = null; if (Icons != null) { Icons.Dispose(); } Icons = null; if (CheckerBoard != null) { CheckerBoard.Dispose(); } CheckerBoard = null; }
private void openGLControl_MouseUp(object sender, MouseEventArgs e) { CurrentState.IsMouseDown = false; if (CurrentState.IsMoveShape == true) { foreach (Shape temp in ListOfInstances) { if (temp.IsChosen == true) { temp.IsChosen = false; } } CurrentState.MoveBegin = CurrentState.MoveEnd = Point.Empty; } else { if (CurrentState.Choose != "DrawPolygon") { DrawTimer.Stop(); CurrentState.DrawTime = 0; } } }
/// <summary> /// OnPaint /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GlControl_Paint(object sender, PaintEventArgs e) { DrawTimer.Stop(); GlControl.MakeCurrent(); Display.ClearBuffers(); Batch.Begin(); // Background texture Rectangle dst = new Rectangle(Point.Empty, GlControl.Size); Batch.Draw(CheckerBoard, dst, dst, Color.White);; Batch.DrawString(CurrentFont, Point.Empty, Color.White, PreviewTextBox.Text); Batch.End(); DrawTimer.Start(); GlControl.SwapBuffers(); }
void PowerManager_IsMonitorOnChanged(object sender, EventArgs e) { if (PowerManager.IsMonitorOn) { Logger.QueueLine("Monitor has turned on, resuming LEDs"); LEDSetup.LEDS_ON = true; if (LEDSetup.ActivePort != null) { if (sColors != null) { DrawTimer.Start(); } if (aColors != null) { aColors.wi.StartRecording(); } } } else { Logger.QueueLine("Monitor has turned off, disabling LEDs"); LEDSetup.LEDS_ON = false; if (LEDSetup.ActivePort != null) { if (sColors != null) { DrawTimer.Stop(); } if (aColors != null) { aColors.wi.StopRecording(); } System.Threading.Thread.Sleep(50); LEDSetup.drawOff(); } } }
private void openGLControl_MouseDown(object sender, MouseEventArgs e) { CurrentState.IsMouseDown = true; if (CurrentState.IsMoveShape == true) { CurrentState.MoveBegin = CurrentState.MoveEnd = e.Location; savedPointInLine = pickShape(CurrentState.MoveBegin, ListOfInstances); } else { if (e.Button == MouseButtons.Left) { switch (CurrentState.Choose) { case "DrawLine": DrawTimeLabel.Text = "Draw Time: 0 s"; DrawTimer.Start(); CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newLine = new Shape(); newLine.Kind = "Line"; newLine.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newLine); break; case "DrawEllipse": DrawTimeLabel.Text = "Draw Time: 0 s"; DrawTimer.Start(); CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newEllipse = new Shape(); newEllipse.Kind = "Ellipse"; newEllipse.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newEllipse); break; case "DrawRectangle": DrawTimeLabel.Text = "Draw Time: 0 s"; DrawTimer.Start(); CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newRectangle = new Shape(); newRectangle.Kind = "Rectangle"; newRectangle.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newRectangle); break; case "DrawPentagon": DrawTimeLabel.Text = "Draw Time: 0 s"; DrawTimer.Start(); CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newPentagon = new Shape(); newPentagon.Kind = "Pentagon"; newPentagon.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newPentagon); break; case "DrawCircle": DrawTimer.Start(); DrawTimeLabel.Text = "Draw Time: 0 s"; CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newCircle = new Shape(); newCircle.Kind = "Circle"; newCircle.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newCircle); break; case "DrawEquilTriangle": DrawTimer.Start(); DrawTimeLabel.Text = "Draw Time: 0 s"; CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newEquilTriangle = new Shape(); newEquilTriangle.Kind = "EquilTriangle"; newEquilTriangle.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newEquilTriangle); break; case "DrawPolygon": if (ListOfInstances.Count > 0) { if (ListOfInstances[ListOfInstances.Count - 1].Kind == "Polygon") { if ((ListOfInstances[ListOfInstances.Count - 1]).IsDone == false) { ListOfInstances[ListOfInstances.Count - 1].ListOfBetweenPoints.Add(new Point(ListOfInstances[ListOfInstances.Count - 1].Properties.PointEnd.X, ListOfInstances[ListOfInstances.Count - 1].Properties.PointEnd.Y)); ListOfInstances[ListOfInstances.Count - 1].Properties.PointEnd = e.Location; ListOfInstances[ListOfInstances.Count - 1].PixelsInLine = drawPolygon( ListOfInstances[ListOfInstances.Count - 1].Properties.PointBegin, ListOfInstances[ListOfInstances.Count - 1].Properties.PointEnd, ListOfInstances[ListOfInstances.Count - 1].ListOfBetweenPoints, ListOfInstances[ListOfInstances.Count - 1].Properties.LineWidth ); break; } } } DrawTimeLabel.Text = "Draw Time: 0 s"; DrawTimer.Start(); CurrentCustom.PointBegin = e.Location; CurrentCustom.PointEnd = e.Location; Shape newPolygon = new Shape(); newPolygon.Kind = "Polygon"; newPolygon.Properties = (Properties)CurrentCustom.DeepCopy(); ListOfInstances.Add(newPolygon); break; } } else if (e.Button == MouseButtons.Right) { if (CurrentState.Choose == "DrawPolygon") { if (ListOfInstances[ListOfInstances.Count - 1].Kind == "Polygon" && ListOfInstances[ListOfInstances.Count - 1].IsDone == false) { ListOfInstances[ListOfInstances.Count - 1].IsDone = true; DrawTimer.Stop(); CurrentState.DrawTime = 0; } } if (CurrentState.IsFill == true) { floodFill(e.Location.X, e.Location.Y); } } } }
// If Winning State, Update Result Test And Stop Game. private void Win() { Result.Text = "Winner!"; DrawTimer.Stop(); }
public void ResetZoomLens() { DrawTimer.Stop(); this.Hide(); }
private void PenCreatorForm_FormClosed(object sender, FormClosedEventArgs e) { DrawTimer.Stop(); exampleBitmap.Dispose(); }
// Pause Game When Clicked. private void Pause_Click(object sender, EventArgs e) { DrawTimer.Stop(); }
private void ShurikenBTN_Click(object sender, EventArgs e) { if (gameModeClassic == true) { CGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; CGame.setCellAlive(20, 26); CGame.setCellAlive(20, 27); CGame.setCellAlive(21, 23); CGame.setCellAlive(22, 22); CGame.setCellAlive(22, 24); CGame.setCellAlive(22, 27); CGame.setCellAlive(22, 28); CGame.setCellAlive(23, 20); CGame.setCellAlive(23, 22); CGame.setCellAlive(23, 24); CGame.setCellAlive(23, 25); CGame.setCellAlive(23, 26); CGame.setCellAlive(23, 29); CGame.setCellAlive(24, 20); CGame.setCellAlive(24, 23); CGame.setCellAlive(24, 24); CGame.setCellAlive(24, 25); CGame.setCellAlive(24, 26); CGame.setCellAlive(24, 27); CGame.setCellAlive(24, 28); CGame.setCellAlive(25, 23); CGame.setCellAlive(25, 24); CGame.setCellAlive(25, 26); CGame.setCellAlive(25, 27); CGame.setCellAlive(26, 22); CGame.setCellAlive(26, 23); CGame.setCellAlive(26, 24); CGame.setCellAlive(26, 25); CGame.setCellAlive(26, 26); CGame.setCellAlive(26, 27); CGame.setCellAlive(26, 30); CGame.setCellAlive(27, 21); CGame.setCellAlive(27, 24); CGame.setCellAlive(27, 25); CGame.setCellAlive(27, 26); CGame.setCellAlive(27, 28); CGame.setCellAlive(27, 30); CGame.setCellAlive(28, 22); CGame.setCellAlive(28, 23); CGame.setCellAlive(28, 26); CGame.setCellAlive(28, 28); CGame.setCellAlive(29, 27); CGame.setCellAlive(30, 23); CGame.setCellAlive(30, 24); } if (gameModeNewRules) { NRGame.Clear(); Invalidate(); DrawTimer.Stop(); PlayBTN.Text = "Play"; generation = 0; GenerationLB.Text = "Generation: " + generation; NRGame.setCellAlive(20, 26); NRGame.setCellAlive(20, 27); NRGame.setCellAlive(21, 23); NRGame.setCellAlive(22, 22); NRGame.setCellAlive(22, 24); NRGame.setCellAlive(22, 27); NRGame.setCellAlive(22, 28); NRGame.setCellAlive(23, 20); NRGame.setCellAlive(23, 22); NRGame.setCellAlive(23, 24); NRGame.setCellAlive(23, 25); NRGame.setCellAlive(23, 26); NRGame.setCellAlive(23, 29); NRGame.setCellAlive(24, 20); NRGame.setCellAlive(24, 23); NRGame.setCellAlive(24, 24); NRGame.setCellAlive(24, 25); NRGame.setCellAlive(24, 26); NRGame.setCellAlive(24, 27); NRGame.setCellAlive(24, 28); NRGame.setCellAlive(25, 23); NRGame.setCellAlive(25, 24); NRGame.setCellAlive(25, 26); NRGame.setCellAlive(25, 27); NRGame.setCellAlive(26, 22); NRGame.setCellAlive(26, 23); NRGame.setCellAlive(26, 24); NRGame.setCellAlive(26, 25); NRGame.setCellAlive(26, 26); NRGame.setCellAlive(26, 27); NRGame.setCellAlive(26, 30); NRGame.setCellAlive(27, 21); NRGame.setCellAlive(27, 24); NRGame.setCellAlive(27, 25); NRGame.setCellAlive(27, 26); NRGame.setCellAlive(27, 28); NRGame.setCellAlive(27, 30); NRGame.setCellAlive(28, 22); NRGame.setCellAlive(28, 23); NRGame.setCellAlive(28, 26); NRGame.setCellAlive(28, 28); NRGame.setCellAlive(29, 27); NRGame.setCellAlive(30, 23); NRGame.setCellAlive(30, 24); } }
private void button3_Click(object sender, EventArgs e) { DrawTimer.Stop(); new LiderboardForm2(score).Show(); }