/// <summary> /// This is a component life cycle event that's trigerred when the component is initialized /// We use it to initialize selected time /// </summary> /// <returns>An async Task</returns> protected override async Task OnInitializedAsync() { if (SelectedTime.HasValue) { //if a selected time is supplied, extract hours, minutes and seconds (if they are also not supplied explicitly) from the time to select the active time if (Second == default) { Second = SelectedTime.Value.Seconds; } if (Minute == default) { Minute = SelectedTime.Value.Minutes; } if (Hour == default) { Hour = SelectedTime.Value.Hours; } } else { //if no selected time is provided, set the hours, minutes and seconds to the current time (if they are also not supplied explicitly) if (Second == default) { Second = DateTime.Now.Second; } if (Minute == default) { Minute = DateTime.Now.Minute; } if (Hour == default) { Hour = DateTime.Now.Hour; } } if (Hour > 12) { _mode = TimeMode.PM; Hour -= 12; } else { _mode = TimeMode.AM; } //Set the angle for the set time MinutesDegrees = Minute.ToExactMinsSecsDegrees(); HoursDegrees = Hour.ToExactHourDegrees(MinutesDegrees); _hourBase = Hour; SecondsDegrees = Second.ToExactMinsSecsDegrees(); await base.OnInitializedAsync(); }
/// <summary> /// Trigerred when the minutes hand is being stopped dragging /// </summary> /// <param name="args">The drag event arguments</param> protected void MinutesHand_DragEnd(DragEventArgs args) { //Round the minute angle to multiple of 6 degrees so that minute hand is snapped to a valid number from 0-59 //(Simply said, this will prevent the minute hand to be placed somewhere between the minutes 30 and 31 and will snap it to the nearest one) MinutesDegrees = Minute.ToExactMinsSecsDegrees(); }