Inheritance: Timer
Example #1
0
 void CreateMenu()
 {
     additem = new MenuItem (Catalog.GetString ("Add period"));
     additem.Activated += (sender, e) => {
         string periodname = Config.GUIToolkit.QueryMessage (Catalog.GetString ("Period name"), null,
                                 (project.Periods.Count + 1).ToString (),
                                 this);
         if (periodname != null) {
             project.Dashboard.GamePeriods.Add (periodname);
             Period p = new Period { Name = periodname };
             p.Nodes.Add (new TimeNode {
                 Name = periodname,
                 Start = new Time { TotalSeconds = time.TotalSeconds - 10 },
                 Stop = new Time { TotalSeconds = time.TotalSeconds + 10 }
             });
             project.Periods.Add (p);
             if (timertimeline != null) {
                 timertimeline.AddTimer (p);
             }
         }
     };
     Add (additem);
     delitem = new MenuItem (Catalog.GetString ("Delete period"));
     delitem.Activated += (sender, e) => {
         project.Periods.Remove (timer as Period);
         if (timertimeline != null) {
             timertimeline.RemoveTimer (timer);
         }
     };
     Add (delitem);
     ShowAll ();
 }
Example #2
0
        public void TestResyncEvents()
        {
            ProjectLongoMatch p = CreateProject (false);
            int offset1 = 100, offset2 = 120, offset3 = 150;
            Period period;
            List<Period> syncedPeriods;

            period = new Period ();
            period.Nodes.Add (new TimeNode { Start = new Time (0),
                Stop = new Time (3000)
            });
            p.Periods.Add (period);
            period = new Period ();
            period.Nodes.Add (new TimeNode { Start = new Time (3001),
                Stop = new Time (6000)
            });
            p.Periods.Add (period);
            period = new Period ();
            period.Nodes.Add (new TimeNode { Start = new Time (6001),
                Stop = new Time (6500)
            });
            p.Periods.Add (period);

            /* Test with a list of periods that don't match */
            Assert.Throws<IndexOutOfRangeException> (
                delegate {
                    p.ResyncEvents (new List<Period> ());
                });

            syncedPeriods = new List<Period> ();
            period = new Period ();
            period.Nodes.Add (new TimeNode {
                Start = new Time (0 + offset1),
                Stop = new Time (3000 + offset1)
            });
            syncedPeriods.Add (period);
            period = new Period ();
            period.Nodes.Add (new TimeNode {
                Start = new Time (3001 + offset2),
                Stop = new Time (6000 + offset2)
            });
            syncedPeriods.Add (period);
            period = new Period ();
            period.Nodes.Add (new TimeNode {
                Start = new Time (6001 + offset3),
                Stop = new Time (6500 + offset3)
            });
            syncedPeriods.Add (period);

            /* 1st Period */
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (0) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (1500) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (3000) });
            /* 2nd Period */
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (3001) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (4500) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (6000) });
            /* 3nd Period */
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (6001) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (6200) });
            p.Timeline.Add (new TimelineEventLongoMatch { EventTime = new Time (6500) });

            IList<TimelineEvent> oldTimeline = p.Timeline.Clone ();

            p.ResyncEvents (syncedPeriods);
            Assert.AreEqual (oldTimeline [0].EventTime + offset1, p.Timeline [0].EventTime);
            Assert.AreEqual (oldTimeline [1].EventTime + offset1, p.Timeline [1].EventTime);
            Assert.AreEqual (oldTimeline [2].EventTime + offset1, p.Timeline [2].EventTime);

            Assert.AreEqual (oldTimeline [3].EventTime + offset2, p.Timeline [3].EventTime);
            Assert.AreEqual (oldTimeline [4].EventTime + offset2, p.Timeline [4].EventTime);
            Assert.AreEqual (oldTimeline [5].EventTime + offset2, p.Timeline [5].EventTime);

            Assert.AreEqual (oldTimeline [6].EventTime + offset3, p.Timeline [6].EventTime);
            Assert.AreEqual (oldTimeline [7].EventTime + offset3, p.Timeline [7].EventTime);
            Assert.AreEqual (oldTimeline [8].EventTime + offset3, p.Timeline [8].EventTime);
        }
Example #3
0
 public void FilterPeriod(Period period, bool visible)
 {
     if (visible) {
         if (!periodsFilter.Contains (period))
             periodsFilter.Add (period);
     } else {
         if (periodsFilter.Contains (period))
             periodsFilter.Remove (period);
     }
     Update ();
 }
Example #4
0
 void Reset()
 {
     currentPeriod = null;
     currentTimeNode = null;
     currentPeriodStart = DateTime.UtcNow;
     accumTime = new Time (0);
     Capturing = false;
     Capturer = null;
     recbutton.Visible = true;
     stopbutton.Visible = false;
     pausebutton.Visible = false;
     savebutton.Visible = false;
     cancelbutton.Visible = true;
     resumebutton.Visible = false;
     lasteventbox.Visible = false;
 }
Example #5
0
        public void StopPeriod()
        {
            if (currentPeriod == null) {
                string msg = Catalog.GetString ("Period recording not started");
                Config.GUIToolkit.WarningMessage (msg, this);
                return;
            }

            GLib.Source.Remove (timeoutID);
            currentPeriod.Stop (CurrentCaptureTime);
            accumTime = CurrentCaptureTime;
            Log.Debug ("Stop period stop=", accumTime.ToMSecondsString ());
            currentTimeNode = null;
            currentPeriod = null;
            recbutton.Visible = true;
            pausebutton.Visible = resumebutton.Visible = stopbutton.Visible = false;
            if (Capturer != null && Capturing) {
                Capturer.TogglePause ();
            }
            Capturing = false;
        }
Example #6
0
        public void StartPeriod()
        {
            string periodName;

            if (currentPeriod != null) {
                string msg = Catalog.GetString ("Period recording already started");
                Config.GUIToolkit.WarningMessage (msg, this);
                return;
            }
            recbutton.Visible = false;
            pausebutton.Visible = savebutton.Visible = stopbutton.Visible = true;

            if (PeriodsNames != null && PeriodsNames.Count > Periods.Count) {
                periodName = PeriodsNames [Periods.Count];
            } else {
                periodName = (Periods.Count + 1).ToString ();
            }
            currentPeriod = new Period { Name = periodName };

            currentTimeNode = currentPeriod.Start (accumTime, periodName);
            currentTimeNode.Stop = currentTimeNode.Start;
            currentPeriodStart = DateTime.UtcNow;
            timeoutID = GLib.Timeout.Add (20, UpdateTime);
            if (Capturer != null) {
                if (Periods.Count == 0) {
                    Capturer.Start ();
                } else {
                    Capturer.TogglePause ();
                }
            }
            periodlabel.Markup = currentPeriod.Name;
            Capturing = true;
            Periods.Add (currentPeriod);
            Log.Debug ("Start new period start=", currentTimeNode.Start.ToMSecondsString ());
        }