trigger some vcr events
This commit is contained in:
		@ -8,7 +8,6 @@ using System.Threading.Tasks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public static class SMvcr
 | 
					public static class SMvcr
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    private static StateVCR _concreteState;
 | 
					    private static StateVCR _concreteState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public delegate void VCREventHandler();
 | 
					    public delegate void VCREventHandler();
 | 
				
			||||||
@ -38,6 +37,45 @@ public static class SMvcr
 | 
				
			|||||||
        _concreteState = e;
 | 
					        _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 class SvcrStandBy : StateVCR
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public SvcrStandBy()
 | 
					    public SvcrStandBy()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Debug.Print("Standby\n");
 | 
					        Debug.Print("Standby\n");
 | 
				
			||||||
@ -62,16 +99,14 @@ public class SvcrStandBy : StateVCR
 | 
				
			|||||||
        SMvcr.evRecordbutton += evRecordbutton;
 | 
					        SMvcr.evRecordbutton += evRecordbutton;
 | 
				
			||||||
        SMvcr.evPlaybutton += evPlaybutton;
 | 
					        SMvcr.evPlaybutton += evPlaybutton;
 | 
				
			||||||
        SMvcr.evRewindbutton += evRewindbutton;
 | 
					        SMvcr.evRewindbutton += evRewindbutton;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evStopbutton()
 | 
					    public override void evStopbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evEndtape()
 | 
					    public override void evEndtape()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evRecordbutton()
 | 
					    public override void evRecordbutton()
 | 
				
			||||||
@ -94,7 +129,6 @@ public class SvcrStandBy : StateVCR
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public override void evBeginningtape()
 | 
					    public override void evBeginningtape()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evRewindbutton()
 | 
					    public override void evRewindbutton()
 | 
				
			||||||
@ -108,7 +142,6 @@ public class SvcrStandBy : StateVCR
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public override void evFastforwardbutton()
 | 
					    public override void evFastforwardbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -123,6 +156,7 @@ public class SvcrPlay : StateVCR
 | 
				
			|||||||
        SMvcr.evRewindbutton += evRewindbutton;
 | 
					        SMvcr.evRewindbutton += evRewindbutton;
 | 
				
			||||||
        SMvcr.evFastforwardbutton += evFastforwardbutton;
 | 
					        SMvcr.evFastforwardbutton += evFastforwardbutton;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evStopbutton()
 | 
					    public override void evStopbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SMvcr.evStopbutton -= evStopbutton;
 | 
					        SMvcr.evStopbutton -= evStopbutton;
 | 
				
			||||||
@ -145,17 +179,14 @@ public class SvcrPlay : StateVCR
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public override void evRecordbutton()
 | 
					    public override void evRecordbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evPlaybutton()
 | 
					    public override void evPlaybutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
       
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evBeginningtape()
 | 
					    public override void evBeginningtape()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
       
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evRewindbutton()
 | 
					    public override void evRewindbutton()
 | 
				
			||||||
@ -181,7 +212,6 @@ public class SvcrPlay : StateVCR
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class SvcrRewind : StateVCR
 | 
					public class SvcrRewind : StateVCR
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public SvcrRewind()
 | 
					    public SvcrRewind()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Debug.Print("Rewind\n");
 | 
					        Debug.Print("Rewind\n");
 | 
				
			||||||
@ -191,6 +221,7 @@ public class SvcrRewind : StateVCR
 | 
				
			|||||||
        SMvcr.evPlaybutton += evPlaybutton;
 | 
					        SMvcr.evPlaybutton += evPlaybutton;
 | 
				
			||||||
        SMvcr.evFastforwardbutton += evFastforwardbutton;
 | 
					        SMvcr.evFastforwardbutton += evFastforwardbutton;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evStopbutton()
 | 
					    public override void evStopbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SMvcr.evStopbutton -= evStopbutton;
 | 
					        SMvcr.evStopbutton -= evStopbutton;
 | 
				
			||||||
@ -254,6 +285,7 @@ public class SvcrFastForward : StateVCR
 | 
				
			|||||||
        SMvcr.evEndtape += evEndtape;
 | 
					        SMvcr.evEndtape += evEndtape;
 | 
				
			||||||
        SMvcr.evRewindbutton += evRewindbutton;
 | 
					        SMvcr.evRewindbutton += evRewindbutton;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evStopbutton()
 | 
					    public override void evStopbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SMvcr.evStopbutton -= evStopbutton;
 | 
					        SMvcr.evStopbutton -= evStopbutton;
 | 
				
			||||||
@ -307,6 +339,7 @@ public class SvcrRecord : StateVCR
 | 
				
			|||||||
        SMvcr.evStopbutton += evStopbutton;
 | 
					        SMvcr.evStopbutton += evStopbutton;
 | 
				
			||||||
        SMvcr.evEndtape += evEndtape;
 | 
					        SMvcr.evEndtape += evEndtape;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void evStopbutton()
 | 
					    public override void evStopbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        SMvcr.evStopbutton -= evStopbutton;
 | 
					        SMvcr.evStopbutton -= evStopbutton;
 | 
				
			||||||
