Exemplo n.º 1
0
        public void CreateTimelineCalculator(
            string calendarType,
            DateTime currentDateTime,
            DateTime minDateTime,
            DateTime maxDateTime
            )
        {
            Debug.Assert(this.TimelineTray != null);

            ItemsSource = new TimelineCalendar(calendarType, m_timelineType,
                                               minDateTime, maxDateTime)
            {
                TimeFormat24 = TimeFormat24
            };

            m_calendarType = calendarType;

            if (ItemTemplate == null)
            {
                ItemTemplate = DefaultItemTemplate;
            }

            if (TextItemTemplate == null)
            {
                TextItemTemplate = DefaultTextItemTemplate;
            }

            if (ShortEventTemplate == null)
            {
                ShortEventTemplate = DefaultShortEventTemplate;
            }

            if (EventTemplate == null)
            {
                EventTemplate = DefaultEventTemplate;
            }

            if (Calculator != null)
            {
                Calculator.ClearEvents();
                Calculator.ClearColumns();
            }

            Calculator = new TimelineBuilder(
                this,
                CanvasPart,
                ItemTemplate,
                TextItemTemplate,
                TimelineWindowSize,
                ItemsSource,
                !IsMainBand ? ShortEventTemplate : EventTemplate,
                MaxEventHeight,
                IsMainBand,
                currentDateTime);

            Calculator.BuildColumns();
            m_calcInitialized = true;
        }
Exemplo n.º 2
0
 private string GetDataContext(long index)
 {
     if (Calendar.IsValidIndex(index))
     {
         return(TimelineCalendar.ItemToString(Calendar, Calendar[index]));
     }
     else
     {
         return(string.Empty);
     }
 }
Exemplo n.º 3
0
        public TimelineBuilder(
            TimelineBand band,
            Canvas canvas,
            DataTemplate template,
            DataTemplate textTemplate,
            int columnCount,
            TimelineCalendar timeline,
            DataTemplate eventTemplate,
            double maxEventHeight,
            bool assignRows,
            DateTime currDateTime
            )
        {
            SingleDelayedInvoke poolBuilder;

            Debug.Assert(template != null);
            Debug.Assert(canvas != null);
            Debug.Assert(eventTemplate != null);
            Debug.Assert(band != null);
            Debug.Assert(columnCount > 0);
            Debug.Assert(timeline != null);
            Debug.Assert(maxEventHeight > 0);

            m_parent         = band;
            m_eventTemplate  = eventTemplate;
            m_canvas         = canvas;
            m_template       = template;;
            m_columnCount    = columnCount;
            m_timeline       = timeline;
            m_assignRows     = assignRows;
            m_markerTemplate = textTemplate;

            m_visibleEvents  = new Dictionary <TimelineEvent, object>();
            m_dispEvents     = new Dictionary <TimelineEvent, TimelineDisplayEvent>();
            m_maxEventHeight = maxEventHeight;

            CurrentDateTime = currDateTime;

            //
            // precreate some elements, so that we can later take them from pool
            //
            poolBuilder = new SingleDelayedInvoke();

            for (int i = 0; i < INITIAL_EVENT_POOL_SIZE; ++i)
            {
                m_elementPool.Push((UIElement)CreateEventElement());
            }

            Utilities.Trace(this);
        }
Exemplo n.º 4
0
        public TimelineBuilder(
            TimelineBand band,
            Canvas canvas,
            DataTemplate template,
            DataTemplate textTemplate,
            int columnCount,
            TimelineCalendar timeline,
            DataTemplate eventTemplate,
            double maxEventHeight,
            bool assignRows,
            DateTime currDateTime
            )
        {
            Debug.Assert(template != null);
            Debug.Assert(canvas != null);
            Debug.Assert(eventTemplate != null);
            Debug.Assert(band != null);
            Debug.Assert(columnCount > 0);
            Debug.Assert(timeline != null);
            Debug.Assert(maxEventHeight > 0);

            m_parent        = band;
            m_eventTemplate = eventTemplate;
            m_canvas        = canvas;
            m_template      = template;;
            m_columnCount   = columnCount;
            m_timeline      = timeline;
            m_assignRows    = assignRows;
            m_textTemplate  = textTemplate;

            m_visibleEvents  = new Dictionary <TimelineEvent, object>();
            m_dispEvents     = new Dictionary <TimelineEvent, TimelineDisplayEvent>();
            m_maxEventHeight = maxEventHeight;

            CurrentDateTime = currDateTime;

            Utilities.Trace(this);
        }
Exemplo n.º 5
0
 private string GetDataContext(
     int index
     )
 {
     return(TimelineCalendar.ItemToString(ItemsSource, ItemsSource[index]));
 }
