From 9984eca5ff55946f0f3d65fcbc84822eeb78c3e6 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 9 Apr 2019 18:41:49 +0200 Subject: [PATCH] trigger some vcr events --- winVCR/VCRlogic/SMvcr.cs | 59 +++++++++++++++++++++++++-------- winVCR/winVCR/Form1.Designer.cs | 38 ++++++++++++++++++--- winVCR/winVCR/Form1.cs | 22 ++++++++---- 3 files changed, 94 insertions(+), 25 deletions(-) diff --git a/winVCR/VCRlogic/SMvcr.cs b/winVCR/VCRlogic/SMvcr.cs index 6233efd..c17cbd6 100644 --- a/winVCR/VCRlogic/SMvcr.cs +++ b/winVCR/VCRlogic/SMvcr.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; public static class SMvcr { - private static StateVCR _concreteState; public delegate void VCREventHandler(); @@ -38,6 +37,45 @@ public static class SMvcr _concreteState = e; } + public static void stop() + { + if (evStopbutton != null) + { + evStopbutton(); + } + } + + public static void record() + { + if (evRecordbutton != null) + { + evRecordbutton(); + } + } + + public static void play() + { + if (evPlaybutton != null) + { + evPlaybutton(); + } + } + + public static void rewind() + { + if (evRewindbutton != null) + { + evRewindbutton(); + } + } + + public static void fastforward() + { + if (evFastforwardbutton != null) + { + evFastforwardbutton(); + } + } } @@ -54,7 +92,6 @@ public abstract class StateVCR public class SvcrStandBy : StateVCR { - public SvcrStandBy() { Debug.Print("Standby\n"); @@ -62,16 +99,14 @@ public class SvcrStandBy : StateVCR SMvcr.evRecordbutton += evRecordbutton; SMvcr.evPlaybutton += evPlaybutton; SMvcr.evRewindbutton += evRewindbutton; - } + public override void evStopbutton() { - } public override void evEndtape() { - } public override void evRecordbutton() @@ -94,7 +129,6 @@ public class SvcrStandBy : StateVCR public override void evBeginningtape() { - } public override void evRewindbutton() @@ -108,7 +142,6 @@ public class SvcrStandBy : StateVCR public override void evFastforwardbutton() { - } } @@ -123,6 +156,7 @@ public class SvcrPlay : StateVCR SMvcr.evRewindbutton += evRewindbutton; SMvcr.evFastforwardbutton += evFastforwardbutton; } + public override void evStopbutton() { SMvcr.evStopbutton -= evStopbutton; @@ -145,17 +179,14 @@ public class SvcrPlay : StateVCR public override void evRecordbutton() { - } public override void evPlaybutton() { - } public override void evBeginningtape() { - } public override void evRewindbutton() @@ -181,7 +212,6 @@ public class SvcrPlay : StateVCR public class SvcrRewind : StateVCR { - public SvcrRewind() { Debug.Print("Rewind\n"); @@ -191,6 +221,7 @@ public class SvcrRewind : StateVCR SMvcr.evPlaybutton += evPlaybutton; SMvcr.evFastforwardbutton += evFastforwardbutton; } + public override void evStopbutton() { SMvcr.evStopbutton -= evStopbutton; @@ -254,6 +285,7 @@ public class SvcrFastForward : StateVCR SMvcr.evEndtape += evEndtape; SMvcr.evRewindbutton += evRewindbutton; } + public override void evStopbutton() { SMvcr.evStopbutton -= evStopbutton; @@ -307,6 +339,7 @@ public class SvcrRecord : StateVCR SMvcr.evStopbutton += evStopbutton; SMvcr.evEndtape += evEndtape; } + public override void evStopbutton() { SMvcr.evStopbutton -= evStopbutton; @@ -342,6 +375,4 @@ public class SvcrRecord : StateVCR public override void evFastforwardbutton() { } -} - - \ No newline at end of file +} \ No newline at end of file diff --git a/winVCR/winVCR/Form1.Designer.cs b/winVCR/winVCR/Form1.Designer.cs index 943aedf..d72265e 100644 --- a/winVCR/winVCR/Form1.Designer.cs +++ b/winVCR/winVCR/Form1.Designer.cs @@ -38,6 +38,8 @@ this.btnEjectTape = new System.Windows.Forms.Button(); this.btnEndTape = new System.Windows.Forms.Button(); this.btnNotEndTape = new System.Windows.Forms.Button(); + this.btnFastForward = new System.Windows.Forms.Button(); + this.btnStop = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -54,11 +56,11 @@ // btnPlay // this.btnPlay.BackColor = System.Drawing.Color.Transparent; - this.btnPlay.Location = new System.Drawing.Point(636, 117); + this.btnPlay.Location = new System.Drawing.Point(625, 102); this.btnPlay.Name = "btnPlay"; this.btnPlay.Size = new System.Drawing.Size(75, 23); this.btnPlay.TabIndex = 1; - this.btnPlay.Text = "Play/Pause"; + this.btnPlay.Text = "Play"; this.btnPlay.UseVisualStyleBackColor = false; this.btnPlay.Click += new System.EventHandler(this.BtnPlay_Click); // @@ -74,12 +76,13 @@ // // btnRecord // - this.btnRecord.Location = new System.Drawing.Point(667, 157); + this.btnRecord.BackColor = System.Drawing.Color.DarkRed; + this.btnRecord.Location = new System.Drawing.Point(706, 89); this.btnRecord.Name = "btnRecord"; - this.btnRecord.Size = new System.Drawing.Size(76, 25); + this.btnRecord.Size = new System.Drawing.Size(52, 25); this.btnRecord.TabIndex = 4; this.btnRecord.Text = "Record"; - this.btnRecord.UseVisualStyleBackColor = true; + this.btnRecord.UseVisualStyleBackColor = false; this.btnRecord.Click += new System.EventHandler(this.BtnRecord_Click); // // statusLabel @@ -133,11 +136,34 @@ this.btnNotEndTape.UseVisualStyleBackColor = true; this.btnNotEndTape.Click += new System.EventHandler(this.BtnNotEndTape_Click); // + // btnFastForward + // + this.btnFastForward.Location = new System.Drawing.Point(667, 159); + this.btnFastForward.Name = "btnFastForward"; + this.btnFastForward.Size = new System.Drawing.Size(75, 23); + this.btnFastForward.TabIndex = 10; + this.btnFastForward.Text = "FastForward"; + this.btnFastForward.UseVisualStyleBackColor = true; + this.btnFastForward.Click += new System.EventHandler(this.BtnFastForward_Click); + // + // btnStop + // + this.btnStop.BackColor = System.Drawing.Color.Transparent; + this.btnStop.Location = new System.Drawing.Point(625, 130); + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(75, 23); + this.btnStop.TabIndex = 11; + this.btnStop.Text = "Stop"; + this.btnStop.UseVisualStyleBackColor = false; + this.btnStop.Click += new System.EventHandler(this.BtnStop_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.btnStop); + this.Controls.Add(this.btnFastForward); this.Controls.Add(this.btnNotEndTape); this.Controls.Add(this.btnEndTape); this.Controls.Add(this.btnEjectTape); @@ -167,6 +193,8 @@ private System.Windows.Forms.Button btnEjectTape; private System.Windows.Forms.Button btnEndTape; private System.Windows.Forms.Button btnNotEndTape; + private System.Windows.Forms.Button btnFastForward; + private System.Windows.Forms.Button btnStop; } } diff --git a/winVCR/winVCR/Form1.cs b/winVCR/winVCR/Form1.cs index 2822b21..b966758 100644 --- a/winVCR/winVCR/Form1.cs +++ b/winVCR/winVCR/Form1.cs @@ -17,17 +17,13 @@ namespace winVCR { public partial class Form1 : Form { - - - - - + public Form1() { InitializeComponent(); SMtape.initSMtape(); - + SMvcr.initSMvcr(); } @@ -41,14 +37,18 @@ namespace winVCR private void BtnPlay_Click(object sender, EventArgs e) { + + SMvcr.play(); } private void Rewind_Click(object sender, EventArgs e) { + SMvcr.rewind(); } private void BtnRecord_Click(object sender, EventArgs e) { + SMvcr.record(); } private void Power_Click(object sender, EventArgs e) @@ -74,5 +74,15 @@ namespace winVCR { SMtape.endTape(); } + + private void BtnFastForward_Click(object sender, EventArgs e) + { + SMvcr.fastforward(); + } + + private void BtnStop_Click(object sender, EventArgs e) + { + SMvcr.stop(); + } } } \ No newline at end of file