コード例 #1
0
        public override void OnDrawDayHeaderBackground(CalendarRendererDayEventArgs e)
        {
            bool  today = e.Day.Date.Date.Equals(DateTime.Today.Date);
            Brush b     = new SolidColorBrush(today ? ColorTable.TodayTopBackground : ColorTable.DayHeaderBackground);

            e.DrawingContext.DrawRectangle(b, new Pen(), e.Day.HeaderBounds);

            base.OnDrawDayHeaderBackground(e);
        }
コード例 #2
0
        public override void OnDrawDayTop(CalendarRendererDayEventArgs e)
        {
            bool  s = e.Day.DayTop.Selected;
            Brush b = new SolidColorBrush(s ? ColorTable.DayTopSelectedBackground : ColorTable.DayTopBackground)
                      e.DrawingContext.DrawRectangle(b, new Pen(), e.Day.DayTop.Bounds);

            Pen p = new Pen(s ? new SolidColorBrush(ColorTable.DayTopSelectedBorder) : new SolidColorBrush(ColorTable.DayTopBorder), 1);

            e.DrawingContext.DrawRectangle(new SolidColorBrush(), p, e.Day.DayTop.Bounds);


            base.OnDrawDayTop(e);
        }
コード例 #3
0
        public override void OnDrawDayHeaderBackground(CalendarRendererDayEventArgs e)
        {
            Rect r = e.Day.HeaderBounds;

            if (e.Day.Date == DateTime.Today)
            {
                GlossyRect(e.DrawingContext, e.Day.HeaderBounds, TodayA, TodayB, TodayC, TodayD);
            }
            else
            {
                GlossyRect(e.DrawingContext, e.Day.HeaderBounds, HeaderA, HeaderB, HeaderC, HeaderD);
            }

            if (e.Calendar.DaysMode == CalendarDaysMode.Short)
            {
                Pen p = new Pen(new SolidColorBrush(ColorTable.DayBorder), 1);

                e.DrawingContext.DrawLine(p, new Point(r.Left, r.Top), new Point(r.Right, r.Top));
                e.DrawingContext.DrawLine(p, new Point(r.Left, r.Bottom), new Point(r.Right, r.Bottom));
            }
        }
コード例 #4
0
        public override void OnDrawDayOverflowEnd(CalendarRendererDayEventArgs e)
        {
            using (Path path = new Path())
            {
                int top = e.Day.OverflowEndBounds.Top + e.Day.OverflowEndBounds.Height / 2;
                path.AddPolygon(new Point[] {
                    new Point(e.Day.OverflowEndBounds.Left, top),
                    new Point(e.Day.OverflowEndBounds.Right, top),
                    new Point(e.Day.OverflowEndBounds.Left + e.Day.OverflowEndBounds.Width / 2, e.Day.OverflowEndBounds.Bottom),
                });

                using (Brush b = new SolidColorBrush(e.Day.OverflowEndSelected ? ColorTable.DayOverflowSelectedBackground : ColorTable.DayOverflowBackground))
                {
                    e.DrawingContext.FillPath(b, path);
                }

                using (Pen p = new Pen(ColorTable.DayOverflowBorder))
                {
                    e.DrawingContext.DrawPath(p, path);
                }
            }
        }
コード例 #5
0
        public override void OnDrawDayBorder(CalendarRendererDayEventArgs e)
        {
            base.OnDrawDayBorder(e);

            Rect r     = e.Day.Bounds;
            bool today = e.Day.Date.Date.Equals(DateTime.Today.Date);
            Pen  p     = new Pen(today ? new SolidColorBrush(ColorTable.TodayBorder) : new SolidColorBrush(ColorTable.DayBorder), today ? 2 : 1);

            if (e.Calendar.DaysMode == CalendarDaysMode.Short)
            {
                e.DrawingContext.DrawLine(p, new Point(r.Right, r.Top), new Point(r.Right, r.Bottom));
                e.DrawingContext.DrawLine(p, new Point(r.Left, r.Bottom), new Point(r.Right, r.Bottom));

                if (e.Day.Date.DayOfWeek == DayOfWeek.Sunday || today)
                {
                    e.DrawingContext.DrawLine(p, new Point(r.Left, r.Top), new Point(r.Left, r.Bottom));
                }
            }
            else
            {
                e.DrawingContext.DrawRectangle(new SolidColorBrush(), p, r);
            }
        }
コード例 #6
0
        public override void OnDrawDay(CalendarRendererDayEventArgs e)
        {
            Rect r = e.Day.Bounds;

            if (e.Day.Selected)
            {
                Brush b = new SolidColorBrush(ColorTable.DayBackgroundSelected);

                e.DrawingContext.DrawRectangle(b, new Pen(), r);
            }
            else if (e.Day.Date.Month % 2 == 0)
            {
                Brush b = new SolidColorBrush(ColorTable.DayBackgroundEven);
                e.DrawingContext.DrawRectangle(b, new Pen(), r);
            }
            else
            {
                Brush b = new SolidColorBrush(ColorTable.DayBackgroundOdd);
                e.DrawingContext.DrawRectangle(b, new Pen(), r);
            }

            base.OnDrawDay(e);
        }