コード例 #1
0
        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();
                }
            }
コード例 #2
0
        public string Message()
        {
            var ampm   = new AmPm();
            var format = new GreetingFormat(_username, ampm);

            return(format.Text());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: GreetingFormat.cs プロジェクト: masakura/oop1
 public GreetingFormat(string username, AmPm ampm)
 {
     this._username = username;
     this._message  = ampm.Message();
 }