private static void OnSelectionStartChanged(SliderEx slider, AvaloniaPropertyChangedEventArgs e)
        {
            double oldValue = (double)e.OldValue;
            double newValue = (double)e.NewValue;

            slider.UpdateSelectionRangeElementPositionAndSize();
        }
Exemple #2
0
        private void Parent_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
        {
            SliderEx parent = sender as SliderEx;

            if (parent != null)
            {
                UpdateProperties(parent);
            }
        }
Exemple #3
0
        private static void OnValueChanged(SliderEx slider, AvaloniaPropertyChangedEventArgs e)
        {
            slider.UpdateSelectionRangeElementPositionAndSize();

            double?oldValue = e.OldValue as double?;
            double?newValue = e.NewValue as double?;

            slider.OnValueChanged(oldValue.HasValue ? oldValue.Value : 0.0,
                                  newValue.HasValue ? newValue.Value : 0.0);
        }
        private void _OnMouseLeftButtonDown(PointerPressedEventArgs e)
        {
            SliderEx sliderEx = e.Source as SliderEx;

            // When someone click on the Slider's part, and it's not focusable
            // Slider need to take the focus in order to process keyboard correctly

            //if (!sliderEx.IsKeyboardFocusWithin)
            //{
            //    e.Handled = sliderEx.IsFocused || e.Handled;
            //}
        }
Exemple #5
0
        /// <summary>
        /// gets the parent <see cref="SliderEx"/>
        /// and the Track
        /// </summary>
        public override void ApplyTemplate()
        {
            base.ApplyTemplate();

            SliderEx parent = TemplatedParent as SliderEx;
            Track    track  = parent?.FindChild <Track>();

            if (parent != null)
            {
                UpdateProperties(parent);
                parent.PropertyChanged += Parent_PropertyChanged;

                if (track != null)
                {
                    track.PropertyChanged += Track_PropertyChanged;
                    UpdateProperties(track);
                }

                //BindToTemplatedParent(TicksProperty, SliderEx.TicksProperty);
                //BindToTemplatedParent(TickFrequencyProperty, SliderEx.TickFrequencyProperty);
                //BindToTemplatedParent(IsSelectionRangeEnabledProperty, SliderEx.IsSelectionRangeEnabledProperty);
                //BindToTemplatedParent(SelectionStartProperty, SliderEx.SelectionStartProperty);
                //BindToTemplatedParent(SelectionEndProperty, SliderEx.SelectionEndProperty);
                //BindToTemplatedParent(MinimumProperty, SliderEx.MinimumProperty);
                //BindToTemplatedParent(MaximumProperty, SliderEx.MaximumProperty);
                //BindToTemplatedParent(IsDirectionReversedProperty, Track.IsDirectionReversedProperty);

                //if (/*!HasNonDefaultValue(ReservedSpaceProperty) &&*/ track != null)
                //{
                //    Binding binding = new Binding();
                //    //binding.Source = track.Thumb;

                //    if (parent.Orientation == Layout.Orientation.Horizontal)
                //    {
                //        //binding.Path = new PropertyPath(Thumb.WidthProperty);
                //        Bind(ReservedSpaceProperty, ObservableEx.SingleValue(Thumb.WidthProperty));
                //    }
                //    else
                //    {
                //        //binding.Path = new PropertyPath(Thumb.HeightProperty);
                //        Bind(ReservedSpaceProperty, ObservableEx.SingleValue(Thumb.HeightProperty));
                //    }

                //    //SetBinding(ReservedSpaceProperty, binding);
                //}
            }
        }
Exemple #6
0
        private void UpdateProperties(Track track)
        {
            SliderEx parent = TemplatedParent as SliderEx;

            IsDirectionReversed = track.IsDirectionReversed;

            if (track.Thumb != null)
            {
                if (parent.Orientation == Layout.Orientation.Horizontal)
                {
                    ReservedSpace = track.Thumb.Width;
                }
                else
                {
                    ReservedSpace = track.Thumb.Height;
                }
            }
        }
