Example #1
0
 /// <summary>
 /// Copies the parameters from the specified <see cref="CalendarRendererEventArgs"/>
 /// </summary>
 /// <param name="original"></param>
 public CalendarRendererEventArgs(CalendarRendererEventArgs original)
 {
     _calendar = original.Calendar;
     _graphics = original.Graphics;
     _clip = original.ClipRectangle;
     _tag = original.Tag;
 }
 public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original)
     : base(original)
 {
     Font = original.Calendar.Font;
     Format |= TextFormatFlags.Default | TextFormatFlags.WordBreak | TextFormatFlags.PreserveGraphicsClipping;// | TextFormatFlags.WordEllipsis;
     TextColor = SystemColors.ControlText;
 }
 public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, Color textColor)
     : this(original)
 {
     Bounds = bounds;
     Text = text;
     TextColor = textColor;
 }
 public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, TextFormatFlags flags)
     : this(original)
 {
     Bounds = bounds;
     Text = text;
     Format |= flags;
 }
        /// <summary>
        /// Paints the name of the day columns when <see cref="Calendar.DaysMode"/> is <see cref="CalendarDaysMode.Short"/>
        /// </summary>
        /// <param name="e">Paint Info</param>
        public virtual void OnDrawDayNameHeaders(CalendarRendererEventArgs e)
        {
            DateTime startDate = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek % 7) + 1 + (int)Calendar.FirstDayOfWeek);

            for (int i = 0; i < DayNameHeaderColumns.Length; i++)
            {
                OnDrawDayNameHeader(new CalendarRendererBoxEventArgs(e,
                    DayNameHeaderColumns[i], 
                    startDate.AddDays(i).ToString("dddd"),
                    TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter));

            }
        }
        /// <summary>
        /// Paints the days on the current calendar view
        /// </summary>
        /// <param name="e">Paint Info</param>
        public virtual void OnDrawDays(CalendarRendererEventArgs e)
        {
            for (int i = 0; i < e.Calendar.Days.Length; i++)
            {
                CalendarDay day = e.Calendar.Days[i];

                e.Tag = day;

                OnDrawDay(new CalendarRendererDayEventArgs(e, 
                    day));
            }
        }
        /// <summary>
        /// Paints the timescale of the calendar
        /// </summary>
        /// <param name="e">Paint info</param>
        public virtual void OnDrawTimeScale(CalendarRendererEventArgs e)
        {
            if (e.Calendar.DaysMode == CalendarDaysMode.Short
                || e.Calendar.Days == null
                || e.Calendar.Days.Length == 0
                || e.Calendar.Days[0].TimeUnits == null
                ) return;

            Font hourFont = new Font(e.Calendar.Font.FontFamily, e.Calendar.Font.Size * (e.Calendar.TimeScale == CalendarTimeScale.SixtyMinutes ? 0.5f : 0.8f));
            Font minuteFont = hourFont; // e.Calendar.Font * 0.8f;
            int hourLeft = TimeScaleBounds.Left;
            int hourWidth = TimeScaleBounds.Left + TimeScaleBounds.Width / 2;
            int minuteLeft = hourLeft + hourWidth;
            int minuteWidth = hourWidth;
            int k = 0;

            for (int i = 0; i < e.Calendar.Days[0].TimeUnits.Length; i++)
            {
                CalendarTimeScaleUnit unit = e.Calendar.Days[0].TimeUnits[i];

                if (!unit.Visible) continue;

                string hours = unit.Hours.ToString("00");
                string minutes = unit.Minutes == 0 ? "00" : string.Empty;

                if (!string.IsNullOrEmpty(minutes))
                {
                    if (hours == "00") hours = "12";

                    CalendarRendererBoxEventArgs hevt = new CalendarRendererBoxEventArgs(e, new Rectangle(hourLeft, unit.Bounds.Top, hourWidth, unit.Bounds.Height), hours, TextFormatFlags.Right);

                    hevt.Font = hourFont;

                    OnDrawTimeScaleHour(hevt);

                    if (k++ == 0 || unit.Hours == 0 || unit.Hours == 12 ) minutes = unit.Date.ToString("tt");

                    CalendarRendererBoxEventArgs mevt = new CalendarRendererBoxEventArgs(e, new Rectangle(minuteLeft, unit.Bounds.Top, minuteWidth, unit.Bounds.Height), minutes, TextFormatFlags.Top | TextFormatFlags.Left);

                    mevt.Font = minuteFont;

                    OnDrawTimeScaleMinutes(mevt);
                }
            }
        }
 /// <summary>
 /// Paints the background of the calendar
 /// </summary>
 /// <param name="e">Paint info</param>
 public virtual void OnDrawBackground(CalendarRendererEventArgs e)
 {
     
 }
