protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (Time is not null && !string.IsNullOrEmpty(e.PropertyName) && e.HasPropertyChanged(e.PropertyName)) { if (Is24Hour) { if (AmPm == Meridiem.PM) { if (Time.Value.Hours < 12) { var newTimeValue = new TimeSpan(Time.Value.Hours + 12, Time.Value.Minutes, Time.Value.Seconds); TimeValueString = newTimeValue.ToString(); } else { var newTimeValue = new TimeSpan(Time.Value.Hours - 12, Time.Value.Minutes, Time.Value.Seconds); TimeValueString = newTimeValue.ToString(); } } else { TimeValueString = Time.Value.ToString(); } } else { TimeValueString = Time.Value.ToString() + " " + AmPm.ToString(); } }
public string Message() { var ampm = new AmPm(); var format = new GreetingFormat(_username, ampm); return(format.Text()); }
public override void Draw(Graphics drawer, Bitmap[] images, WatchState state) { AmPm?.Draw(drawer, images, state); var hours = AmPm == null ? state.Time.Hour : state.Time.Hour % 12; var drawingOrder = DrawingOrder ?? 0x1234; foreach (var position in DrawingOrderIterator.Iterate(drawingOrder)) { switch (position) { case DrawingOrderPosition.HourTens: Hours?.Tens?.Draw(drawer, images, hours % 100 / 10); break; case DrawingOrderPosition.HourOnes: Hours?.Ones?.Draw(drawer, images, hours % 10); break; case DrawingOrderPosition.MinuteTens: Minutes?.Tens?.Draw(drawer, images, state.Time.Minute % 100 / 10); break; case DrawingOrderPosition.MinuteOnes: Minutes?.Ones?.Draw(drawer, images, state.Time.Minute % 10); break; default: Logger.Warn("Not supported element {0} in DrawingOrder value", position); break; } } Seconds?.Draw(drawer, images, state.Time.Second); }
public GreetingFormat(string username, AmPm ampm) { this._username = username; this._message = ampm.Message(); }