first events
This commit is contained in:
		@ -1,29 +1,122 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Security.Cryptography.X509Certificates;
 | 
			
		||||
using VCRlogic;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMtape
 | 
			
		||||
namespace VCRlogic
 | 
			
		||||
{
 | 
			
		||||
    private SMtape _concreteState;
 | 
			
		||||
 | 
			
		||||
    public SMtape()
 | 
			
		||||
    public static class SMtape
 | 
			
		||||
    {
 | 
			
		||||
        private static StateTape _concreteState;
 | 
			
		||||
 | 
			
		||||
        public delegate void TapeEventHandler();
 | 
			
		||||
 | 
			
		||||
        public static event TapeEventHandler evIntape;
 | 
			
		||||
 | 
			
		||||
        public static event TapeEventHandler evOuttape;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static void initSMtape()
 | 
			
		||||
        {
 | 
			
		||||
            setState(new StapeNoTapeIn());
 | 
			
		||||
 | 
			
		||||
            //evIntape += evIntape;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void setState(StateTape e)
 | 
			
		||||
        {
 | 
			
		||||
            _concreteState = null;
 | 
			
		||||
 | 
			
		||||
            _concreteState = e;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public static void insertTape()
 | 
			
		||||
        {
 | 
			
		||||
            if (evIntape != null)
 | 
			
		||||
            {
 | 
			
		||||
                evIntape();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void ejectTape()
 | 
			
		||||
        {
 | 
			
		||||
            if (evOuttape != null)
 | 
			
		||||
            {
 | 
			
		||||
                evOuttape();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMtapeNoTapeIn : SMtape
 | 
			
		||||
public abstract class StateTape
 | 
			
		||||
{
 | 
			
		||||
    public abstract void evIntape();
 | 
			
		||||
 | 
			
		||||
    public abstract void evOuttape();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMtapeTapeInNotEnd : SMtape
 | 
			
		||||
public class StapeNoTapeIn : StateTape
 | 
			
		||||
{
 | 
			
		||||
    public override void evIntape()
 | 
			
		||||
    {
 | 
			
		||||
        Debug.Print("tape is now in\n");
 | 
			
		||||
 | 
			
		||||
        //unsub
 | 
			
		||||
        SMtape.evIntape -= evIntape;
 | 
			
		||||
 | 
			
		||||
        SMtape.setState(new StapeTapeInNotEnd());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override void evOuttape()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public StapeNoTapeIn()
 | 
			
		||||
    {
 | 
			
		||||
        // sub to event
 | 
			
		||||
        SMtape.evIntape += evIntape;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class SMtapeTapeInEnd : SMtape
 | 
			
		||||
 | 
			
		||||
public class StapeTapeInNotEnd : StateTape
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
    public override void evIntape()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public override void evOuttape()
 | 
			
		||||
    {
 | 
			
		||||
        Debug.Print("tape is now out\n");
 | 
			
		||||
 | 
			
		||||
        //unsub
 | 
			
		||||
        SMtape.evOuttape -= evOuttape;
 | 
			
		||||
        SMtape.setState(new StapeNoTapeIn());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public StapeTapeInNotEnd()
 | 
			
		||||
    {
 | 
			
		||||
        //sub
 | 
			
		||||
        SMtape.evOuttape += evOuttape;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
public class StapeTapeInEnd : StateTape
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    */
 | 
			
		||||
@ -9,7 +9,17 @@ public class SMvcr
 | 
			
		||||
{
 | 
			
		||||
    private string _labelText;
 | 
			
		||||
 | 
			
		||||
    private SMvcr _concreteState;
 | 
			
		||||
    private StateVCR _concreteState;
 | 
			
		||||
 | 
			
		||||
    public SMvcr()
 | 
			
		||||
    {
 | 
			
		||||
        setState(new SvcrStandBy());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setState(StateVCR e)
 | 
			
		||||
    {
 | 
			
		||||
        _concreteState = e;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public string getLabelText()
 | 
			
		||||
    {
 | 
			
		||||
@ -18,25 +28,50 @@ public class SMvcr
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMvcrStandBy : SMvcr
 | 
			
		||||
public abstract class StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public abstract void setStateText();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class SvcrStandBy : StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMvcrPlay : SMvcr
 | 
			
		||||
public class SvcrPlay : StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMvcrRewind : SMvcr
 | 
			
		||||
public class SvcrRewind : StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class SMvcrFastForward : SMvcr
 | 
			
		||||
public class SvcrFastForward : StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class SMvcrRecord : SMvcr
 | 
			
		||||
public class SvcrRecord : StateVCR
 | 
			
		||||
{
 | 
			
		||||
    public override void setStateText()
 | 
			
		||||
    {
 | 
			
		||||
        throw new NotImplementedException();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								winVCR/winVCR/Form1.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										34
									
								
								winVCR/winVCR/Form1.Designer.cs
									
									
									
										generated
									
									
									
								
							@ -36,6 +36,8 @@
 | 
			
		||||
            this.statusLabel = new System.Windows.Forms.Label();
 | 
			
		||||
            this.btnInsertTape = new System.Windows.Forms.Button();
 | 
			
		||||
            this.btnEjectTape = new System.Windows.Forms.Button();
 | 
			
		||||
            this.btnEndTape = new System.Windows.Forms.Button();
 | 
			
		||||
            this.btnNotEndTape = new System.Windows.Forms.Button();
 | 
			
		||||
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
 | 
			
		||||
            this.SuspendLayout();
 | 
			
		||||
            // 
 | 
			
		||||
@ -93,9 +95,9 @@
 | 
			
		||||
            // 
 | 
			
		||||
            // btnInsertTape
 | 
			
		||||
            // 
 | 
			
		||||
            this.btnInsertTape.Location = new System.Drawing.Point(201, 117);
 | 
			
		||||
            this.btnInsertTape.Location = new System.Drawing.Point(197, 117);
 | 
			
		||||
            this.btnInsertTape.Name = "btnInsertTape";
 | 
			
		||||
            this.btnInsertTape.Size = new System.Drawing.Size(99, 44);
 | 
			
		||||
            this.btnInsertTape.Size = new System.Drawing.Size(79, 44);
 | 
			
		||||
            this.btnInsertTape.TabIndex = 6;
 | 
			
		||||
            this.btnInsertTape.Text = "Insert Tape";
 | 
			
		||||
            this.btnInsertTape.UseVisualStyleBackColor = true;
 | 
			
		||||
@ -103,19 +105,41 @@
 | 
			
		||||
            // 
 | 
			
		||||
            // btnEjectTape
 | 
			
		||||
            // 
 | 
			
		||||
            this.btnEjectTape.Location = new System.Drawing.Point(451, 117);
 | 
			
		||||
            this.btnEjectTape.Location = new System.Drawing.Point(483, 117);
 | 
			
		||||
            this.btnEjectTape.Name = "btnEjectTape";
 | 
			
		||||
            this.btnEjectTape.Size = new System.Drawing.Size(99, 44);
 | 
			
		||||
            this.btnEjectTape.Size = new System.Drawing.Size(79, 44);
 | 
			
		||||
            this.btnEjectTape.TabIndex = 7;
 | 
			
		||||
            this.btnEjectTape.Text = "Eject Tape";
 | 
			
		||||
            this.btnEjectTape.UseVisualStyleBackColor = true;
 | 
			
		||||
            this.btnEjectTape.Click += new System.EventHandler(this.BtnEjectTape_Click);
 | 
			
		||||
            // 
 | 
			
		||||
            // btnEndTape
 | 
			
		||||
            // 
 | 
			
		||||
            this.btnEndTape.Location = new System.Drawing.Point(293, 117);
 | 
			
		||||
            this.btnEndTape.Name = "btnEndTape";
 | 
			
		||||
            this.btnEndTape.Size = new System.Drawing.Size(79, 44);
 | 
			
		||||
            this.btnEndTape.TabIndex = 8;
 | 
			
		||||
            this.btnEndTape.Text = "End Tape";
 | 
			
		||||
            this.btnEndTape.UseVisualStyleBackColor = true;
 | 
			
		||||
            this.btnEndTape.Click += new System.EventHandler(this.BtnEndTape_Click);
 | 
			
		||||
            // 
 | 
			
		||||
            // btnNotEndTape
 | 
			
		||||
            // 
 | 
			
		||||
            this.btnNotEndTape.Location = new System.Drawing.Point(388, 117);
 | 
			
		||||
            this.btnNotEndTape.Name = "btnNotEndTape";
 | 
			
		||||
            this.btnNotEndTape.Size = new System.Drawing.Size(79, 44);
 | 
			
		||||
            this.btnNotEndTape.TabIndex = 9;
 | 
			
		||||
            this.btnNotEndTape.Text = "Not End Tape";
 | 
			
		||||
            this.btnNotEndTape.UseVisualStyleBackColor = true;
 | 
			
		||||
            this.btnNotEndTape.Click += new System.EventHandler(this.BtnNotEndTape_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.btnNotEndTape);
 | 
			
		||||
            this.Controls.Add(this.btnEndTape);
 | 
			
		||||
            this.Controls.Add(this.btnEjectTape);
 | 
			
		||||
            this.Controls.Add(this.btnInsertTape);
 | 
			
		||||
            this.Controls.Add(this.statusLabel);
 | 
			
		||||
@ -141,6 +165,8 @@
 | 
			
		||||
        private System.Windows.Forms.Label statusLabel;
 | 
			
		||||
        private System.Windows.Forms.Button btnInsertTape;
 | 
			
		||||
        private System.Windows.Forms.Button btnEjectTape;
 | 
			
		||||
        private System.Windows.Forms.Button btnEndTape;
 | 
			
		||||
        private System.Windows.Forms.Button btnNotEndTape;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.ComponentModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Data;
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
@ -8,15 +9,36 @@ using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
using VCRlogic;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace winVCR
 | 
			
		||||
{
 | 
			
		||||
    public partial class Form1 : Form
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public Form1()
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
 | 
			
		||||
            SMtape.initSMtape();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public void setLabelText(string txt)
 | 
			
		||||
        {
 | 
			
		||||
            statusLabel.Text = txt;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        private void BtnPlay_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
@ -35,10 +57,20 @@ namespace winVCR
 | 
			
		||||
 | 
			
		||||
        private void BtnInsertTape_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            SMtape.insertTape();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void BtnEjectTape_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            SMtape.ejectTape();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void BtnNotEndTape_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void BtnEndTape_Click(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -79,5 +79,11 @@
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <None Include="App.config" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\VCRlogic\VCRlogic.csproj">
 | 
			
		||||
      <Project>{74f418c8-f030-41c7-ba8d-8a9b57253e45}</Project>
 | 
			
		||||
      <Name>VCRlogic</Name>
 | 
			
		||||
    </ProjectReference>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
</Project>
 | 
			
		||||
		Reference in New Issue
	
	Block a user