Example #9
0
 public override void OnDrawWeekHeaders(CalendarRendererEventArgs e)
 {
     base.OnDrawWeekHeaders(e);
 }
        /// <summary>
        /// Paints the headers of the week rows when <see cref="Calendar.DaysMode"/> is <see cref="CalendarDaysMode.Short"/>
        /// </summary>
        /// <param name="e"></param>
        public virtual void OnDrawWeekHeaders(CalendarRendererEventArgs e)
        {
            if (Calendar.Weeks == null) return;

            for (int i = 0; i < Calendar.Weeks.Length; i++)
            {
                string str = Calendar.Weeks[i].ToStringLarge();
                SizeF sz = e.Graphics.MeasureString(str, e.Calendar.Font);

                if (sz.Width > Calendar.Weeks[i].HeaderBounds.Height)
                {
                    str = Calendar.Weeks[i].ToStringShort();
                }

                OnDrawWeekHeader(new CalendarRendererBoxEventArgs(e,
                    Calendar.Weeks[i].HeaderBounds, str,  TextFormatFlags.Default));
            }
        }
 public CalendarRendererItemEventArgs(CalendarRendererEventArgs original, CalendarItem item)
     : base(original)
 {
     _item = item;
 }
 /// <summary>
 /// Creates a new <see cref="CalendarRendererDayEventArgs"/> object
 /// </summary>
 /// <param name="original">Orignal object to copy basic paramters</param>
 /// <param name="day">Day to render</param>
 public CalendarRendererDayEventArgs(CalendarRendererEventArgs original, CalendarDay day)
     : base(original)
 {
     _day = day;
 }
 public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds)
     : this(original)
 {
     Bounds = bounds;
 }
        /// <summary>
        /// Draws the items of the calendar
        /// </summary>
        /// <param name="e">Event info</param>
        public virtual void OnDrawItems(CalendarRendererEventArgs e)
        {
            Rectangle days = e.Calendar.DaysBodyRectangle; days.Inflate(-1, -1);
            Region oldclip = e.Graphics.Clip;
            bool doClip = e.Calendar.DaysMode == CalendarDaysMode.Expanded;
            bool clipped = false;

            #region Shadows
            foreach (CalendarItem item in e.Calendar.Items)
            {
                clipped = false;

                if (doClip && !item.IsOnDayTop && item.Bounds.Top < days.Top)
                {
                    e.Graphics.SetClip(days, CombineMode.Intersect);
                    clipped = true;
                }

                List<Rectangle> rects = new List<Rectangle>(item.GetAllBounds());

                for (int i = 0; i < rects.Count; i++)
                {
                    CalendarRendererItemBoundsEventArgs evt = new CalendarRendererItemBoundsEventArgs(
                        new CalendarRendererItemEventArgs(e, item),
                        rects[i],
                        i == 0 && !item.IsOpenStart,
                        (i == rects.Count - 1) && !item.IsOpenEnd);
                    OnDrawItemShadow(evt);
                }

                if (clipped)
                    e.Graphics.SetClip(oldclip, CombineMode.Replace);
            } 
            #endregion

            #region Items
            foreach (CalendarItem item in e.Calendar.Items)
            {
                clipped = false;

                if (doClip && !item.IsOnDayTop && item.Bounds.Top < days.Top)
                {
                    e.Graphics.SetClip(days, CombineMode.Intersect);
                    clipped = true;
                }

                OnDrawItem(new CalendarRendererItemEventArgs(e, item));

                if (clipped)
                    e.Graphics.SetClip(oldclip, CombineMode.Replace);
            } 
            #endregion

            #region Borders of selected items
            foreach (CalendarItem item in e.Calendar.Items)
            {
                if (!item.Selected) continue;

                List<Rectangle> rects = new List<Rectangle>(item.GetAllBounds());

                for (int i = 0; i < rects.Count; i++)
                {
                    CalendarRendererItemBoundsEventArgs evt = new CalendarRendererItemBoundsEventArgs(
                        new CalendarRendererItemEventArgs(e, item),
                        rects[i],
                        i == 0 && !item.IsOpenStart,
                        (i == rects.Count - 1) && !item.IsOpenEnd);

                    SmoothingMode smbuff = e.Graphics.SmoothingMode;
                    e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

                    OnDrawItemBorder(evt);

                    e.Graphics.SmoothingMode = smbuff;
                }

            } 
            #endregion
        }
