Example #1
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            e.Device.Capture(this);
            _lastPoint = e.GetPosition(this);

            var ev = new VectorEventArgs
            {
                RoutedEvent = DragStartedEvent,
                Vector = (Vector)_lastPoint,
            };

            RaiseEvent(ev);
        }
Example #2
0
        protected override void OnPointerMoved(PointerEventArgs e)
        {
            if (_lastPoint.HasValue)
            {
                var ev = new VectorEventArgs
                {
                    RoutedEvent = DragDeltaEvent,
                    Vector = e.GetPosition(this) - _lastPoint.Value,
                };

                RaiseEvent(ev);
            }
        }
Example #3
0
 protected override void OnDragDelta(VectorEventArgs e)
 {
     var delta = Orientation == Orientation.Vertical ? e.Vector.X : e.Vector.Y;
     double max;
     double min;
     GetDeltaConstraints(out min, out max);
     delta = Math.Min(Math.Max(delta, min), max);
     foreach (var definition in _definitions)
     {
         if (definition == _prevDefinition)
         {
             SetLengthInStars(_prevDefinition, GetActualLength(_prevDefinition) + delta);
         }
         else if (definition == _nextDefinition)
         {
             SetLengthInStars(_nextDefinition, GetActualLength(_nextDefinition) - delta);
         }
         else if (IsStar(definition))
         {
             SetLengthInStars(definition, GetActualLength(definition)); // same size but in stars.
         }
     }
 }
Example #4
0
        private void ThumbDragged(object sender, VectorEventArgs e)
        {
            double range = Maximum - Minimum;
            double value = Value;
            double offset;

            if (Orientation == Orientation.Horizontal)
            {
                offset = e.Vector.X / ((Bounds.Size.Width - Thumb.Bounds.Size.Width) / range);
            }
            else
            {
                offset = e.Vector.Y * (range / (Bounds.Size.Height - Thumb.Bounds.Size.Height));
            }

            if (!double.IsNaN(offset) && !double.IsInfinity(offset))
            {
                value += offset;
                value = Math.Max(value, Minimum);
                value = Math.Min(value, Maximum);
                Value = value;
            }
        }
Example #5
0
        protected override void OnPointerReleased(PointerEventArgs e)
        {
            if (_lastPoint.HasValue)
            {
                e.Device.Capture(null);
                _lastPoint = null;

                var ev = new VectorEventArgs
                {
                    RoutedEvent = DragCompletedEvent,
                    Vector = (Vector)e.GetPosition(this),
                };

                RaiseEvent(ev);
            }
        }
Example #6
0
 protected virtual void OnDragCompleted(VectorEventArgs e)
 {
 }
Example #7
0
 protected virtual void OnDragDelta(VectorEventArgs e)
 {
 }
Example #8
0
 protected virtual void OnDragStarted(VectorEventArgs e)
 {
 }
Example #9
0
 /// <summary>
 /// Called when user dragging the <see cref="Thumb"/>.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnThumbDragDelta(VectorEventArgs e)
 {
     Thumb thumb = e.Source as Thumb;
     if (thumb != null && _track.Thumb == thumb)
     {
         MoveToNextTick(_track.Value);
     }
 }