public ClockActivityRecord(Guid id, Activity activity, Guid dayRecordId, ActivityRecordOrder order, ClockValue value) : base(id, activity, dayRecordId, order) { if (activity.Type != ActivitiesTypes.ClockActivity) { throw new Exception($"Can not create {nameof(ClockActivityRecord)} for activity type other than {ActivitiesTypes.ClockActivity}."); } Value = value; }
public async Task HandleAsync(CreateClockActivityRecord command) { var forActivity = await _activitiesRepository.GetByIdAsync(command.ActivityId); var clock = new ClockValue(command.Hour, command.Minute); var activityRecord = await _activityRecordCreator.CreateAsync(command.Id, forActivity, command.DayRecordId, clock); _activityRecordsRepository.Add(activityRecord); await _lifeLogContext.SaveChangesAsync(); }
public static ZWaveMessage Set(ZWaveNode node, ClockValue value) { List <byte> message = new List <byte> (); message.AddRange(new byte [] { (byte)CommandClass.Clock, (byte)Command.ClockSet }); message.AddRange(value.GetValueBytes()); return(node.SendDataRequest(message.ToArray())); }
public NodeEvent GetEvent(ZWaveNode node, byte[] message) { NodeEvent nodeEvent = null; byte cmdType = message[1]; if ((message.Length > 0) && (cmdType == (byte)Command.ClockReport)) { var clockValue = ClockValue.Parse(message); nodeEvent = new NodeEvent(node, EventParameter.Clock, clockValue, 0); } return(nodeEvent); }
public CountdownUserControl() { InitializeComponent(); isRunning = IsCountdownRunning(); CountdownTimesCollection = new ObservableCollection <StopwatchTimes>(); LoadLapAndSplitData(); App.gDefaultCountdown = GetCountdownDefaultTime(); App.gAlarmSetting = GetCountdownAlarmSetting(); lastCountdownValue = GetLastCountdownValue(); if (lastCountdownValue == string.Empty || lastCountdownValue == "00:00:00") { ClockValue = App.gDefaultCountdown; } else { ClockValue = TimeSpan.Parse(lastCountdownValue); } ClockValueString = ClockValue.ToString(@"hh\:mm\:ss"); dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); if (isRunning.ToUpper() == "YES") { Mode = AppResources.StartText; Start.Background = new SolidColorBrush(Colors.Green); StartCountdown(); } else { if (lastCountdownValue == string.Empty || lastCountdownValue == "00:00:00" || lastCountdownValue == App.gDefaultCountdown.ToString()) { Mode = AppResources.StartText; Start.Background = new SolidColorBrush(Colors.Green); } else { Mode = AppResources.ResumeText; Start.Background = new SolidColorBrush(Colors.Green); } } this.DataContext = this; }
private void Timer_Tick(object sender, EventArgs e) { if (ClockValue >= new TimeSpan(9, 0, 0)) { if (Mode != AppResources.ExceedText) { MessageBox.Show(AppResources.MaxTimeExceededMessage); Mode = AppResources.ExceedText; } } else if (Mode != AppResources.ExceedText) { ClockValue = App.gStopWatch.Elapsed + _adjustment; ClockValueString = ClockValue.ToString(@"hh\:mm\:ss\.ff"); IS.SaveSetting("Stopwatch-LastValue", ClockValue.ToString()); } }
private void ResetCountdown(bool setClockValueToDefault) { SolidColorBrush mySolidColorBrush = new SolidColorBrush(); dispatcherTimer.Stop(); if (setClockValueToDefault == true) { ClockValue = App.gDefaultCountdown; } // Describes the brush's color using RGB values. Each value has a range of 0-255. mySolidColorBrush.Color = System.Windows.Media.Color.FromArgb(255, 50, 205, 50); ClockValueString = ClockValue.ToString(@"hh\:mm\:ss"); Mode = AppResources.StartText; Start.Background = new SolidColorBrush(Colors.Green); btnCountdownDisplay.Foreground = new SolidColorBrush(mySolidColorBrush.Color); }
private void TimerClickAsync() { try { Dispatcher.BeginInvoke(() => { ClockValue = ClockValue - new TimeSpan(0, 0, 1); ClockValueString = ClockValue.ToString(@"hh\:mm\:ss"); if (ClockValue <= new TimeSpan(0, 0, 5) && ClockValue > new TimeSpan(0, 0, 0)) { btnCountdownDisplay.Foreground = new SolidColorBrush(Colors.Red); PlaySound("Assets/alarm.wav"); } }); if (ClockValue <= new TimeSpan(0, 0, 0)) { Dispatcher.BeginInvoke(() => { PlaySound("Assets/beep.wav"); MessageBoxResult result = MessageBox.Show(AppResources.ElapsedTime + " " + originalCountdownTime, AppResources.CountdownFinished, MessageBoxButton.OK); if (result == MessageBoxResult.OK) { ResetCountdown(true); } }); } IS.SaveSetting("Countdown-LastValue", ClockValue.ToString()); } catch (Exception) { } }
public void ChangeValue(ClockValue newValue) { Value = newValue; }
private void PassMinuteOfTime() { ClockValue = ClockValue.AddMinutes(1); OnMinutePassed?.Invoke(ClockValue); }
private void countdownTime_ValueChanged(object sender, RoutedPropertyChangedEventArgs <TimeSpan> e) { ClockValue = TimeSpan.Parse(ctlCountdownTime.Value.ToString()); ClockValueString = ClockValue.ToString(@"hh\:mm\:ss"); ResetCountdown(false); }