Example #15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            CalendarRendererEventArgs evt = new CalendarRendererEventArgs(this, e.Graphics, e.ClipRectangle);

            ///Calendar background
            Renderer.OnDrawBackground(evt);

            /// Headers / Timescale
            switch (DaysMode)
            {
                case CalendarDaysMode.Short:
                    Renderer.OnDrawDayNameHeaders(evt);
                    Renderer.OnDrawWeekHeaders(evt);
                    break;
                case CalendarDaysMode.Expanded:
                    Renderer.OnDrawTimeScale(evt);
                    break;
                default:
                    throw new NotImplementedException("Current DaysMode not implemented");
            }

            ///Days on view
            Renderer.OnDrawDays(evt);

            ///Items
            Renderer.OnDrawItems(evt);

            ///Overflow marks
            Renderer.OnDrawOverflows(evt);
        }
        /// <summary>
        /// Draws the overflows of days
        /// </summary>
        /// <param name="e"></param>
        public virtual void OnDrawOverflows(CalendarRendererEventArgs e)
        {
            for (int i = 0; i < e.Calendar.Days.Length; i++)
            {
                CalendarDay day = e.Calendar.Days[i];

                if (day.OverflowStart)
                {
                    OnDrawDayOverflowStart(new CalendarRendererDayEventArgs(e, day));
                }

                if(day.OverflowEnd)
                {
                    OnDrawDayOverflowEnd(new CalendarRendererDayEventArgs(e, day));
                }
            }
        }
        public override void OnInitialize(CalendarRendererEventArgs e)
        {
            base.OnInitialize(e);

            //e.Calendar.Font = SystemFonts.CaptionFont;
        }
Example #18
0
        public override void OnDrawTimeScale(CalendarRendererEventArgs e)
        {
            int margin = 5;
            int largeX1 = TimeScaleBounds.Left + margin;
            int largeX2 = TimeScaleBounds.Right - margin;
            int shortX1 = TimeScaleBounds.Left + TimeScaleBounds.Width / 2;
            int shortX2 = largeX2;
            int top = 0;
            Pen p = new Pen(ColorTable.TimeScaleLine);

            for (int i = 0; i < e.Calendar.Days[0].TimeUnits.Length; i++)
            {
                CalendarTimeScaleUnit unit = e.Calendar.Days[0].TimeUnits[i];

                if (!unit.Visible) continue;

                top = unit.Bounds.Top;

                if (unit.Minutes == 0)
                {
                    e.Graphics.DrawLine(p, largeX1, top, largeX2, top);
                }
                else
                {
                    e.Graphics.DrawLine(p, shortX1, top, shortX2, top);
                }
            }

            if (e.Calendar.DaysMode == CalendarDaysMode.Expanded
                && e.Calendar.Days != null
                && e.Calendar.Days.Length > 0
                && e.Calendar.Days[0].TimeUnits != null
                && e.Calendar.Days[0].TimeUnits.Length > 0
                )
            {
                top = e.Calendar.Days[0].BodyBounds.Top;
                
                //Timescale top line is full
                e.Graphics.DrawLine(p, TimeScaleBounds.Left, top, TimeScaleBounds.Right, top);
            }

            p.Dispose();

            base.OnDrawTimeScale(e);
        }
        /// <summary>
        /// Initializes the Calendar
        /// </summary>
        /// <param name="e"></param>
        public virtual void OnInitialize(CalendarRendererEventArgs e)
        {

        }
Example #20
0
 public override void OnDrawBackground(CalendarRendererEventArgs e)
 {
     e.Graphics.Clear(ColorTable.Background);
 }
 public CalendarRendererTimeUnitEventArgs(CalendarRendererEventArgs original, CalendarTimeScaleUnit unit)
     : base(original)
 {
     _unit = unit;
 }