Пример #1
0
        public void BringItemIntoView(object item)
        {
            TimelineItem container = ContainerFromItem(item);

            if (container != null)
            {
                Nullable <long> start = TimelineCompactPanel.GetStartTick(container);
                if (start.HasValue)
                {
                    GoToTick(start.Value);
                }
            }
        }
Пример #2
0
        public void BringIntoView(TimelineControlBringIntoViewMode mode, object dataItem)
        {
            TimelineItem container = ContainerFromItem(dataItem);

            if (container != null)
            {
                Nullable <long> start = TimelineCompactPanel.GetStartTick(container);
                Nullable <long> end   = TimelineCompactPanel.GetEndTick(container);

                if (IsSetZoomToFit(mode) && start.HasValue && end.HasValue)
                {
                    long     duration        = end.Value - start.Value;
                    double   pixelPerTick    = (ActualWidth / 2) / duration;
                    TimeSpan newTickTimeSpan = TimeSpan.FromTicks((long)(1D / pixelPerTick));

                    if (newTickTimeSpan.TotalMinutes < 1)
                    {
                        newTickTimeSpan = TimeSpan.FromMinutes(1);
                    }

                    if (newTickTimeSpan < TickTimeSpan)
                    {
                        TickTimeSpan = newTickTimeSpan;
                    }
                    else
                    {
                        if (ActualWidth / 2 < duration * Timeline.GetPixelsPerTick(this))
                        {
                            TickTimeSpan = newTickTimeSpan;
                        }
                    }

                    WpfUtility.WaitForPriority(DispatcherPriority.Background);
                }

                if (IsSetCurrentTime(mode))
                {
                    if (start.HasValue)
                    {
                        CurrentTick = start.Value;
                    }
                    else if (end.HasValue)
                    {
                        CurrentTick = end.Value;
                    }
                }
            }
        }