TrakHound_UI.Timeline.TimelineDisplayEvent.Recalculate C# (CSharp) Méthode

Recalculate() public méthode

public Recalculate ( bool fireUpdate = true ) : void
fireUpdate bool
Résultat void
        public void Recalculate(
            bool                                                fireUpdate = true
        )
        {
            ActualEventPixelWidth = TimelineBuilder.TimeSpanToPixels(Event.EndDate - Event.StartDate);
            ActualEventPixelWidth = Math.Max(3.0, ActualEventPixelWidth);
            EventPixelWidth       = Math.Min(TimelineBuilder.PixelWidth * 2, ActualEventPixelWidth);

            FirePropertyChanged("DescriptionWidth");
            FirePropertyChanged("DescriptionHeight");
            FirePropertyChanged("EventPixelWidth");
            FirePropertyChanged("ActualEventPixelWidth");
        }

Usage Example

        ///
        /// <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;
            //newStart = m_timeline.IndexOf(CurrentDateTime);

            startLeft = (PixelWidth / 2 - ColumnPixelWidth * (colcount / 2)) - posOffset;
            //startLeft = 0;

            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);
            //m_startIndex = 0;

            if (displayEvents)
            {
                DisplayEvents(animate);
            }

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

                    tde.Recalculate();
                }
            }
        }