update status label if state changes
This commit is contained in:
		| @ -1,5 +1,6 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Data; | ||||
| using System.Diagnostics; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| @ -26,11 +27,28 @@ public static class SMvcr | ||||
|  | ||||
|     public static event VCREventHandler evFastforwardbutton; | ||||
|  | ||||
|  | ||||
|     public delegate void StatusLabelHandler(StatusEventArgs e); | ||||
|  | ||||
|     public static event StatusLabelHandler evUpdateStatus; | ||||
|  | ||||
|  | ||||
|     public static void initSMvcr() | ||||
|     { | ||||
|         setState(new SvcrStandBy()); | ||||
|     } | ||||
|  | ||||
|     public static void triggerUpdateLabel(string txt) | ||||
|     { | ||||
|         var e = new StatusEventArgs(txt); | ||||
|         //trigger handler | ||||
|  | ||||
|         if (evUpdateStatus != null) | ||||
|         { | ||||
|             evUpdateStatus(e); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static void setState(StateVCR e) | ||||
|     { | ||||
|         _concreteState = null; | ||||
| @ -96,6 +114,8 @@ public class SvcrStandBy : StateVCR | ||||
|     { | ||||
|         Debug.Print("Standby\n"); | ||||
|  | ||||
|         SMvcr.triggerUpdateLabel("Standby"); | ||||
|  | ||||
|         SMvcr.evRecordbutton += evRecordbutton; | ||||
|         SMvcr.evPlaybutton += evPlaybutton; | ||||
|         SMvcr.evRewindbutton += evRewindbutton; | ||||
| @ -151,6 +171,8 @@ public class SvcrPlay : StateVCR | ||||
|     { | ||||
|         Debug.Print("Play\n"); | ||||
|  | ||||
|         SMvcr.triggerUpdateLabel("Play"); | ||||
|  | ||||
|         SMvcr.evStopbutton += evStopbutton; | ||||
|         SMvcr.evEndtape += evEndtape; | ||||
|         SMvcr.evRewindbutton += evRewindbutton; | ||||
| @ -216,6 +238,8 @@ public class SvcrRewind : StateVCR | ||||
|     { | ||||
|         Debug.Print("Rewind\n"); | ||||
|  | ||||
|         SMvcr.triggerUpdateLabel("Rewind"); | ||||
|  | ||||
|         SMvcr.evStopbutton += evStopbutton; | ||||
|         SMvcr.evBeginningtape += evBeginningtape; | ||||
|         SMvcr.evPlaybutton += evPlaybutton; | ||||
| @ -281,6 +305,8 @@ public class SvcrFastForward : StateVCR | ||||
|     { | ||||
|         Debug.Print("FastForward\n"); | ||||
|  | ||||
|         SMvcr.triggerUpdateLabel("FastForward"); | ||||
|  | ||||
|         SMvcr.evStopbutton += evStopbutton; | ||||
|         SMvcr.evEndtape += evEndtape; | ||||
|         SMvcr.evRewindbutton += evRewindbutton; | ||||
| @ -336,6 +362,8 @@ public class SvcrRecord : StateVCR | ||||
|     { | ||||
|         Debug.Print("Record\n"); | ||||
|  | ||||
|         SMvcr.triggerUpdateLabel("Record"); | ||||
|  | ||||
|         SMvcr.evStopbutton += evStopbutton; | ||||
|         SMvcr.evEndtape += evEndtape; | ||||
|     } | ||||
| @ -375,4 +403,14 @@ public class SvcrRecord : StateVCR | ||||
|     public override void evFastforwardbutton() | ||||
|     { | ||||
|     } | ||||
| } | ||||
|  | ||||
| public class StatusEventArgs | ||||
| { | ||||
|     public StatusEventArgs(string txt) | ||||
|     { | ||||
|         Text = txt; | ||||
|     } | ||||
|  | ||||
|     public string Text { get; private set; } | ||||
| } | ||||
| @ -25,13 +25,16 @@ namespace winVCR | ||||
|             SMtape.initSMtape(); | ||||
|             SMvcr.initSMvcr(); | ||||
|  | ||||
|             SMvcr.evUpdateStatus += setLabelText; | ||||
|  | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public void setLabelText(string txt) | ||||
|  | ||||
|  | ||||
|         public void setLabelText(StatusEventArgs e) | ||||
|         { | ||||
|             statusLabel.Text = txt; | ||||
|             statusLabel.Text = e.Text; | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user