示例#1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            CurrentTime = CurrentTime.Subtract(Timer.Interval);

            TimerTextBox.Text = CurrentTime.ToString();

            if (CurrentTime.Equals(TimeSpan.Zero))
            {
                Timer.Stop();

                this.Activate();

                String currentTimeString = DateTime.Now.ToString("HH:mm:ss");

                this.NotifyIcon.ShowBalloonTip(5000, "Time is up!", $"@ {currentTimeString}", WinForms.ToolTipIcon.Info);

                MessageBox.Show(this, $"Time is up!{Environment.NewLine}@ {currentTimeString}",
                                this.Title, MessageBoxButton.OK, MessageBoxImage.Information);

                TimerTextBox.Text = OriginalTime.ToString();

                TimerButtonImage.Source = this.FindResource("TimerStartIcon") as DrawingImage;

                TimerTextBox.IsReadOnly = Timer.IsEnabled;
                TaskTextBox.IsReadOnly  = Timer.IsEnabled;
            }
        }
示例#2
0
        /// <summary>
        /// Compares two heartbeat responses for equality.
        /// </summary>
        /// <param name="HeartbeatResponse">A heartbeat response to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(HeartbeatResponse HeartbeatResponse)
        {
            if (HeartbeatResponse is null)
            {
                return(false);
            }

            return(CurrentTime.Equals(HeartbeatResponse.CurrentTime));
        }
示例#3
0
 /// <summary>
 /// 时间更新。
 /// </summary>
 /// <param name="time"></param>
 public void Update(Time time)
 {
     //Upadat previous epoch
     if (!CurrentTime.Equals(time))
     {
         this.PreviousTime = CurrentTime;
         this.CurrentTime  = time;
     }
 }
示例#4
0
        /// <summary>
        /// Compares two boot notification responses for equality.
        /// </summary>
        /// <param name="BootNotificationResponse">A boot notification response to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(BootNotificationResponse BootNotificationResponse)
        {
            if (BootNotificationResponse is null)
            {
                return(false);
            }

            return(Status.Equals(BootNotificationResponse.Status) &&
                   CurrentTime.Equals(BootNotificationResponse.CurrentTime) &&
                   HeartbeatInterval.Equals(BootNotificationResponse.HeartbeatInterval));
        }
        /// <summary>
        /// Compares two boot notification responses for equality.
        /// </summary>
        /// <param name="BootNotificationResponse">A boot notification response to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(BootNotificationResponse BootNotificationResponse)
        {
            if ((Object)BootNotificationResponse == null)
            {
                return(false);
            }

            return(Status.Equals(BootNotificationResponse.Status) &&
                   CurrentTime.Equals(BootNotificationResponse.CurrentTime) &&
                   Interval.Equals(BootNotificationResponse.Interval));
        }
            /// <summary>
            /// Compares two Heartbeat responses for equality.
            /// </summary>
            /// <param name="HeartbeatResponse">A Heartbeat response to compare with.</param>
            /// <returns>True if both match; False otherwise.</returns>
            public override Boolean Equals(HeartbeatResponse HeartbeatResponse)
            {
                if ((Object)HeartbeatResponse == null)
                {
                    return(false);
                }

                return(HeartbeatPeriod.Equals(HeartbeatResponse.HeartbeatPeriod) &&
                       CurrentTime.Equals(HeartbeatResponse.CurrentTime) &&
                       TransactionId.Equals(HeartbeatResponse.TransactionId) &&
                       RequestStatus.Equals(HeartbeatResponse.RequestStatus));
            }
示例#7
0
 public bool Equals(ScoreboardData other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(CurrentTime.Equals(other.CurrentTime) && CurrentScore.SequenceEqual(other.CurrentScore) &&
            ScoresByPeriod.SequenceEqual(other.ScoresByPeriod));
 }
示例#8
0
        /// <summary>
        /// Compares two boot notification responses for equality.
        /// </summary>
        /// <param name="BootNotificationResponse">A boot notification response to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public override Boolean Equals(BootNotificationResponse BootNotificationResponse)
        {
            if (BootNotificationResponse is null)
            {
                return(false);
            }

            return(Status.Equals(BootNotificationResponse.Status) &&
                   CurrentTime.Equals(BootNotificationResponse.CurrentTime) &&
                   Interval.Equals(BootNotificationResponse.Interval) &&

                   ((StatusInfo == null && BootNotificationResponse.StatusInfo == null) ||
                    (StatusInfo != null && BootNotificationResponse.StatusInfo != null && StatusInfo.Equals(BootNotificationResponse.StatusInfo))) &&

                   ((CustomData == null && BootNotificationResponse.CustomData == null) ||
                    (CustomData != null && BootNotificationResponse.CustomData != null && CustomData.Equals(BootNotificationResponse.CustomData))));
        }
        //Updates statistics
        public override async void Update()
        {
            CurrentTime = CurrentTime.AddSeconds(1);
            var distancesTravelled = DroneController.DistanceTravelled.Values.ToList();
            var speeds             = DroneController.Speeds.Values.ToList();
            await Task.Run(() =>
            {
                Statistic.RunTimeSeconds           = (int)CurrentTime.Subtract(Statistic.StartRunTime).TotalSeconds;
                Statistic.DroneCount               = !DroneController.Drones.IsNullOrEmpty() ? DroneController.Drones.Count : 0;
                Statistic.AverageDistanceTravelled = distancesTravelled.IsNullOrEmpty() ? 0 : distancesTravelled.Average();
                Statistic.AverageDroneSpeed        = speeds.IsNullOrEmpty() ? 0 : speeds.Average();
            });

            if (!CurrentTime.Equals(Statistic.CurrentTimeInRun.AddMinutes(5)))
            {
                return;
            }
            Statistic.CurrentTimeInRun = CurrentTime;
            RecordStatistics(false);
        }