コード例 #1
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
        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);
        }
コード例 #2
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
        protected override void OnPointerMoved(PointerEventArgs e)
        {
            if (_lastPoint.HasValue)
            {
                var ev = new VectorEventArgs
                {
                    RoutedEvent = DragDeltaEvent,
                    Vector = e.GetPosition(this) - _lastPoint.Value,
                };

                RaiseEvent(ev);
            }
        }
コード例 #3
0
ファイル: GridSplitter.cs プロジェクト: CarlSosaDev/Avalonia
 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.
         }
     }
 }
コード例 #4
0
ファイル: Track.cs プロジェクト: CarlSosaDev/Avalonia
        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;
            }
        }
コード例 #5
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
        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);
            }
        }
コード例 #6
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
 protected virtual void OnDragCompleted(VectorEventArgs e)
 {
 }
コード例 #7
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
 protected virtual void OnDragDelta(VectorEventArgs e)
 {
 }
コード例 #8
0
ファイル: Thumb.cs プロジェクト: CarlSosaDev/Avalonia
 protected virtual void OnDragStarted(VectorEventArgs e)
 {
 }
コード例 #9
0
ファイル: Slider.cs プロジェクト: CarlSosaDev/Avalonia
 /// <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);
     }
 }