Пример #1
0
 void ProgressSliderElement_Seeked(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         bool canceled = false;
         ViewModel.Seek(TimeSpan.FromSeconds(e.Value), out canceled);
         e.Canceled = canceled;
     }
 }
Пример #2
0
 void ProgressSliderElement_ScrubbingCompleted(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         bool canceled = false;
         ViewModel.CompleteScrub(TimeSpan.FromSeconds(e.Value), ref canceled);
         e.Canceled = canceled;
     }
 }
Пример #3
0
 /// <summary>
 /// Invokes the Seeked event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnSeeked(ValueRoutedEventArgs e)
 {
     if (Seeked != null)
     {
         ignoreValueChanged = true;
         try
         {
             Seeked(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
Пример #4
0
 /// <summary>
 /// Invokes the Scrubbing event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnScrubbing(ValueRoutedEventArgs e)
 {
     if (Scrubbing != null)
     {
         ignoreValueChanged = true;
         try
         {
             Scrubbing(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
 /// <summary>
 /// Invokes the Seeked event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnSeeked(ValueRoutedEventArgs e)
 {
     if (Seeked != null)
     {
         ignoreValueChanged = true;
         try
         {
             Seeked(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
Пример #6
0
 /// <summary>
 /// Invokes the ScrubbingCompleted event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnScrubbingCompleted(ValueRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "NotScrubbing", true);
     if (ScrubbingCompleted != null)
     {
         ignoreValueChanged = true;
         try
         {
             ScrubbingCompleted(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
Пример #7
0
 void ProgressSliderElement_ScrubbingStarted(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         var  vm       = ViewModel; // hold onto this in case the ViewModel changes because of this action. This way we can ensure we're calling the same one.
         bool canceled = false;
         vm.StartScrub(TimeSpan.FromSeconds(e.Value), out canceled);
         if (canceled)
         {
             ProgressSliderElement.CancelScrub();
             vm.CompleteScrub(TimeSpan.FromSeconds(e.Value), ref canceled);
         }
         e.Canceled = canceled;
     }
 }
Пример #8
0
 /// <inheritdoc />
 protected override void OnValueChanged(double oldValue, double newValue)
 {
     if (!ignoreValueChanged)
     {
         var value = Math.Min(newValue, Max);
         if (inboundValue || !IsEnabled)
         {
             base.OnValueChanged(oldValue, value);
         }
         else
         {
             var args = new ValueRoutedEventArgs(value);
             if (IsScrubbing)
             {
                 OnScrubbing(args);
             }
             else
             {
                 OnSeeked(args);
             }
             if (!args.Canceled)
             {
                 base.OnValueChanged(oldValue, value);
             }
             else
             {
                 inboundValue = true;
                 try
                 {
                     Value = oldValue;
                 }
                 finally
                 {
                     inboundValue = false;
                 }
             }
         }
     }
 }
Пример #9
0
        private void bar_PointerPressed(object sender, PointerRoutedEventArgs e)
#endif
        {
#if SILVERLIGHT
            pointerCaptured = ((FrameworkElement)sender).CaptureMouse();
#else
            pointerCaptured = ((FrameworkElement)sender).CapturePointer(e.Pointer);
#endif
            UpdateScrubbingVisualState();
            if (pointerCaptured)
            {
#if SILVERLIGHT
                pointerReleaseAction = () => ((FrameworkElement)sender).ReleaseMouseCapture();
#else
                pointerReleaseAction = () => ((FrameworkElement)sender).ReleasePointerCapture(e.Pointer);
#endif
                double?newValue = null;
                if (Orientation == Orientation.Horizontal)
                {
                    newValue = GetHorizontalPanelMousePosition(e);
                }
                else
                {
                    newValue = GetVerticalPanelMousePosition(e);
                }

                if (newValue.HasValue)
                {
                    var value = Math.Min(newValue.Value, Max);
                    var args  = new ValueRoutedEventArgs(value);
                    OnScrubbingStarted(args);
                    if (!args.Canceled)
                    {
                        Value = value;
                    }
                }
            }
            e.Handled = true;
        }
Пример #10
0
 void ProgressSliderElement_ScrubbingStarted(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         var vm = ViewModel; // hold onto this in case the ViewModel changes because of this action. This way we can ensure we're calling the same one.
         bool canceled = false;
         vm.StartScrub(TimeSpan.FromSeconds(e.Value), out canceled);
         if (canceled)
         {
             ProgressSliderElement.CancelScrub();
             vm.CompleteScrub(TimeSpan.FromSeconds(e.Value), ref canceled);
         }
         e.Canceled = canceled;
     }
 }
Пример #11
0
 void ProgressSliderElement_ScrubbingCompleted(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         bool canceled = false;
         ViewModel.CompleteScrub(TimeSpan.FromSeconds(e.Value), ref canceled);
         e.Canceled = canceled;
     }
 }
Пример #12
0
 void ProgressSliderElement_Seeked(object sender, ValueRoutedEventArgs e)
 {
     if (ViewModel != null)
     {
         bool canceled = false;
         ViewModel.Seek(TimeSpan.FromSeconds(e.Value), out canceled);
         e.Canceled = canceled;
     }
 }
 /// <summary>
 /// Invokes the ScrubbingCompleted event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnScrubbingCompleted(ValueRoutedEventArgs e)
 {
     VisualStateManager.GoToState(this, "NotScrubbing", true);
     if (ScrubbingCompleted != null)
     {
         ignoreValueChanged = true;
         try
         {
             ScrubbingCompleted(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
 /// <inheritdoc /> 
 protected override void OnValueChanged(double oldValue, double newValue)
 {
     if (!ignoreValueChanged)
     {
         var value = Math.Min(newValue, Max);
         if (inboundValue || !IsEnabled)
         {
             base.OnValueChanged(oldValue, value);
         }
         else
         {
             var args = new ValueRoutedEventArgs(value);
             if (IsScrubbing)
             {
                 OnScrubbing(args);
             }
             else
             {
                 OnSeeked(args);
             }
             if (!args.Canceled)
             {
                 base.OnValueChanged(oldValue, value);
             }
             else
             {
                 inboundValue = true;
                 try
                 {
                     Value = oldValue;
                 }
                 finally
                 {
                     inboundValue = false;
                 }
             }
         }
     }
 }
 /// <summary>
 /// Invokes the Scrubbing event.
 /// </summary>
 /// <param name="e">EventArgs used to provide info about the event</param>
 protected void OnScrubbing(ValueRoutedEventArgs e)
 {
     if (Scrubbing != null)
     {
         ignoreValueChanged = true;
         try
         {
             Scrubbing(this, e);
         }
         finally { ignoreValueChanged = false; }
     }
 }
        private void bar_PointerPressed(object sender, PointerRoutedEventArgs e)
#endif
        {
#if SILVERLIGHT
            pointerCaptured = ((FrameworkElement)sender).CaptureMouse();
#else
            pointerCaptured = ((FrameworkElement)sender).CapturePointer(e.Pointer);
#endif
            UpdateScrubbingVisualState();
            if (pointerCaptured)
            {
#if SILVERLIGHT
                pointerReleaseAction = () => ((FrameworkElement)sender).ReleaseMouseCapture();
#else
                pointerReleaseAction = () => ((FrameworkElement)sender).ReleasePointerCapture(e.Pointer);
#endif
                double? newValue = null;
                if (Orientation == Orientation.Horizontal) newValue = GetHorizontalPanelMousePosition(e);
                else newValue = GetVerticalPanelMousePosition(e);

                if (newValue.HasValue)
                {
                    var value = Math.Min(newValue.Value, Max);
                    var args = new ValueRoutedEventArgs(value);
                    OnScrubbingStarted(args);
                    if (!args.Canceled)
                    {
                        Value = value;
                    }
                }
            }
            e.Handled = true;
        }