I need show what location a person is at in each time slot on the day view. It only needs to be 3 alpha-numeric digits. The best thing would be if I could reserve that last three digits of each day view cells for a location code. Can you think of anyway I could accomplish this. Or any other ideas on how to handle it. I am currently using background and forground colors to denote other informaiton. This information would be outside of an appointment. The person may be at a certain location without having an appointment.
Thanks
The following code sample demonstrates a solution to the problem you describe here using the IUIElementCreationFilter interface:
using Infragistics.Win.UltraWinSchedule;using nsDayView = Infragistics.Win.UltraWinSchedule.DayView;
TimeSlotLabelCreationFilter.TimeSlotLabelOwnerDateDelegate del = new TimeSlotLabelCreationFilter.TimeSlotLabelOwnerDateDelegate( this.GetTimeSlotLabel );this.dayView.CreationFilter = new TimeSlotLabelCreationFilter( del );
private string GetTimeSlotLabel( Owner owner, DateTime date, TimeSlot timeSlot ){ // TODO: Return a string to be displayed in the TimeSlot}
#region TimeSlotLabelCreationFilter/// <summary>/// Provides a way to add labels for DayView's TimeSlotUIElements/// </summary>public class TimeSlotLabelCreationFilter : IUIElementCreationFilter{ public delegate string TimeSlotLabelOwnerDateDelegate( Owner owner, DateTime date, TimeSlot timeSlot ); private TimeSlotLabelOwnerDateDelegate ownerDateDelegate = null;
public TimeSlotLabelCreationFilter( TimeSlotLabelOwnerDateDelegate ownerDateDelegate ) { this.ownerDateDelegate = ownerDateDelegate; }
#region IUIElementCreationFilter interface implementation
void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { nsDayView.TimeSlotUIElement timeSlotElement = parent as nsDayView.TimeSlotUIElement; if ( timeSlotElement != null ) { // Try to obtain the last TextUIElement that was used, if we can, // to eliminate unnecessary object instantiation. TextUIElement textElement = null; if ( timeSlotElement.ChildElements.Count > 0 ) textElement = timeSlotElement.GetDescendant( typeof(TextUIElement) ) as TextUIElement;
timeSlotElement.ChildElements.Clear();
object dateContext = timeSlotElement.GetContext( typeof(DateTime) ); if ( dateContext != null ) { // Get the Owner and TimeSlot Owner owner = timeSlotElement.GetContext( typeof(Owner) ) as Owner; TimeSlot timeSlot = timeSlotElement.GetContext( typeof(TimeSlot) ) as TimeSlot;
// Call out to the owner/date delegate to get the text for the label string text = this.ownerDateDelegate.Invoke( owner, (DateTime)dateContext, timeSlot );
// If they return a non-empty string, add a TextUIElement to display it. if ( string.IsNullOrEmpty(text) == false ) { if ( textElement == null ) textElement = new TextUIElement( timeSlotElement, text ); else textElement.Text = text;
// Set the Rect and add the element textElement.Rect = timeSlotElement.RectInsideBorders; timeSlotElement.ChildElements.Add( textElement ); } } } }
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; }
#endregion IUIElementCreationFilter interface implementation}#endregion TimeSlotLabelCreationFilter
That worked great. The only problem I have now is, when there is an appointment the appointment description rectangle covers the Location. Is there a way to make the Description rectangle area smaller.
Sorry but no, there is really no way to prevent the label from being obscured by appointments. Appointments can span across more than one TimeSlot and as such they are drawn over the TimeSlots; the example I provided draws the labels inside the TimeSlots.
I was wondering if you could provide an example of what the creation filter would look like to modify the width of the appointment elements
rufinitsw said:So your saying that you can't even make the appointment subject box smaller.
The width of the appointment element is (sometimes) governed by the number of appointments with which it intersects. If, for example, 3 appointments intersect with the 9AM time slot, those three appointments will have a width of 1/3 the column in which they are displayed. You could theoretically use a creation filter to modify the width of the appointment elements, but in doing so you might be interfering with the logic that determines their correct width
rufinitsw said:or is there a way to draw the labels outside the box so they are not obscured
If the label is the same for every owner, you could conceivably draw into the time slot descriptor area (the area that shows the time for the time slots. There is then, however, the issue of interfering the time slot time labels, although it should be possible to move them over, say, to the left edge of the descriptor element, then show the location labels on the right edge.
So your saying that you can't even make the appointment subject box smaller. I know they will drawn over the TimeSlot but is there a way to control the appointment subject box size. I added
textElement.TextHAlign = HAlign.Right
So it prints the location at the far right. If I had control over the size of the appointment subject it would work perfectly.
or is there a way to draw the labels outside the box so they are not obscured. this would have to be the case even if there were multiple owners on the screen at the same time.
Thanks for the help