Esempio n. 1
0
        public static Caption FakeData(TimelineLayout layout, TimelineData timeline)
        {
            var text = File.ReadAllText(@"..\..\SourceText.txt").Replace(Environment.NewLine, " ");

            const int captionLength = 50;

            var idx1 = random.Next(0, text.Length - captionLength);

            var idx2 = text.IndexOf(' ', idx1) + 1;

            return(new Caption(layout, timeline)
            {
                Text = text.Substring(idx2, Math.Min(captionLength, text.Length - captionLength - 1))
            });
        }
Esempio n. 2
0
        public Caption(TimelineLayout layout, TimelineData timeline)
        {
            _layout   = layout;
            _timeline = timeline;

            _layout.WhenZoomChanged.Subscribe(i =>
            {
                zoomFactor = i;
                OnPropertyChanged(nameof(MarkerWidth));
                OnPropertyChanged(nameof(LeftMarginWidth));
            });

            zoomFactor = _layout.Zoom;
            OnPropertyChanged(nameof(MarkerWidth));
            OnPropertyChanged(nameof(LeftMarginWidth));

            MarkerDuration = TimeSpan.FromSeconds(4);
        }
Esempio n. 3
0
        public RootControl()
        {
            TimelineLayout = new TimelineLayout();
            Playback       = new TimelinePlayback(TimeSpan.FromMinutes(3));
            Timeline       = TimelineData.FakeData(TimelineLayout, Playback);

            InitializeComponent();

            this.video.Position = TimeSpan.Zero;


            Playback.WhenTimeChanged.Subscribe(time =>
            {
                var scrollPosition = TimelineLayout.GetScrollPosition(time);

                //var playerHeadPosition = TimelineLayout.GetPlayerHeadPosition(time);

                //overlay.Set(playerHeadPosition);

                ScrollTo(scrollPosition);

                whenTimeChanged.OnNext(time);

                var caption = Timeline.PlaybackCaption;

                whenPlaybackCaptionChanged.OnNext(caption);

                Thread.Sleep(100);
            });

            var viewer = new WaveViewer();

            viewer.BackColor  = System.Drawing.Color.LightGray;
            viewer.WaveStream = new WaveFileReader(@"C:\Users\Amichai\Desktop\The Zahir.wav");

            this.Host.Child = viewer;

            TimelineLayout.WhenZoomChanged.Subscribe(zoom =>
            {
                var scale = TimelineLayout.Zoom / 100f;
                viewer.SamplesPerPixel = (int)Math.Round(128 / scale);
            });
        }