public bool AddPhase(string name)
        {
            try
            {
                var phase = new MissionPhase(name)
                {
                    ID = Guid.NewGuid().ToString("D")
                };

                if (PhaseList.Count > 0)
                {
                    var lastTimeExtent = PhaseList.Last().VisibleTimeExtent;

                    phase.VisibleTimeExtent = new TimeExtent(lastTimeExtent.End.AddSeconds(1.0), lastTimeExtent.Offset(new TimeSpan(1, 0, 0)).End);
                }
                else
                {
                    // set default time extent
                    phase.VisibleTimeExtent = new TimeExtent(DateTime.Now, DateTime.Now.AddSeconds(3599));
                }

                PhaseList.Add(phase);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public PhaseViewerVm(IContest contest)
        {
            if (contest == null)
            {
                throw new ArgumentNullException(nameof(contest));
            }

            PhaseList = contest.PhaseList.Select(_ => new PhaseViewItem(_)).ToList();
            contest.NewPhaseLaunch += (sender, phase) => PhaseList.Add(new PhaseViewItem(phase));
            var timer = new DispatcherTimer();

            timer.Tick    += RefreshClock;
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Start();


            WatchNextPhase();

            timer          = new DispatcherTimer();
            timer.Tick    += ChangePhase;
            timer.Interval = TimeSpan.FromSeconds(60);
            timer.Start();
        }