@ -342,6 +375,4 @@ public class SvcrRecord : StateVCR
 | 
				
			|||||||
    public override void evFastforwardbutton()
 | 
					    public override void evFastforwardbutton()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
							
								
								
									
										38
									
								
								winVCR/winVCR/Form1.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										38
									
								
								winVCR/winVCR/Form1.Designer.cs
									
									
									
										generated
									
									
									
								
							@ -38,6 +38,8 @@
 | 
				
			|||||||
            this.btnEjectTape = new System.Windows.Forms.Button();
 | 
					            this.btnEjectTape = new System.Windows.Forms.Button();
 | 
				
			||||||
            this.btnEndTape = new System.Windows.Forms.Button();
 | 
					            this.btnEndTape = new System.Windows.Forms.Button();
 | 
				
			||||||
            this.btnNotEndTape = 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();
 | 
					            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
 | 
				
			||||||
            this.SuspendLayout();
 | 
					            this.SuspendLayout();
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -54,11 +56,11 @@
 | 
				
			|||||||
            // btnPlay
 | 
					            // btnPlay
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            this.btnPlay.BackColor = System.Drawing.Color.Transparent;
 | 
					            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.Name = "btnPlay";
 | 
				
			||||||
            this.btnPlay.Size = new System.Drawing.Size(75, 23);
 | 
					            this.btnPlay.Size = new System.Drawing.Size(75, 23);
 | 
				
			||||||
            this.btnPlay.TabIndex = 1;
 | 
					            this.btnPlay.TabIndex = 1;
 | 
				
			||||||
            this.btnPlay.Text = "Play/Pause";
 | 
					            this.btnPlay.Text = "Play";
 | 
				
			||||||
            this.btnPlay.UseVisualStyleBackColor = false;
 | 
					            this.btnPlay.UseVisualStyleBackColor = false;
 | 
				
			||||||
            this.btnPlay.Click += new System.EventHandler(this.BtnPlay_Click);
 | 
					            this.btnPlay.Click += new System.EventHandler(this.BtnPlay_Click);
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
@ -74,12 +76,13 @@
 | 
				
			|||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // btnRecord
 | 
					            // 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.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.TabIndex = 4;
 | 
				
			||||||
            this.btnRecord.Text = "Record";
 | 
					            this.btnRecord.Text = "Record";
 | 
				
			||||||
            this.btnRecord.UseVisualStyleBackColor = true;
 | 
					            this.btnRecord.UseVisualStyleBackColor = false;
 | 
				
			||||||
            this.btnRecord.Click += new System.EventHandler(this.BtnRecord_Click);
 | 
					            this.btnRecord.Click += new System.EventHandler(this.BtnRecord_Click);
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            // statusLabel
 | 
					            // statusLabel
 | 
				
			||||||
@ -133,11 +136,34 @@
 | 
				
			|||||||
            this.btnNotEndTape.UseVisualStyleBackColor = true;
 | 
					            this.btnNotEndTape.UseVisualStyleBackColor = true;
 | 
				
			||||||
            this.btnNotEndTape.Click += new System.EventHandler(this.BtnNotEndTape_Click);
 | 
					            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
 | 
					            // Form1
 | 
				
			||||||
            // 
 | 
					            // 
 | 
				
			||||||
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
 | 
					            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
 | 
				
			||||||
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 | 
					            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 | 
				
			||||||
            this.ClientSize = new System.Drawing.Size(800, 450);
 | 
					            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.btnNotEndTape);
 | 
				
			||||||
            this.Controls.Add(this.btnEndTape);
 | 
					            this.Controls.Add(this.btnEndTape);
 | 
				
			||||||
            this.Controls.Add(this.btnEjectTape);
 | 
					            this.Controls.Add(this.btnEjectTape);
 | 
				
			||||||
@ -167,6 +193,8 @@
 | 
				
			|||||||
        private System.Windows.Forms.Button btnEjectTape;
 | 
					        private System.Windows.Forms.Button btnEjectTape;
 | 
				
			||||||
        private System.Windows.Forms.Button btnEndTape;
 | 
					        private System.Windows.Forms.Button btnEndTape;
 | 
				
			||||||
        private System.Windows.Forms.Button btnNotEndTape;
 | 
					        private System.Windows.Forms.Button btnNotEndTape;
 | 
				
			||||||
 | 
					        private System.Windows.Forms.Button btnFastForward;
 | 
				
			||||||
 | 
					        private System.Windows.Forms.Button btnStop;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -17,17 +17,13 @@ namespace winVCR
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    public partial class Form1 : Form
 | 
					    public partial class Form1 : Form
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public Form1()
 | 
					        public Form1()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            InitializeComponent();
 | 
					            InitializeComponent();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            SMtape.initSMtape();
 | 
					            SMtape.initSMtape();
 | 
				
			||||||
 | 
					            SMvcr.initSMvcr();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -41,14 +37,18 @@ namespace winVCR
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private void BtnPlay_Click(object sender, EventArgs e)
 | 
					        private void BtnPlay_Click(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                SMvcr.play();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void Rewind_Click(object sender, EventArgs e)
 | 
					        private void Rewind_Click(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            SMvcr.rewind();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void BtnRecord_Click(object sender, EventArgs e)
 | 
					        private void BtnRecord_Click(object sender, EventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            SMvcr.record();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void Power_Click(object sender, EventArgs e)
 | 
					        private void Power_Click(object sender, EventArgs e)
 | 
				
			||||||
@ -74,5 +74,15 @@ namespace winVCR
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
SMtape.endTape();
 | 
					SMtape.endTape();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void BtnFastForward_Click(object sender, EventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            SMvcr.fastforward();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void BtnStop_Click(object sender, EventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            SMvcr.stop();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user