public static void Main(string[] args) { if (args.Length == 0) { Console.Write("Server name: "); Game.serverName = Console.ReadLine(); } else { Game.serverName = args[0]; TrackerHandler.doConnect = false; } UdpClient client = new UdpClient(); MessageBuffer msg = new MessageBuffer(); msg.WriteByte(1); msg.WriteShort(Port.UDP); client.Send(msg.Array, msg.Size, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 12345)); client.Close(); game = new Game(); Multimedia.Timer timer = new Multimedia.Timer(); timer.Period = 7; timer.Resolution = 0; timer.Mode = Multimedia.TimerMode.Periodic; timer.Tick += timer_Tick; timer.Start(); while (running) { Thread.Sleep(500); if (!timer.IsRunning) { Console.WriteLine("Timer stopped...."); } } }
public MainWindow() { InitializeComponent(); _time = new Multimedia.Timer(); _time.Period = 250; System.Threading.Thread thisThread = System.Threading.Thread.CurrentThread; thisThread.Priority = System.Threading.ThreadPriority.Highest; string g = ""; string b = ""; blacks = new Rectangle[4]; greys = new Rectangle[4]; for (int i = 0; i < 4; i++) { b = "rectB" + (i + 1).ToString(); g = "rectG" + (i + 1).ToString(); blacks[i] = FindChild <Rectangle>(grid, b); greys[i] = FindChild <Rectangle>(grid, g); } }
protected void Finish() { this.ClearFade(); Sound = null; this.PlayTimer = null; this.ResetParameters(); GC.Collect(); }
// Player actions public void Play() { if (!this.Initialized) { this.Initialize(); } if (!this.Initialized) { this.CallNext(); return; } this.PlayTimer = new Multimedia.Timer(); this.PlayTimer.Resolution = 1; this.PlayTimer.Tick += new EventHandler(Tick); this.PlayTimer.Start(); this.SetVolume(); this.SetPan(); Sound.Play(); PlayStarted(this, new EventArgs()); }
/// <summary> /// Called by all constructors /// </summary> private void Setup() { SerialPortOpen = true; BufferPollTimer = new Multimedia.Timer(); BufferPollTimer.Period = 1; BufferPollTimer.Resolution = 0; BufferPollTimer.Tick +=new EventHandler(BufferPollTimer_Tick); BufferPollTimer.Start(); ResponseTimer = new Multimedia.Timer(); ResponseTimer.Period = TimeOut; ResponseTimer.Mode = TimerMode.Periodic; ResponseTimer.Resolution = 0; ResponseTimer.Stop(); ResponseTimer.Tick += new EventHandler(ResponseTimer_Tick); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.groupBox3 = new GroupBox(); this.txtPeriod = new System.Windows.Forms.TextBox(); this.groupBox2 = new GroupBox(); this.rbPeriodic = new RadioButton(); this.rbOneShot = new RadioButton(); this.groupBox5 = new GroupBox(); this.lblCounter = new Label(); this.errorProvider1 = new ErrorProvider(this.components); this.btnStop = new System.Windows.Forms.Button(); this.groupBox4 = new GroupBox(); this.txtResolution = new System.Windows.Forms.TextBox(); this.groupBox1 = new GroupBox(); this.lblPeriodMax = new Label(); this.lblPeriodMin = new Label(); this.label2 = new Label(); this.label1 = new Label(); this.btnStart = new System.Windows.Forms.Button(); this.mmTimer = new Multimedia.Timer(this.components); this.groupBox3.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); this.groupBox4.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // groupBox3 // this.groupBox3.Controls.Add(this.txtPeriod); this.groupBox3.Location = new System.Drawing.Point(8, 96); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(152, 56); this.groupBox3.TabIndex = 9; this.groupBox3.TabStop = false; this.groupBox3.Text = "Period"; // // txtPeriod // this.txtPeriod.Location = new System.Drawing.Point(24, 24); this.txtPeriod.MaxLength = 7; this.txtPeriod.Name = "txtPeriod"; this.txtPeriod.Size = new System.Drawing.Size(100, 20); this.txtPeriod.TabIndex = 0; this.txtPeriod.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.txtPeriod.WordWrap = false; this.txtPeriod.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPeriod_KeyPress); this.txtPeriod.Validating += new System.ComponentModel.CancelEventHandler(this.txtPeriod_Validating); // // groupBox2 // this.groupBox2.Controls.Add(this.rbPeriodic); this.groupBox2.Controls.Add(this.rbOneShot); this.groupBox2.Location = new System.Drawing.Point(168, 8); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(144, 80); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; this.groupBox2.Text = "Mode"; // // rbPeriodic // this.rbPeriodic.Location = new System.Drawing.Point(24, 48); this.rbPeriodic.Name = "rbPeriodic"; this.rbPeriodic.Size = new System.Drawing.Size(104, 24); this.rbPeriodic.TabIndex = 1; this.rbPeriodic.Text = "Periodic"; this.rbPeriodic.CheckedChanged += new System.EventHandler(this.rbPeriodic_CheckedChanged); // // rbOneShot // this.rbOneShot.Location = new System.Drawing.Point(24, 16); this.rbOneShot.Name = "rbOneShot"; this.rbOneShot.Size = new System.Drawing.Size(104, 24); this.rbOneShot.TabIndex = 0; this.rbOneShot.Text = "One Shot"; this.rbOneShot.CheckedChanged += new System.EventHandler(this.rbOneShot_CheckedChanged); // // groupBox5 // this.groupBox5.Controls.Add(this.lblCounter); this.groupBox5.Location = new System.Drawing.Point(168, 168); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(144, 56); this.groupBox5.TabIndex = 13; this.groupBox5.TabStop = false; this.groupBox5.Text = "Counter"; // // lblCounter // this.lblCounter.Location = new System.Drawing.Point(16, 24); this.lblCounter.Name = "lblCounter"; this.lblCounter.Size = new System.Drawing.Size(112, 16); this.lblCounter.TabIndex = 0; this.lblCounter.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // errorProvider1 // this.errorProvider1.ContainerControl = this; // // btnStop // this.btnStop.Location = new System.Drawing.Point(200, 136); this.btnStop.Name = "btnStop"; this.btnStop.Size = new System.Drawing.Size(75, 23); this.btnStop.TabIndex = 12; this.btnStop.Text = "Stop"; this.btnStop.Click += new System.EventHandler(this.btnStop_Click); // // groupBox4 // this.groupBox4.Controls.Add(this.txtResolution); this.groupBox4.Location = new System.Drawing.Point(8, 168); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(152, 56); this.groupBox4.TabIndex = 10; this.groupBox4.TabStop = false; this.groupBox4.Text = "Resolution"; // // txtResolution // this.txtResolution.Location = new System.Drawing.Point(24, 24); this.txtResolution.Name = "txtResolution"; this.txtResolution.Size = new System.Drawing.Size(104, 20); this.txtResolution.TabIndex = 0; this.txtResolution.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.txtResolution.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtResolution_KeyPress); // // groupBox1 // this.groupBox1.Controls.Add(this.lblPeriodMax); this.groupBox1.Controls.Add(this.lblPeriodMin); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Location = new System.Drawing.Point(8, 8); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(152, 80); this.groupBox1.TabIndex = 7; this.groupBox1.TabStop = false; this.groupBox1.Text = "Capabilities"; // // lblPeriodMax // this.lblPeriodMax.Location = new System.Drawing.Point(88, 48); this.lblPeriodMax.Name = "lblPeriodMax"; this.lblPeriodMax.Size = new System.Drawing.Size(48, 16); this.lblPeriodMax.TabIndex = 3; this.lblPeriodMax.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblPeriodMin // this.lblPeriodMin.Location = new System.Drawing.Point(88, 24); this.lblPeriodMin.Name = "lblPeriodMin"; this.lblPeriodMin.Size = new System.Drawing.Size(48, 16); this.lblPeriodMin.TabIndex = 2; this.lblPeriodMin.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label2 // this.label2.Location = new System.Drawing.Point(8, 48); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(72, 16); this.label2.TabIndex = 1; this.label2.Text = "Period Max:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label1 // this.label1.Location = new System.Drawing.Point(16, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(64, 16); this.label1.TabIndex = 0; this.label1.Text = "Period Min:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // btnStart // this.btnStart.Location = new System.Drawing.Point(200, 104); this.btnStart.Name = "btnStart"; this.btnStart.Size = new System.Drawing.Size(75, 23); this.btnStart.TabIndex = 11; this.btnStart.Text = "Start"; this.btnStart.Click += new System.EventHandler(this.btnStart_Click); // // mmTimer // this.mmTimer.Mode = Multimedia.TimerMode.Periodic; this.mmTimer.Period = 1; this.mmTimer.Resolution = 1; this.mmTimer.SynchronizingObject = this; this.mmTimer.Tick += new System.EventHandler(this.mmTimer_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(328, 246); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox5); this.Controls.Add(this.btnStop); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btnStart); this.Controls.Add(this.groupBox3); this.Name = "Form1"; this.Text = "Multimedia Timer Demo"; this.Load += new System.EventHandler(this.Form1_Load); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); }
/// <summary> /// Initializes tick generator. /// </summary> private void InitializeTickGenerator() { TimerCaps caps = Timer.Capabilities; timer = new Timer(new TimerCallback(OnTick), null, caps.periodMin, 0, TimerMode.Periodic); period = caps.periodMin * 1000; Tempo = DefaultTempo; pulsesPerQuarterNote = DefaultPpqn; }
/// <summary> /// Initializes tick generator. /// </summary> private void InitializeTickGenerator() { TimerCaps caps = Timer.Capabilities; timer = new Timer(new TimerCallback(OnTick), null, caps.periodMin, 0, TimerMode.Periodic); period = caps.periodMin * 1000; Tempo = DefaultTempo; TicksPerBeat = DefaultTicksPerBeat; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.txtPeriod = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.rbPeriodic = new System.Windows.Forms.RadioButton(); this.rbOneShot = new System.Windows.Forms.RadioButton(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.lblCounter = new System.Windows.Forms.Label(); this.errorProvider1 = new System.Windows.Forms.ErrorProvider(); this.btnStop = new System.Windows.Forms.Button(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.txtResolution = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.lblPeriodMax = new System.Windows.Forms.Label(); this.lblPeriodMin = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.btnStart = new System.Windows.Forms.Button(); this.mmTimer = new Multimedia.Timer(this.components); this.groupBox3.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox5.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // groupBox3 // this.groupBox3.Controls.Add(this.txtPeriod); this.groupBox3.Location = new System.Drawing.Point(8, 96); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(152, 56); this.groupBox3.TabIndex = 9; this.groupBox3.TabStop = false; this.groupBox3.Text = "Period"; // // txtPeriod // this.txtPeriod.Location = new System.Drawing.Point(24, 24); this.txtPeriod.MaxLength = 7; this.txtPeriod.Name = "txtPeriod"; this.txtPeriod.TabIndex = 0; this.txtPeriod.Text = ""; this.txtPeriod.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.txtPeriod.WordWrap = false; this.txtPeriod.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPeriod_KeyPress); this.txtPeriod.Validating += new System.ComponentModel.CancelEventHandler(this.txtPeriod_Validating); // // groupBox2 // this.groupBox2.Controls.Add(this.rbPeriodic); this.groupBox2.Controls.Add(this.rbOneShot); this.groupBox2.Location = new System.Drawing.Point(168, 8); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(144, 80); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; this.groupBox2.Text = "Mode"; // // rbPeriodic // this.rbPeriodic.Location = new System.Drawing.Point(24, 48); this.rbPeriodic.Name = "rbPeriodic"; this.rbPeriodic.TabIndex = 1; this.rbPeriodic.Text = "Periodic"; this.rbPeriodic.CheckedChanged += new System.EventHandler(this.rbPeriodic_CheckedChanged); // // rbOneShot // this.rbOneShot.Location = new System.Drawing.Point(24, 16); this.rbOneShot.Name = "rbOneShot"; this.rbOneShot.TabIndex = 0; this.rbOneShot.Text = "One Shot"; this.rbOneShot.CheckedChanged += new System.EventHandler(this.rbOneShot_CheckedChanged); // // groupBox5 // this.groupBox5.Controls.Add(this.lblCounter); this.groupBox5.Location = new System.Drawing.Point(168, 168); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(144, 56); this.groupBox5.TabIndex = 13; this.groupBox5.TabStop = false; this.groupBox5.Text = "Counter"; // // lblCounter // this.lblCounter.Location = new System.Drawing.Point(16, 24); this.lblCounter.Name = "lblCounter"; this.lblCounter.Size = new System.Drawing.Size(112, 16); this.lblCounter.TabIndex = 0; this.lblCounter.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // errorProvider1 // this.errorProvider1.ContainerControl = this; // // btnStop // this.btnStop.Location = new System.Drawing.Point(200, 136); this.btnStop.Name = "btnStop"; this.btnStop.TabIndex = 12; this.btnStop.Text = "Stop"; this.btnStop.Click += new System.EventHandler(this.btnStop_Click); // // groupBox4 // this.groupBox4.Controls.Add(this.txtResolution); this.groupBox4.Location = new System.Drawing.Point(8, 168); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(152, 56); this.groupBox4.TabIndex = 10; this.groupBox4.TabStop = false; this.groupBox4.Text = "Resolution"; // // txtResolution // this.txtResolution.Location = new System.Drawing.Point(24, 24); this.txtResolution.Name = "txtResolution"; this.txtResolution.Size = new System.Drawing.Size(104, 20); this.txtResolution.TabIndex = 0; this.txtResolution.Text = ""; this.txtResolution.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.txtResolution.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtResolution_KeyPress); // // groupBox1 // this.groupBox1.Controls.Add(this.lblPeriodMax); this.groupBox1.Controls.Add(this.lblPeriodMin); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Location = new System.Drawing.Point(8, 8); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(152, 80); this.groupBox1.TabIndex = 7; this.groupBox1.TabStop = false; this.groupBox1.Text = "Capabilities"; // // lblPeriodMax // this.lblPeriodMax.Location = new System.Drawing.Point(88, 48); this.lblPeriodMax.Name = "lblPeriodMax"; this.lblPeriodMax.Size = new System.Drawing.Size(48, 16); this.lblPeriodMax.TabIndex = 3; this.lblPeriodMax.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // lblPeriodMin // this.lblPeriodMin.Location = new System.Drawing.Point(88, 24); this.lblPeriodMin.Name = "lblPeriodMin"; this.lblPeriodMin.Size = new System.Drawing.Size(48, 16); this.lblPeriodMin.TabIndex = 2; this.lblPeriodMin.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label2 // this.label2.Location = new System.Drawing.Point(8, 48); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(72, 16); this.label2.TabIndex = 1; this.label2.Text = "Period Max:"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // label1 // this.label1.Location = new System.Drawing.Point(16, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(64, 16); this.label1.TabIndex = 0; this.label1.Text = "Period Min:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // btnStart // this.btnStart.Location = new System.Drawing.Point(200, 104); this.btnStart.Name = "btnStart"; this.btnStart.TabIndex = 11; this.btnStart.Text = "Start"; this.btnStart.Click += new System.EventHandler(this.btnStart_Click); // // mmTimer // this.mmTimer.Mode = Multimedia.TimerMode.Periodic; this.mmTimer.Period = 1; this.mmTimer.Resolution = 1; this.mmTimer.SynchronizingObject = this; this.mmTimer.Tick += new System.EventHandler(this.mmTimer_Tick); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(328, 246); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox5); this.Controls.Add(this.btnStop); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btnStart); this.Controls.Add(this.groupBox3); this.Name = "Form1"; this.Text = "Multimedia Timer Demo"; this.Load += new System.EventHandler(this.Form1_Load); this.groupBox3.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox5.ResumeLayout(false); this.groupBox4.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); }