finished states for vcr
This commit is contained in:
parent
ab18b92b3d
commit
6953c604f3
|
@ -1,77 +1,347 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
public class SMvcr
|
||||
public static class SMvcr
|
||||
{
|
||||
private string _labelText;
|
||||
|
||||
private StateVCR _concreteState;
|
||||
private static StateVCR _concreteState;
|
||||
|
||||
public SMvcr()
|
||||
public delegate void VCREventHandler();
|
||||
|
||||
public static event VCREventHandler evStopbutton;
|
||||
|
||||
public static event VCREventHandler evEndtape;
|
||||
|
||||
public static event VCREventHandler evRecordbutton;
|
||||
|
||||
public static event VCREventHandler evPlaybutton;
|
||||
|
||||
public static event VCREventHandler evBeginningtape;
|
||||
|
||||
public static event VCREventHandler evRewindbutton;
|
||||
|
||||
public static event VCREventHandler evFastforwardbutton;
|
||||
|
||||
public static void initSMvcr()
|
||||
{
|
||||
setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public void setState(StateVCR e)
|
||||
public static void setState(StateVCR e)
|
||||
{
|
||||
_concreteState = null;
|
||||
_concreteState = e;
|
||||
}
|
||||
|
||||
public string getLabelText()
|
||||
{
|
||||
return _labelText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public abstract class StateVCR
|
||||
{
|
||||
public abstract void setStateText();
|
||||
public abstract void evStopbutton();
|
||||
public abstract void evEndtape();
|
||||
public abstract void evRecordbutton();
|
||||
public abstract void evPlaybutton();
|
||||
public abstract void evBeginningtape();
|
||||
public abstract void evRewindbutton();
|
||||
public abstract void evFastforwardbutton();
|
||||
}
|
||||
|
||||
public class SvcrStandBy : StateVCR
|
||||
{
|
||||
public override void setStateText()
|
||||
|
||||
public SvcrStandBy()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Debug.Print("Standby\n");
|
||||
|
||||
SMvcr.evRecordbutton += evRecordbutton;
|
||||
SMvcr.evPlaybutton += evPlaybutton;
|
||||
SMvcr.evRewindbutton += evRewindbutton;
|
||||
|
||||
}
|
||||
public override void evStopbutton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evEndtape()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evRecordbutton()
|
||||
{
|
||||
SMvcr.evRecordbutton -= evRecordbutton;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrRecord());
|
||||
}
|
||||
|
||||
public override void evPlaybutton()
|
||||
{
|
||||
SMvcr.evRecordbutton -= evRecordbutton;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrPlay());
|
||||
}
|
||||
|
||||
public override void evBeginningtape()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evRewindbutton()
|
||||
{
|
||||
SMvcr.evRecordbutton -= evRecordbutton;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrRewind());
|
||||
}
|
||||
|
||||
public override void evFastforwardbutton()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SvcrPlay : StateVCR
|
||||
{
|
||||
public override void setStateText()
|
||||
public SvcrPlay()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Debug.Print("Play\n");
|
||||
|
||||
SMvcr.evStopbutton += evStopbutton;
|
||||
SMvcr.evEndtape += evEndtape;
|
||||
SMvcr.evRewindbutton += evRewindbutton;
|
||||
SMvcr.evFastforwardbutton += evFastforwardbutton;
|
||||
}
|
||||
public override void evStopbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evEndtape()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evRecordbutton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evPlaybutton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evBeginningtape()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void evRewindbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrRewind());
|
||||
}
|
||||
|
||||
public override void evFastforwardbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrFastForward());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SvcrRewind : StateVCR
|
||||
{
|
||||
public override void setStateText()
|
||||
|
||||
public SvcrRewind()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Debug.Print("Rewind\n");
|
||||
|
||||
SMvcr.evStopbutton += evStopbutton;
|
||||
SMvcr.evBeginningtape += evBeginningtape;
|
||||
SMvcr.evPlaybutton += evPlaybutton;
|
||||
SMvcr.evFastforwardbutton += evFastforwardbutton;
|
||||
}
|
||||
public override void evStopbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evBeginningtape -= evBeginningtape;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evEndtape()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evRecordbutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evPlaybutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evBeginningtape -= evBeginningtape;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrPlay());
|
||||
}
|
||||
|
||||
public override void evBeginningtape()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evBeginningtape -= evBeginningtape;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evRewindbutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evFastforwardbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evBeginningtape -= evBeginningtape;
|
||||
SMvcr.evPlaybutton -= evPlaybutton;
|
||||
SMvcr.evFastforwardbutton -= evFastforwardbutton;
|
||||
|
||||
SMvcr.setState(new SvcrFastForward());
|
||||
}
|
||||
}
|
||||
|
||||
public class SvcrFastForward : StateVCR
|
||||
{
|
||||
public override void setStateText()
|
||||
public SvcrFastForward()
|
||||
{
|
||||
Debug.Print("FastForward\n");
|
||||
|
||||
SMvcr.evStopbutton += evStopbutton;
|
||||
SMvcr.evEndtape += evEndtape;
|
||||
SMvcr.evRewindbutton += evRewindbutton;
|
||||
}
|
||||
public override void evStopbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evEndtape()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evRecordbutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evPlaybutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evBeginningtape()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evRewindbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
SMvcr.evRewindbutton -= evRewindbutton;
|
||||
|
||||
SMvcr.setState(new SvcrRewind());
|
||||
}
|
||||
|
||||
public override void evFastforwardbutton()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SvcrRecord : StateVCR
|
||||
{
|
||||
public override void setStateText()
|
||||
public SvcrRecord()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Debug.Print("Record\n");
|
||||
|
||||
SMvcr.evStopbutton += evStopbutton;
|
||||
SMvcr.evEndtape += evEndtape;
|
||||
}
|
||||
}
|
||||
public override void evStopbutton()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evEndtape()
|
||||
{
|
||||
SMvcr.evStopbutton -= evStopbutton;
|
||||
SMvcr.evEndtape -= evEndtape;
|
||||
|
||||
SMvcr.setState(new SvcrStandBy());
|
||||
}
|
||||
|
||||
public override void evRecordbutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evPlaybutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evBeginningtape()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evRewindbutton()
|
||||
{
|
||||
}
|
||||
|
||||
public override void evFastforwardbutton()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue