internal void FireEventCreated(
     FrameworkElement element,
     TimelineDisplayEvent de
     )
 {
     OnEventCreated?.Invoke(element, de);
 }
Beispiel #2
0
        public object CreateEvent(
            TimelineEvent e,
            TimelineDisplayEvent de
            )
        {
            FrameworkElement element;

            Debug.Assert(e != null);

            if (m_elementPool.Count == 0)
            {
                element = CreateEventElement() as FrameworkElement;
            }
            else
            {
                element = m_elementPool.Pop() as FrameworkElement;
            }

            element.DataContext = de;
            element.SetValue(Canvas.ZIndexProperty, (e.Row + 1) * MIN_EVENT_ZINDEX);
            m_canvas.Children.Add(element);

            if (m_parent.IsMainBand)
            {
                m_parent.TimelineTray.FireEventCreated(element, de);
                m_parent.FireEventCreated(element, de);
            }

            return(element);
        }
Beispiel #3
0
 internal void FireEventCreated(
     TimelineDisplayEvent de
     )
 {
     if (OnEventCreated != null)
     {
         OnEventCreated(de);
     }
 }
Beispiel #4
0
 internal void FireOnEventVisible(
     FrameworkElement element,
     TimelineDisplayEvent de
     )
 {
     if (OnEventVisible != null)
     {
         OnEventVisible(element, de);
     }
 }
Beispiel #5
0
 internal void FireEventCreated(
     FrameworkElement element,
     TimelineDisplayEvent de
     )
 {
     if (OnEventCreated != null)
     {
         OnEventCreated(element, de);
     }
 }
Beispiel #6
0
        ///
        /// <summary>
        /// Calculate top position and width of each event</summary>
        ///
        public void CalculateEventPositions(
            )
        {
            TimelineDisplayEvent pos;

            Debug.Assert(m_events != null);

            if (m_dispEvents == null)
            {
                return;
            }

            Utilities.Trace(this);

            foreach (TimelineEvent e in m_events)
            {
                if (!m_dispEvents.ContainsKey(e))
                {
                    pos = new TimelineDisplayEvent(e, m_parent.TimelineTray, this);
                    if (m_savedDispEvents != null && m_savedDispEvents.ContainsKey(e))
                    {
                        pos.Selected = m_savedDispEvents[e].Selected;
                        if (pos.Selected && !string.IsNullOrEmpty(TimelineDisplayEvent.SelectedEventImageUrl))
                        {
                            m_savedDispEvents[e].Event.TeaserEventImage = e.TeaserEventImage;
                            e.TeaserEventImage = TimelineDisplayEvent.SelectedEventImageUrl;
                        }
                        else if (!pos.Selected)
                        {
                            e.TeaserEventImage = m_savedDispEvents[e].Event.TeaserEventImage;
                        }
                    }
                    m_dispEvents.Add(e, pos);
                }
                else
                {
                    pos = m_dispEvents[e];
                }

                Debug.Assert(e.Row >= 0, "Need first call CalculateEventRows for main band");

                if (pos.Top == -1 || pos.TimelineTray.RecalculateEventTopPosition)
                {
                    pos.SetCalculatedTop(e.Row * m_maxEventHeight + TOP_MARGIN);
                }

                pos.ActualEventPixelWidth = TimeSpanToPixels(e.EndDate - e.StartDate);
                pos.ActualEventPixelWidth = Math.Max(3.0, pos.ActualEventPixelWidth);

                pos.EventPixelWidth = Math.Min(PixelWidth * 2, pos.ActualEventPixelWidth);
            }
        }
Beispiel #7
0
        ///
        /// <summary>
        /// Once visual element is deleted we mark that there are no currently
        /// playing videos</summary>
        ///
        private void OnEventDeleted(
            FrameworkElement element,
            TimelineLibrary.TimelineDisplayEvent de
            )
        {
            MediaElement me;

            me = element.FindName("MediaPlayer") as MediaElement;

            if (me == m_playing && me != null)
            {
                m_playing.Stop();
                m_playing = null;
            }
        }
        ///
        /// <summary>
        /// Calculate top position and width of each event</summary>
        ///
        public void CalculateEventPositions(
            )
        {
            TimelineDisplayEvent pos;
            double maxWidth = 0;

            Debug.Assert(AllEvents != null);

            if (m_dispEvents == null)
            {
                return;
            }

            Utilities.Trace(this);

            foreach (TimelineEvent e in AllEvents)
            {
                if (!m_dispEvents.ContainsKey(e))
                {
                    pos = new TimelineDisplayEvent(e, m_parent.TimelineTray, this);
                    m_dispEvents.Add(e, pos);
                }
                else
                {
                    pos = m_dispEvents[e];
                }

                Debug.Assert(e.Row >= 0, "Need first call CalculateEventRows for main band");

                if (pos.Top == -1 || pos.TimelineTray.RecalculateEventTopPosition)
                {
                    pos.SetCalculatedTop(e.Row * m_maxEventHeight + TOP_MARGIN);
                }

                pos.ActualEventPixelWidth = TimeSpanToPixels(e.EndDate - e.StartDate);
                pos.ActualEventPixelWidth = Math.Max(3.0, pos.ActualEventPixelWidth);

                pos.EventPixelWidth = Math.Min(PixelWidth * 2, pos.ActualEventPixelWidth);

                maxWidth = Math.Max(maxWidth, pos.DescriptionWidth);
            }

            m_maxDescriptionWidth = PixelsToTimeSpan(maxWidth);
        }
Beispiel #9
0
        /// <summary>
        /// Calculate top position and width of each event</summary>
        public void CalculateEventPositions()
        {
            TimelineDisplayEvent pos;

            Debug.Assert(AllEvents != null);

            if (m_dispEvents == null)
            {
                return;
            }

            Utilities.Trace(this);
            TimeSpan ts = new TimeSpan();

            foreach (TimelineEvent e in AllEvents)
            {
                if (!m_dispEvents.ContainsKey(e))
                {
                    pos = new TimelineDisplayEvent(e, m_parent.TimelineTray, this);
                    m_dispEvents.Add(e, pos);
                }
                else
                {
                    pos = m_dispEvents[e];
                }

                Debug.Assert(e.Row >= 0, "Need first call CalculateEventRows for main band");

                if (pos.Top == -1 || pos.TimelineTray.RecalculateEventTopPosition)
                {
                    pos.SetCalculatedTop(e.Row * m_maxEventHeight + TOP_MARGIN);
                }

                pos.Recalculate(false);

                ts = (e.EndDate - e.StartDate);
            }

            m_maxDescriptionWidth = ts;
        }
Beispiel #10
0
        public object CreateEvent(
            TimelineEvent e,
            TimelineDisplayEvent de
            )
        {
            FrameworkElement element;
            DependencyObject obj;
            Button           link;

            Debug.Assert(e != null);

            obj                 = m_eventTemplate.LoadContent();
            element             = (FrameworkElement)obj;
            element.MouseEnter += OnMouseEnter;
            element.MouseLeave += OnMouseLeave;
            element.DataContext = de;

            if (m_parent.IsMainBand)
            {
                element.MouseLeftButtonDown += OnLeftButtonDown;
            }

            element.SetValue(Canvas.ZIndexProperty, (e.Row + 1) * MIN_EVENT_ZINDEX);

            link = (Button)element.FindName("EventLinkTextBlock");

            if (link != null)
            {
                link.Click += m_parent.OnMoreInfoClick;
            }
            m_canvas.Children.Add(element);

            if (m_parent.IsMainBand)
            {
                m_parent.TimelineTray.FireEventCreated(element, de);
            }

            return(element);
        }
Beispiel #11
0
        ///
        /// <summary>
        /// After current data is changed this function fixes positions of all columns
        /// and all events</summary>
        ///
        private void FixPositions(
            bool displayEvents,
            bool animate        = false,
            bool updateDuration = false
            )
        {
            double startLeft;
            double posOffset;

            int  colcount;
            long newStart;
            long idxOffset;

            colcount  = (m_columnCount + EXTRA_COLUMNS);
            posOffset = TimeSpanToPixels(CurrentDateTime - m_timeline.GetFloorTime(CurrentDateTime));

            newStart  = m_timeline.IndexOf(CurrentDateTime) - colcount / 2;
            startLeft = (PixelWidth / 2 - ColumnPixelWidth * (colcount / 2)) - posOffset;

            if (m_startIndex == INVALID_COLUMN_IDX || newStart > m_startIndex + colcount || newStart + colcount < m_startIndex)
            {
                //
                // this is case when we draw columns for the first time, or there are no columns which data contexts
                // may be reused
                //
                PositionColumnAndMarker(newStart, startLeft, 0, true, null);
            }
            else if (m_startIndex == newStart)
            {
                //
                // this is the case when we reuse existing column context (date string)
                //
                PositionColumnAndMarker(newStart, startLeft, 0, false, null);
            }
            else
            {
                idxOffset = m_startIndex - newStart;

                ShiftArray(m_columns, idxOffset, out m_columns);
                ShiftArray(m_columnMarkers, idxOffset, out m_columnMarkers);

                PositionColumnAndMarker(newStart, startLeft, 0, false, null);

                if (idxOffset > 0)
                {
                    for (int i = 0; i < idxOffset; ++i)
                    {
                        SetColumnDataContext(newStart + i, i);
                    }
                }
                else
                {
                    for (int i = colcount + (int)idxOffset; i < colcount; ++i)
                    {
                        SetColumnDataContext(newStart + i, i);
                    }
                }
            }
            m_startIndex = Math.Max(0, newStart);

            if (displayEvents)
            {
                DisplayEvents(animate);
            }

            if (updateDuration)
            {
                foreach (var ve in m_visibleEvents)
                {
                    var evnt = ve.Key;
                    TimelineDisplayEvent tde = m_dispEvents[evnt];

                    tde.Recalculate();
                }
            }
        }
