private void MarkerEditName_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if (e != null)
            {
                TimelineMarker marker = e.Parameter as TimelineMarker;

                if (marker != null)
                {
                    e.Handled = true;

                    Window window = Window.GetWindow(this);

                    EditStringDialog dialog = new EditStringDialog()
                    {
                        Owner         = window,
                        Title         = Strings.EditTimeMarker_Title,
                        Prompt        = Strings.TimelineMarker_Name_Prompt,
                        Value         = marker.Name,
                        MaximumLength = 63,
                    };

                    if (dialog.ShowDialog() == true)
                    {
                        marker.Name = dialog.Value.Trim();
                    }
                }
            }
        }
        private void SetInPoint_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if ((e != null) && (this.InOutPointsSource != null))
            {
                e.Handled = true;

                TimelineMarker marker = e.Parameter as TimelineMarker;

                if (marker == null)
                {
                    if (this.newPointTime.HasValue)
                    {
                        this.InOutPointsSource.InPoint = this.newPointTime.Value;
                    }
                }
                else
                {
                    this.InOutPointsSource.InPoint = marker.RelativeTime;
                }
            }

            this.newPointTime = null;
        }
Esempio n. 3
0
        public TimelinePausePoint AddAt(TimelineMarker marker)
        {
            DebugHelper.AssertUIThread();
            Debug.Assert(this.Points != null);
            Debug.Assert(this.Source != null);

            if (marker == null)
            {
                throw new ArgumentNullException("marker");
            }

            TimeSpan relativeTime = marker.RelativeTime;

            TimelinePausePoint pausePoint = null;

            pausePoint = new TimelinePausePoint(this, relativeTime, marker);

            this.Points.Add(pausePoint);

            if (this.ignore == 0)
            {
                this.UpdatePlaybackPausePoints();
            }

            this.IsDirty = true;

            this.OnSave();

            return(pausePoint);
        }
        private void PausePointCouple_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if ((e != null) && (this.PausePointsSource != null))
            {
                e.Handled = true;

                TimelineMarker marker = e.Parameter as TimelineMarker;
                if (marker != null)
                {
                    e.CanExecute = marker.CoupledPausePoint == null;
                }
            }
        }
        private void MarkerEditName_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if (e != null)
            {
                TimelineMarker marker = e.Parameter as TimelineMarker;

                if (marker != null)
                {
                    e.Handled    = true;
                    e.CanExecute = !marker.IsReadOnly;
                }
            }
        }
        private void PausePointCouple_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DebugHelper.AssertUIThread();

            if ((e != null) && (this.PausePointsSource != null))
            {
                e.Handled = true;

                TimelineMarker marker = e.Parameter as TimelineMarker;
                if (marker != null)
                {
                    if (marker.CoupledPausePoint == null)
                    {
                        marker.CreateCoupledPausePoint(this.PausePointsSource);
                    }
                }
            }

            this.newPointTime = null;
        }
        public TimelinePausePoint(TimelinePausePointsCollection owner, TimeSpan relativeTime, TimelineMarker marker)
            : base(relativeTime)
        {
            DebugHelper.AssertUIThread();

            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            if (marker == null)
            {
                throw new ArgumentNullException("marker");
            }

            this.owner = owner;
            this.marker = marker;

            this.marker.PropertyChanged += Marker_PropertyChanged;
        }
        public TimelinePausePoint(TimelinePausePointsCollection owner, TimeSpan relativeTime, TimelineMarker marker)
            : base(relativeTime)
        {
            DebugHelper.AssertUIThread();

            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            if (marker == null)
            {
                throw new ArgumentNullException("marker");
            }

            this.owner  = owner;
            this.marker = marker;

            this.marker.PropertyChanged += Marker_PropertyChanged;
        }
Esempio n. 9
0
        protected override void OnLoad()
        {
            DebugHelper.AssertUIThread();
            Debug.Assert(this.Points != null);
            Debug.Assert(this.Source != null);

            this.Points.Clear();
            bool newHasEnabled  = false;
            bool newHasDisabled = false;

            this.ignore++;

            XElement element = this.GetSettings("pausePoints");

            if (element != null)
            {
                foreach (XElement pausePointElement in element.Elements("pausePoint"))
                {
                    TimeSpan time       = XmlExtensions.GetAttribute(pausePointElement, "time", TimeSpan.MinValue);
                    bool     enabled    = XmlExtensions.GetAttribute(pausePointElement, "enabled", true);
                    string   markerName = XmlExtensions.GetAttribute(pausePointElement, "marker", (string)null);

                    TimelinePausePoint pausePoint = null;

                    // Marker names are not unique in a file, so we have to do a little rough guessing
                    // 1. the first marker found with the given name and time will be given the pause point
                    // 2. if no such, then the first marker found with the given name will be given the pause point
                    // 3. if no such, then the pause point will just be entered as a pause point by time

                    if (markerName != null)
                    {
                        if (this.markers != null)
                        {
                            TimelineMarker marker = markers.FirstOrDefault(m => (m.CoupledPausePoint == null) && (m.Name == markerName) && (m.RelativeTime == time));
                            if (marker == null)
                            {
                                marker = this.markers.FirstOrDefault(m => (m.CoupledPausePoint == null) && (m.Name == markerName));
                            }

                            if (marker != null)
                            {
                                pausePoint = marker.CreateCoupledPausePoint(this);
                            }
                        }
                    }

                    if (pausePoint == null)
                    {
                        if ((time >= TimeSpan.Zero) && (time <= this.Source.Duration))
                        {
                            pausePoint = this.AddAt(time);
                        }
                    }

                    if (pausePoint != null)
                    {
                        if (enabled)
                        {
                            newHasEnabled = true;
                        }
                        else
                        {
                            newHasDisabled       = true;
                            pausePoint.IsEnabled = false;
                        }
                    }
                }
            }

            this.ignore--;

            if (newHasEnabled)
            {
                this.UpdatePlaybackPausePoints();
            }

            this.IsDirty = false;

            this.HasEnabled  = newHasEnabled;
            this.HasDisabled = newHasDisabled;
        }