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;
        }
Beispiel #2
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;
        }