Beispiel #12
0
 ///
 /// <summary>
 /// Once visual element is deleted we mark that there are no currently
 /// playing videos</summary>
 ///
 private new void OnEventDeleted(
     FrameworkElement element,
     TimelineLibrary.TimelineDisplayEvent de
     )
 {
 }
Beispiel #13
0
 internal void FireOnEventVisible(FrameworkElement element, TimelineDisplayEvent de)
 {
     OnEventVisible?.Invoke(element, de);
 }
Beispiel #14
0
 internal void FireOnEventVisible(
     FrameworkElement                            element,
     TimelineDisplayEvent                        de
 )
 {
     if (OnEventVisible != null)
     {
         OnEventVisible(element, de);
     }
 }
Beispiel #15
0
 internal void FireEventDeleted(
     FrameworkElement                            element,
     TimelineDisplayEvent                        de
 )
 {
     if (OnEventDeleted != null)
     {
         OnEventDeleted(element, de);
     }
 }
        /// 
        /// <summary>
        /// This event fires when event is about to be displayed on the screen,
        /// we attach event handlers to stop/play mediaplayer link here</summary>
        /// 
        void OnEventCreated(
            FrameworkElement                            element,
            TimelineDisplayEvent                        de
            )
        {
            MediaElement                                me;
            TimelineLibrary.Hyperlink                   link;

            me = element.FindName("MediaPlayer") as MediaElement;
            link = element.FindName("StopPlayButton") as TimelineLibrary.Hyperlink;

            if (me != null && link != null)
            {
                link.Tag = me;
                link.Click += new RoutedEventHandler(OnButtonClick);
                me.MediaEnded += new RoutedEventHandler(OnMediaEnded);
                me.Tag = false;
            }
        }
Beispiel #17
0
        /// 
        /// <summary>
        /// Once new visual element is created for timeline event we attach 
        /// event handlers to it's elements</summary>
        /// 
        private new void OnEventCreated(
            FrameworkElement                            element, 
            TimelineDisplayEvent                        de
        )
        {
            Grid                                        b;
            Border                                      bsize;
            Border                                      bdescr;
            Border                                      bduration;
            Hyperlink                                   hlink;

            b = element.FindName("EventTemplateRoot") as Grid;
            bsize = element.FindName("ResizeButton") as Border;
            bdescr = element.FindName("EventDescriptionBorder") as Border;
            bduration = element.FindName("DurationChangeBorder") as Border;

            hlink = element.FindName("EditButton") as Hyperlink;

            if (hlink != null)
            {
                hlink.Click += OnEditClick;
                hlink.Tag = de;
            }

            if (bdescr != null)
            {
                bdescr.MouseLeftButtonDown += CaptureMouse;
                bdescr.MouseLeftButtonUp += ReleaseMouse;
                bdescr.MouseMove += OnDescriptionMouseMove;
                bdescr.Tag = element;
            }

            if (bduration != null)
            {
                bduration.MouseLeftButtonDown += CaptureMouse;
                bduration.MouseLeftButtonUp += ReleaseMouse;
                bduration.MouseMove += OnBDurationMouseMove;
                bduration.Tag = element;
            }

            if (bsize != null)
            {
                bsize.MouseLeftButtonDown += CaptureMouse;
                bsize.MouseLeftButtonUp += ReleaseMouse;
                bsize.MouseMove += OnResizeMouseMove;
                bsize.Tag = b;
            }
        }