Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
MonthViewMulti - Drawing on top of the day number
posted

Hello,

I'm using the MonthViewMulti. Some days should be marked with an "x" on top of the day number (see the image below). What's the best way to do it?

Thanks.

 

 

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    The following code sample demonstrates how to solve the problem you describe here using the IUIElementDrawFilter interface:

    using nsMonthViewMulti = Infragistics.Win.UltraWinSchedule.MonthViewMulti;

    XDayDrawFilter drawFilter = new XDayDrawFilter( this.ultraMonthViewMulti1 );
    drawFilter.AddDate( DateTime.Today.AddDays(7) );
    this.ultraMonthViewMulti1.DrawFilter = drawFilter;

    #region XDayDrawFilter
    public class XDayDrawFilter : IUIElementDrawFilter
    {
        private Dictionary<DateTime, object> dates = null;
        private UltraMonthViewMulti control = null;

        public XDayDrawFilter( UltraMonthViewMulti control ) { this.control = control; }

        public void AddDate( DateTime date )
        {
            date = date.Date;

            if ( this.Dates.ContainsKey(date) == false )
            {
                this.Dates.Add( date.Date, null );

                if ( this.control != null )
                    this.control.Refresh();
            }
        }

        public void RemoveDate( DateTime date )
        {
            date = date.Date;

            if ( this.Dates.ContainsKey(date) )
            {
                this.Dates.Remove( date.Date );

                if ( this.control != null )
                    this.control.Refresh();
            }
        }

        private Dictionary<DateTime, object> Dates
        {
            get
            {
                if ( this.dates == null )
                    this.dates = new Dictionary<DateTime,object>(0);

                return this.dates;
            }
        }

        #region IUIElementDrawFilter Members

        bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
        {
            Graphics gr = drawParams.Graphics;
            Rectangle bounds = drawParams.Element.RectInsideBorders;
            using ( Pen pen = new Pen(Color.Red) )
            {
                gr.DrawLine( pen, new Point(bounds.Left, bounds.Top), new Point(bounds.Right - 1, bounds.Bottom - 1) );
                gr.DrawLine( pen, new Point(bounds.Left, bounds.Bottom - 1), new Point(bounds.Right - 1, bounds.Top) );
            }

            return true;
        }

        DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
        {
            nsMonthViewMulti.DayUIElement dayElement = drawParams.Element as nsMonthViewMulti.DayUIElement;

            if ( dayElement != null && this.Dates.ContainsKey(dayElement.Date) )
                return DrawPhase.AfterDrawElement;
            else
                return DrawPhase.None;
        }

        #endregion
    }
    #endregion XDayDrawFilter

Children