Exemple #7
0
        private void UpdateProperties(SliderEx parent)
        {
            //Width = parent.Width;
            Ticks                   = parent.Ticks;
            TickFrequency           = parent.TickFrequency;
            IsSelectionRangeEnabled = parent.IsSelectionRangeEnabled;
            SelectionStart          = parent.SelectionStart;
            SelectionEnd            = parent.SelectionEnd;
            Minimum                 = parent.Minimum;
            Maximum                 = parent.Maximum;

            //Track  track= parent.FindChild<Track>(true);
            //if (track?.Thumb != null)
            //{
            //    if (parent.Orientation == Layout.Orientation.Horizontal)
            //    {
            //        ReservedSpace = track.Thumb.Width;
            //    }
            //    else
            //    {
            //        ReservedSpace = track.Thumb.Height;
            //    }
            //}
        }
 private static void OnThumbDragStarted(SliderEx sliderEx, VectorEventArgs args)
 {
     sliderEx.OnThumbDragStarted(args);
 }
 private static void OnThumbDragDelta(SliderEx sliderEx, VectorEventArgs args)
 {
     sliderEx.OnThumbDragDelta(args);
 }
 private static void OnSelectionEndChanged(SliderEx slider, AvaloniaPropertyChangedEventArgs e)
 {
     slider.UpdateSelectionRangeElementPositionAndSize();
 }
        private static void OnTickPlacementChanged(SliderEx slider, AvaloniaPropertyChangedEventArgs e)
        {
            if (slider.TopTickBar == null || slider.BottomTickBar == null)
            {
                return;
            }

            //strange behaviour in the view
            //right now we skip this
            if (slider.Orientation == Orientation.Vertical)
            {
                return;
            }

            //TopTickBar.Width = this.Width;
            //BottomTickBar.Width = this.Width;

            if (slider.Track?.Thumb != null)
            {
                switch (slider.Orientation)
                {
                case Orientation.Horizontal:
                    if (DoubleUtil.IsDoubleFinite(slider.Track.Thumb.Width))
                    {
                        slider.TopTickBar.ReservedSpace = slider.Track.Thumb.Width;
                    }
                    break;

                case Orientation.Vertical:
                    if (DoubleUtil.IsDoubleFinite(slider.Track.Thumb.Height))
                    {
                        slider.TopTickBar.ReservedSpace = slider.Track.Thumb.Height;
                    }
                    break;
                }
            }

            if (slider.Orientation == Orientation.Horizontal)
            {
                slider.Track.Thumb.Classes.Set("HorizontalSliderUpThumbStyle", slider.TickPlacement == TickPlacement.TopLeft);
                slider.Track.Thumb.Classes.Set("HorizontalSliderDownThumbStyle", slider.TickPlacement == TickPlacement.BottomRight);
            }
            else
            {
                slider.Track.Thumb.Classes.Set("VerticalSliderLeftThumbStyle", slider.TickPlacement == TickPlacement.TopLeft);
                slider.Track.Thumb.Classes.Set("VerticalSliderRightThumbStyle", slider.TickPlacement == TickPlacement.BottomRight);
            }

            TickPlacement tickBarPlacement = (TickPlacement)e.NewValue;

            switch (tickBarPlacement)
            {
            case TickPlacement.None:
                slider.TopTickBar.IsVisible    = false;
                slider.BottomTickBar.IsVisible = false;
                break;

            case TickPlacement.TopLeft:
                slider.TopTickBar.IsVisible = true;
                if (slider.Orientation == Orientation.Horizontal)
                {
                    slider.TrackBackground.Margin = new Thickness(5, 2, 5, 0);
                }
                else
                {
                    slider.TrackBackground.Margin = new Thickness(2, 5, 0, 5);
                }
                break;

            case TickPlacement.BottomRight:
                slider.BottomTickBar.IsVisible = true;
                if (slider.Orientation == Orientation.Horizontal)
                {
                    slider.TrackBackground.Margin = new Thickness(5, 2, 5, 0);
                }
                else
                {
                    slider.TrackBackground.Margin = new Thickness(0, 5, 2, 5);
                }
                break;

            case TickPlacement.Both:
                slider.TopTickBar.IsVisible    = true;
                slider.BottomTickBar.IsVisible = true;
                break;
            }
        }