Exemplo n.º 6
0
        public static string ItemToString(
            TimelineCalendar src,
            DateTime value
            )
        {
            DateTime             d;
            string               ret;
            TimelineCalendarType type;

            Debug.Assert(src as TimelineCalendar != null);
            Debug.Assert(value != null);

            d    = (DateTime)value;
            type = ((TimelineCalendar)src).LineType;

            switch (type)
            {
            case TimelineCalendarType.Decades:
                ret = DateTimeConverter.GetDecades(d);
                break;

            case TimelineCalendarType.Years:
                ret = DateTimeConverter.GetYear(d);
                break;

            case TimelineCalendarType.Months:
                ret = DateTimeConverter.GetMonth(d);
                break;

            case TimelineCalendarType.Days:
                ret = DateTimeConverter.GetDay(d);
                break;

            case TimelineCalendarType.Hours:
                if (!src.m_is24hFormat)
                {
                    ret = d.ToString("hh tt");
                }
                else
                {
                    ret = d.ToString("HH");
                }
                break;

            case TimelineCalendarType.Minutes10:
                if (d.Minute == 0)
                {
                    ret = d.Hour.ToString() + ":00";
                }
                else
                {
                    ret = ((d.Minute / 10) * 10).ToString();
                }
                break;

            case TimelineCalendarType.Minutes:
                ret = d.ToString("mm");
                break;

            case TimelineCalendarType.Seconds:
                ret = d.Second.ToString();
                break;

            case TimelineCalendarType.Milliseconds100:
                ret = (d.Millisecond / 100).ToString();
                break;

            case TimelineCalendarType.Milliseconds10:
                ret = (d.Millisecond / 10).ToString();
                break;

            case TimelineCalendarType.Milliseconds:
                ret = (d.Millisecond).ToString();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(ret);
        }
Exemplo n.º 7
0
        public static string ItemToString(
            TimelineCalendar                            src,
            DateTime                                    value
            )
        {
            DateTime                                    d;
            string                                      ret;
            TimelineCalendarType                        type;

            Debug.Assert(src as TimelineCalendar != null);
            Debug.Assert(value != null);

            d = (DateTime) value;
            type = ((TimelineCalendar) src).LineType;

            switch (type)
            {
                    
                case TimelineCalendarType.Decades:
                    ret = DateTimeConverter.GetDecades(d);
                    break;

                case TimelineCalendarType.Years:
                    ret = DateTimeConverter.GetYear(d);
                    break;

                case TimelineCalendarType.Months:
                    ret = DateTimeConverter.GetMonth(d);
                    break;

                case TimelineCalendarType.Days:
                    ret = DateTimeConverter.GetDay(d);
                    break;
                
                case TimelineCalendarType.Hours:
                    if (!src.m_is24hFormat)
                    {
                        ret = d.ToString("hh tt");
                    }
                    else
                    {
                        ret = d.ToString("HH");
                    }
                    break;

                case TimelineCalendarType.Minutes10:
                    if (d.Minute == 0)
                    {
                        ret = d.Hour.ToString() + ":00";
                    }
                    else 
                    {
                        ret = ((d.Minute / 10) * 10).ToString();
                    }
                    break;

                case TimelineCalendarType.Minutes: 
                    ret = d.ToString("mm");
                    break;

                case TimelineCalendarType.Seconds:
                    ret = d.Second.ToString();
                    break;

                case TimelineCalendarType.Milliseconds100:
                    ret = (d.Millisecond / 100).ToString();
                    break;                

                case TimelineCalendarType.Milliseconds10:
                    ret = (d.Millisecond / 10).ToString();
                    break;

                case TimelineCalendarType.Milliseconds:
                    ret = (d.Millisecond).ToString();
                    break;

                default:
                   throw new ArgumentOutOfRangeException();
            }
            
            return ret;
        }
Exemplo n.º 8
0
        public void CreateTimelineCalculator(
            string                                      calendarType,
            DateTime                                    currentDateTime,
            DateTime                                    minDateTime,
            DateTime                                    maxDateTime
        )
        {
            Debug.Assert(this.TimelineTray != null);

            ItemsSource = new TimelineCalendar(calendarType, m_timelineType,
                minDateTime, maxDateTime);

            ItemsSource.TimeFormat24 = TimeFormat24;

            m_calendarType = calendarType;

            if (ItemTemplate == null)
            {
                ItemTemplate = DefaultItemTemplate;
            }

            if (TextItemTemplate == null)
            {
                TextItemTemplate = DefaultTextItemTemplate;
            }
            
            if (ShortEventTemplate == null)
            {
                ShortEventTemplate = DefaultShortEventTemplate;
            }

            if (EventTemplate == null)
            {
                EventTemplate = DefaultEventTemplate;
            }

            if (m_calc != null)
            {
                m_calc.ClearEvents();
                m_calc.ClearColumns();
            }

            m_calc = new TimelineBuilder(
                this,
                CanvasPart, 
                ItemTemplate, 
                TextItemTemplate,
                TimelineWindowSize, 
                ItemsSource, 
                !IsMainBand ? ShortEventTemplate : EventTemplate,
                MaxEventHeight,
                IsMainBand,
                currentDateTime);

            m_calc.BuildColumns();
            m_calcInitialized = true;
        }