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.
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 XDayDrawFilterpublic 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 );
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
Thanks for the answer Brian, this is exatcly what I needed.
I have one more question: Is there a way to suspend the control's repainting, aply a bunch of Appearances or Look changes and then resume the repaint?
In this case I'd like to set 30 or more days with an x, then let the control repaint.
Yes, use the control's BeginUpdate/EndUpdate methods. The former suspends processing of paint messages, and the latter resumes.