first events
This commit is contained in:
parent
5cfbf8d0a5
commit
b8f984edd9
Binary file not shown.
Binary file not shown.
@ -71,6 +71,17 @@ namespace WindowsFormsApp01
|
|||||||
_number = (int) res;
|
_number = (int) res;
|
||||||
|
|
||||||
label1.Text = "Ergebnis: " + res.ToString();
|
label1.Text = "Ergebnis: " + res.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
var f = new CalcEventArgs(res);
|
||||||
|
//trigger handler
|
||||||
|
|
||||||
|
// if (CalcFinished != null)
|
||||||
|
// {
|
||||||
|
CalcFinished(f);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,6 +236,9 @@ namespace WindowsFormsApp01
|
|||||||
public static event CalcEventHandler CalcFinished;
|
public static event CalcEventHandler CalcFinished;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void CalcIt()
|
public static void CalcIt()
|
||||||
{
|
{
|
||||||
int res = DateTime.Now.Second;
|
int res = DateTime.Now.Second;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,29 +1,122 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using VCRlogic;
|
||||||
|
|
||||||
|
namespace VCRlogic
|
||||||
public class SMtape
|
|
||||||
{
|
{
|
||||||
private SMtape _concreteState;
|
public static class SMtape
|
||||||
|
|
||||||
public 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 abstract class StateTape
|
||||||
|
|
||||||
|
|
||||||
public class SMtapeNoTapeIn : SMtape
|
|
||||||
{
|
{
|
||||||
|
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 string _labelText;
|
||||||
|
|
||||||
private SMvcr _concreteState;
|
private StateVCR _concreteState;
|
||||||
|
|
||||||
|
public SMvcr()
|
||||||
|
{
|
||||||
|
setState(new SvcrStandBy());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(StateVCR e)
|
||||||
|
{
|
||||||
|
_concreteState = e;
|
||||||
|
}
|
||||||
|
|
||||||
public string getLabelText()
|
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.statusLabel = new System.Windows.Forms.Label();
|
||||||
this.btnInsertTape = new System.Windows.Forms.Button();
|
this.btnInsertTape = new System.Windows.Forms.Button();
|
||||||
this.btnEjectTape = 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();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -93,9 +95,9 @@
|
|||||||
//
|
//
|
||||||
// btnInsertTape
|
// 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.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.TabIndex = 6;
|
||||||
this.btnInsertTape.Text = "Insert Tape";
|
this.btnInsertTape.Text = "Insert Tape";
|
||||||
this.btnInsertTape.UseVisualStyleBackColor = true;
|
this.btnInsertTape.UseVisualStyleBackColor = true;
|
||||||
@ -103,19 +105,41 @@
|
|||||||
//
|
//
|
||||||
// btnEjectTape
|
// 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.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.TabIndex = 7;
|
||||||
this.btnEjectTape.Text = "Eject Tape";
|
this.btnEjectTape.Text = "Eject Tape";
|
||||||
this.btnEjectTape.UseVisualStyleBackColor = true;
|
this.btnEjectTape.UseVisualStyleBackColor = true;
|
||||||
this.btnEjectTape.Click += new System.EventHandler(this.BtnEjectTape_Click);
|
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
|
// 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.btnNotEndTape);
|
||||||
|
this.Controls.Add(this.btnEndTape);
|
||||||
this.Controls.Add(this.btnEjectTape);
|
this.Controls.Add(this.btnEjectTape);
|
||||||
this.Controls.Add(this.btnInsertTape);
|
this.Controls.Add(this.btnInsertTape);
|
||||||
this.Controls.Add(this.statusLabel);
|
this.Controls.Add(this.statusLabel);
|
||||||
@ -141,6 +165,8 @@
|
|||||||
private System.Windows.Forms.Label statusLabel;
|
private System.Windows.Forms.Label statusLabel;
|
||||||
private System.Windows.Forms.Button btnInsertTape;
|
private System.Windows.Forms.Button btnInsertTape;
|
||||||
private System.Windows.Forms.Button btnEjectTape;
|
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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -8,15 +9,36 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using VCRlogic;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace winVCR
|
namespace winVCR
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
SMtape.initSMtape();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLabelText(string txt)
|
||||||
|
{
|
||||||
|
statusLabel.Text = txt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void BtnPlay_Click(object sender, EventArgs e)
|
private void BtnPlay_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -35,10 +57,20 @@ namespace winVCR
|
|||||||
|
|
||||||
private void BtnInsertTape_Click(object sender, EventArgs e)
|
private void BtnInsertTape_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
SMtape.insertTape();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnEjectTape_Click(object sender, EventArgs e)
|
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>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</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" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user