private void Point_DragDelta(object sender, DragDeltaEventArgs e) { DebugHelper.AssertUIThread(); FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement != null) { if (this.panel != null) { TimelineTimeProxy point = frameworkElement.DataContext as TimelineTimeProxy; if ((point != null) && point.IsFloating) { e.Handled = true; if ((point is TimelinePausePoint) || point.IsEnabled) { long ticks = point.RelativeTime.Ticks + (long)((e.HorizontalChange / this.panel.ActualWidth) * (this.panel.Maximum - this.panel.Minimum)); ticks = Math.Min(Math.Max(ticks, (long)panel.Minimum), (long)panel.Maximum); point.RelativeTime = TimeSpan.FromTicks(ticks); } } } } }
private void Point_DragCompleted(object sender, DragCompletedEventArgs e) { DebugHelper.AssertUIThread(); FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement != null) { TimelineTimeProxy point = frameworkElement.DataContext as TimelineTimeProxy; if ((point != null) && point.IsFloating) { TimelinePausePoint pausePoint = point as TimelinePausePoint; if (pausePoint != null) { if (this.PausePointsSource != null) { if (!point.HasMovedDuringLastFloat) { this.PausePointsSource.Remove(pausePoint); } } } point.IsFloating = false; } } }
private void Point_DragStarted(object sender, DragStartedEventArgs e) { DebugHelper.AssertUIThread(); FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement != null) { TimelineTimeProxy point = frameworkElement.DataContext as TimelineTimeProxy; if (point != null) { e.Handled = true; TimelinePausePoint pausePoint = point as TimelinePausePoint; if ((pausePoint != null) && pausePoint.HasCoupledMarker) { if (this.PausePointsSource != null) { this.PausePointsSource.OnTimePointDataChanged(pausePoint, pausePoint.RelativeTime, false, true, false); } } else if ((pausePoint != null) || point.IsEnabled) { point.IsFloating = true; } } } }
private void TimePointEdit_Executed(object sender, ExecutedRoutedEventArgs e) { DebugHelper.AssertUIThread(); if (e != null) { TimelineTimeProxy timePoint = e.Parameter as TimelineTimeProxy; if (timePoint != null) { e.Handled = true; Window window = Window.GetWindow(this); EditTimeSpanDialog dialog = new EditTimeSpanDialog() { Owner = window, Title = (timePoint is TimelinePausePoint) ? Strings.EditTimelinePausePoint_Title : Strings.EditTimeMarker_Title, Minimum = TimeSpan.Zero, Maximum = timePoint.Source.Duration, Value = timePoint.RelativeTime, }; if (dialog.ShowDialog() == true) { if (dialog.Value != timePoint.RelativeTime) { this.PausePointsSource.RemoveAt(dialog.Value); timePoint.RelativeTime = dialog.Value; } } } } }
private void TimePointEdit_CanExecute(object sender, CanExecuteRoutedEventArgs e) { DebugHelper.AssertUIThread(); if (e != null) { TimelineTimeProxy point = e.Parameter as TimelineTimeProxy; if (point != null) { e.Handled = true; e.CanExecute = !point.IsReadOnly; } } }
private void TimePointRemove_Executed(object sender, ExecutedRoutedEventArgs e) { DebugHelper.AssertUIThread(); if (e != null) { TimelineTimeProxy point = e.Parameter as TimelineTimeProxy; if (point != null) { e.Handled = true; point.Remove(); } } }
protected override void OnMouseDown(MouseButtonEventArgs e) { DebugHelper.AssertUIThread(); if (e != null) { switch (e.ChangedButton) { case MouseButton.Left: { if (this.panel != null) { this.newPointMouseEventArgs = e; Point pt = e.GetPosition(this.panel); ulong min = this.panel.Minimum; ulong max = this.panel.Maximum; double v = min + (max - min) * (pt.X / this.panel.ActualWidth); TimeSpan relativeTime = TimeSpan.FromTicks((long)v); Point ptMarkers = e.GetPosition(this.MarkersItemsControl); Point ptPausePoints = e.GetPosition(this.PausePointsItemsControl); TimelineTimeProxy point = null; if ((ptMarkers.X >= 0) && (ptMarkers.Y >= 0) && (ptMarkers.X <= this.MarkersItemsControl.ActualWidth) && (ptMarkers.Y <= this.MarkersItemsControl.ActualHeight)) { if ((this.MarkersSource != null) && !this.MarkersSource.IsReadOnly) { string name = this.GetUniqueMarkerName(); point = this.MarkersSource.AddAt(relativeTime, name); } } if ((ptPausePoints.X >= 0) && (ptPausePoints.Y >= 0) && (ptPausePoints.X <= this.PausePointsItemsControl.ActualWidth) && (ptPausePoints.Y <= this.PausePointsItemsControl.ActualHeight)) { if (this.PausePointsSource != null) { point = this.PausePointsSource.AddAt(relativeTime); } } if (point != null) { // immediately let the pause point be draggable point.IsFloating = true; point.ForceHasMovedDuringLastFloat(); } } break; } case MouseButton.Right: { if (this.panel != null) { Point pt = e.GetPosition(this.panel); this.newPointTime = TimeSpan.FromTicks((long)(this.panel.Minimum + ((this.panel.Maximum - this.panel.Minimum) * (pt.X / this.panel.ActualWidth)))); } break; } } } base.OnMouseDown(e); }