private void OnTimeChanged( object s, EventArgs e) { if (enabled) { Mp4FileAccessRecorder recorder = (Mp4FileAccessRecorder)this.recorder; SimpleTime now = new SimpleTime(System.DateTime.Now); periods.ForEach(delegate(SimpleTimePeriod p) { if (now.Equals(p.Start)) { recorder.Initialize(p.ToString()); recorder.Start(); if (pic != null) { recorder.OnImageCaptured = new ImageDelegate(delegate(Bitmap bitmap) { pic.BackgroundImage = bitmap; }); } } else if (now.Equals(p.End)) { recorder.Stop(); if (pic != null) { pic.BackgroundImage = null; } } }); } }
public MainForm() { InitializeComponent(); controller.Enabled = true; controller.Display = this.pictureBox1; SimpleTime now = new SimpleTime(System.DateTime.Now); int t = now.TotalSecond; controller.AddTimePeriod(new SimpleTimePeriod(new SimpleTime(t+5), new SimpleTime(t+65), "1")); controller.AddTimePeriod(new SimpleTimePeriod(new SimpleTime(t+70), new SimpleTime(t+200), "2")); controller.AddTimePeriod(new SimpleTimePeriod(new SimpleTime(t+201), new SimpleTime(t+300), "3")); }
public bool isBetween(SimpleTime t1, SimpleTime t2) { int s1 = t1.TotalSecond; int s2 = t2.TotalSecond; int s = this.TotalSecond; return (s1 <= s && s <= s2) || (s1 >= s && s >= s2); }
public bool isBefore(SimpleTime anotherTime) { return this.TotalSecond <= anotherTime.TotalSecond; }
public SimpleTime getAfter(SimpleTime time) { return new SimpleTime(this.TotalSecond + time.TotalSecond); }
public SimpleTime getBefore(SimpleTime time) { return new SimpleTime(this.TotalSecond - time.TotalSecond); }
public SimpleTimePeriod(SimpleTime start, SimpleTime end, String name) : this(start, end){ this.name = name; }
public SimpleTimePeriod(SimpleTime start, SimpleTime end) { this.end = end; this.start = start; }