Advertisement
BrU32

C# Traffic Signal SRC V1

Mar 10th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. //C# Traffic Signal Simulation SRC
  2.  
  3. //Coded By BrÜ
  4.  
  5. //CompulsiveCoding.com
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15.  
  16. namespace Stoplight_Example_SRC_Code
  17. {
  18. public partial class Form1 : Form
  19. {
  20. public Form1()
  21. {
  22. InitializeComponent();
  23. }
  24.  
  25. private void Form1_Load(object sender, EventArgs e)
  26. {
  27.  
  28. }
  29. public bool WayOne=false;
  30. public int I=0;
  31. private void timer1_Tick(object sender, EventArgs e)
  32. {
  33. I++;
  34. if (WayOne==false){
  35. pictureBox1.Location= new System.Drawing.Point(355,I);
  36. }
  37. else
  38. {
  39. pictureBox2.Location = new System.Drawing.Point(I, 246);
  40. }
  41. if (I == 525 && WayOne == true)
  42. {
  43. label1.ForeColor = Color.Yellow;
  44. label1.Text = "Slow Down!!";
  45. }
  46. if(I==735 && WayOne==true){
  47. WayOne=false;
  48. label2.ForeColor = Color.Green;
  49. label1.ForeColor = Color.Red;
  50. label2.Text = "Go!!";
  51. label1.Text="Stop!!";
  52. I=0;
  53. pictureBox2.Location = new System.Drawing.Point(0, 246);
  54. }
  55. if (I == 525 && WayOne == false)
  56. {
  57. label2.ForeColor = Color.Yellow;
  58. label2.Text = "Slow Down!!";
  59. }
  60. if(I==735 && WayOne==false){
  61. WayOne=true;
  62. label1.ForeColor = Color.Green;
  63. label2.ForeColor = Color.Red;
  64. label2.Text = "Stop!!";
  65. label1.Text = "Go!!";
  66. I=0;
  67. pictureBox1.Location = new System.Drawing.Point(355, 0);
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement