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
85
I need to show location on the day view for each time slot
posted

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

Parents
No Data
Reply
  • 69832
    Offline posted

    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

Children