コード例 #1
0
        public void DeleteSelectedCaption()
        {
            if (lastSelectedCaption == null)
            {
                return;
            }


            var next = NextCaption(lastSelectedCaption);

            if (next != null)
            {
                next.LeftMargin += lastSelectedCaption.LeftMargin + lastSelectedCaption.MarkerDuration;
            }

            this.Captions.Remove(lastSelectedCaption);

            next.LayoutUpdated();


            lastSelectedCaption.Dispose();
            lastSelectedCaption = null;


            //var elapsed = TimeSpan.Zero;
            //foreach (var caption in Captions)
            //{
            //    caption.LeftMargin = caption.StartTime - elapsed;
            //    elapsed += caption.LeftMargin + caption.MarkerDuration;
            //}
        }
コード例 #2
0
 private void StartDragging(Caption caption)
 {
     mouseDownPosition = Mouse.GetPosition(this);
     startingMarginVal = caption.StartTime + caption.LeftMargin;
     draggingCaption   = caption;
     isDragging        = true;
 }
コード例 #3
0
        public Caption PreviousCaption(Caption caption)
        {
            var idx = Captions.IndexOf(caption);

            if (idx == 0)
            {
                return(null);
            }

            return(Captions[idx - 1]);
        }
コード例 #4
0
        public Caption NextCaption(Caption caption)
        {
            var idx = Captions.IndexOf(caption);

            if (idx >= Captions.Count - 1)
            {
                return(null);
            }

            return(Captions[idx + 1]);
        }
コード例 #5
0
        public static TimelineData FakeData(TimelineLayout layout, TimelinePlayback playback)
        {
            var timeline = new TimelineData(layout, playback);

            for (var i = 0; i < 30; i++)
            {
                timeline.AddCaption(Caption.FakeData(layout, timeline));
            }

            return(timeline);
        }
コード例 #6
0
        public void SelectCaption(Caption caption)
        {
            if (caption != lastSelectedCaption)
            {
                if (lastSelectedCaption != null)
                {
                    lastSelectedCaption.IsSelected = false;
                }

                caption.IsSelected  = true;
                lastSelectedCaption = caption;
            }
        }
コード例 #7
0
        public void SetCaptionStart(Caption caption, TimeSpan start, int dragSession)
        {
            var next = NextCaption(caption);

            TimeSpan start2;

            if (lastSession == null || dragSession != lastSession.Value)
            {
                start2          = caption.StartTime;
                sessionPosition = start2;
                lastSession     = dragSession;
            }
            else
            {
                start2 = sessionPosition;
            }

            var diff = start - start2;

            diff = TimeSpan.FromMilliseconds(Math.Max(0, diff.TotalMilliseconds));

            var marginDiff = caption.LeftMargin - diff;

            if (next != null && next.LeftMargin + marginDiff < TimeSpan.Zero)
            {
                diff += (next.LeftMargin + marginDiff);
            }

            marginDiff         = caption.LeftMargin - diff;
            caption.LeftMargin = diff;
            sessionPosition   += caption.LeftMargin - diff;

            if (next != null)
            {
                next.LeftMargin += marginDiff;
            }
        }
コード例 #8
0
 public void AddCaption(Caption caption)
 {
     Captions.Add(caption);
 }