コード例 #1
0
        private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var title      = (SourceTitle)e.NewValue;
            var chapterBar = d as RangeBar;

            if (title == null)
            {
                return;
            }

            List <SourceChapter> chapters = title.ChapterList;

            chapterBar.markersUpdated = false;

            chapterBar.totalDuration = title.Duration.ToSpan();
            chapterBar.totalSeconds  = HandBrakeUnitConversionHelpers.PtsToSeconds((ulong)title.Duration.Ticks);

            ulong pts = 0;

            chapterBar.chapterFractions = new List <double>();
            foreach (SourceChapter chapter in chapters)
            {
                pts += (ulong)chapter.Duration.Ticks;
                chapterBar.chapterFractions.Add(Math.Min(HandBrakeUnitConversionHelpers.PtsToSeconds(pts) / chapterBar.totalSeconds, 1));
            }

            chapterBar.UpdateSeekBarUI();
            chapterBar.UpdateMarkers();
        }
コード例 #2
0
        private void UpdateMarkers()
        {
            if (this.markersUpdated)
            {
                return;
            }

            if (this.ChaptersEnabled)
            {
                if (this.StartChapter <= 0 || this.EndChapter <= 0 || this.Chapters == null)
                {
                    return;
                }
            }

            double barWidth = this.barHolder.ActualWidth;

            if (barWidth == 0)
            {
                return;
            }

            this.markersGrid.Children.Clear();

            if (this.ChaptersEnabled)
            {
                ulong pts = 0;
                for (int i = 1; i < this.Chapters.Count - 1; i++)
                {
                    pts += (ulong)this.Chapters[i - 1].Duration.Ticks;

                    var marker = new Polygon
                    {
                        Style  = this.FindResource("SeekBarTick") as Style,
                        Margin = new Thickness(barWidth * (HandBrakeUnitConversionHelpers.PtsToSeconds(pts) / this.totalSeconds) - 1, 0, 0, 0),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top
                    };

                    this.markersGrid.Children.Add(marker);
                }
            }

            for (int minutes = 10; minutes * 60 < this.totalSeconds; minutes += 10)
            {
                string style = minutes % 60 == 0 ? "SeekBarBigTick" : "SeekBarTick";

                var marker = new Polygon
                {
                    Style  = this.FindResource(style) as Style,
                    Margin = new Thickness(barWidth * ((minutes * 60) / this.totalSeconds) - 1, 0, 0, 0),
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Bottom
                };

                this.markersGrid.Children.Add(marker);
            }

            this.markersUpdated = true;
        }
コード例 #3
0
        private double GetBarFractionFromChapter(int chapter)
        {
            ulong pts = 0;
            for (int i = 1; i <= chapter; i++)
            {
                pts += (ulong)this.Chapters[i - 1].Duration.Ticks;
            }

            return GetBarFractionFromSeconds(HandBrakeUnitConversionHelpers.PtsToSeconds(pts));
        }