Exemplo n.º 1
0
        /// <summary>
        /// Initializes the <see cref="Slider"/> type.
        /// </summary>
        static Slider()
        {
            // Dependency property overrides
            ValueProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Double>(HandleValueChanged));
            MinimumProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Double>(HandleMinimumChanged));
            MaximumProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Double>(HandleMaximumChanged));
            SmallChangeProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Double>(HandleSmallChangeChanged));
            LargeChangeProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Double>(HandleLargeChangeChanged));

            // Commands - decrease
            CommandManager.RegisterClassBindings(typeof(Slider), DecreaseLargeCommand, ExecutedDecreaseLargeCommand,
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new KeyGesture(Key.PageUp, ModifierKeys.None, "PageUp")));
            CommandManager.RegisterClassBindings(typeof(Slider), DecreaseSmallCommand, ExecutedDecreaseSmallCommand,
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new KeyGesture(Key.Up, ModifierKeys.None, "Up")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new GamePadGesture(GamePadButton.LeftStickUp, 0, "LeftStickUp")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Horizontal, new KeyGesture(Key.Left, ModifierKeys.None, "Left")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Horizontal, new GamePadGesture(GamePadButton.LeftStickLeft, 0, "LeftStickLeft")));

            // Commands - increase
            CommandManager.RegisterClassBindings(typeof(Slider), IncreaseLargeCommand, ExecutedIncreaseLargeCommand,
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new KeyGesture(Key.PageUp, ModifierKeys.None, "PageDown")));
            CommandManager.RegisterClassBindings(typeof(Slider), IncreaseSmallCommand, ExecutedIncreaseSmallCommand,
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new KeyGesture(Key.Down, ModifierKeys.None, "Down")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Vertical, new GamePadGesture(GamePadButton.LeftStickDown, 0, "LeftStickDown")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Horizontal, new KeyGesture(Key.Right, ModifierKeys.None, "Right")),
                                                 new ConditionalGesture(src => (src as Slider)?.Orientation == Orientation.Horizontal, new GamePadGesture(GamePadButton.LeftStickRight, 0, "LeftStickRight")));

            // Commands - min/max
            CommandManager.RegisterClassBindings(typeof(Slider), MaximizeValueCommand, ExecutedMaximizeValueCommand,
                                                 new KeyGesture(Key.End, ModifierKeys.None, "End"));
            CommandManager.RegisterClassBindings(typeof(Slider), MinimizeValueCommand, ExecutedMinimizeValueCommand,
                                                 new KeyGesture(Key.Home, ModifierKeys.None, "Home"));
        }
Exemplo n.º 2
0
 static ExtendedProgressBar()
 {
     DefaultStyleKeyProperty.OverrideMetadata(typeof(ExtendedProgressBar), new FrameworkPropertyMetadata(typeof(ExtendedProgressBar)));
     BackgroundProperty.OverrideMetadata(typeof(ExtendedProgressBar), new FrameworkPropertyMetadata(Brushes.LightGray));
     BorderBrushProperty.OverrideMetadata(typeof(ExtendedProgressBar), new FrameworkPropertyMetadata(Brushes.Gray));
     ValueProperty.OverrideMetadata(typeof(ExtendedProgressBar), new FrameworkPropertyMetadata(0.0));
     MaximumProperty.OverrideMetadata(typeof(ExtendedProgressBar), new FrameworkPropertyMetadata(1.0));
 }
    public LogSlider()
    {
        InitializeComponent();
        var metadata = new FrameworkPropertyMetadata();

        metadata.PropertyChangedCallback += ValuePropertyChangedCallback;
        ValueProperty.OverrideMetadata(typeof(LogSlider), metadata);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes static members of the <see cref="Slider"/> class.
        /// </summary>
        static SliderEx()
        {
            PressedMixin.Attach <SliderEx>();
            OrientationProperty.OverrideDefaultValue(typeof(SliderEx), Orientation.Horizontal);
            Thumb.DragStartedEvent.AddClassHandler <SliderEx>((x, e) => x.OnThumbDragStarted(e), RoutingStrategies.Bubble);
            Thumb.DragCompletedEvent.AddClassHandler <SliderEx>((x, e) => x.OnThumbDragCompleted(e),
                                                                RoutingStrategies.Bubble);

            ValueProperty.OverrideMetadata <SliderEx>(new DirectPropertyMetadata <double>(enableDataValidation: true));
        }
        static RectangleProgressBar()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(RectangleProgressBar), new FrameworkPropertyMetadata(typeof(RectangleProgressBar)));

            MinimumProperty.OverrideMetadata(typeof(RectangleProgressBar), new FrameworkPropertyMetadata(0.0d));
            MaximumProperty.OverrideMetadata(typeof(RectangleProgressBar), new FrameworkPropertyMetadata(100.0d));
            ValueProperty.OverrideMetadata(typeof(RectangleProgressBar), new FrameworkPropertyMetadata(0d));

            EventManager.RegisterClassHandler(typeof(RectangleProgressBar), FrameworkElement.SizeChangedEvent, new SizeChangedEventHandler(OnSizeChanged));
        }
Exemplo n.º 6
0
        static RatingSlider()
        {
            ValueProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: 0d, RecalculateRelativeValues));
            MinimumProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: 0d, RecalculateRelativeValues));
            MaximumProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: 10d, RecalculateRelativeValues));

            WidthProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: 0d, RecalculateWidth));

            ForegroundProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: null, ResolveForeground));
            BackgroundProperty.OverrideMetadata(typeof(RatingSlider), new FrameworkPropertyMetadata(defaultValue: null, ResolveBackground));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static Fader()
        {
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(Fader),
                new FrameworkPropertyMetadata(typeof(Fader)));

            ValueProperty.OverrideMetadata(
                typeof(Fader),
                new FrameworkPropertyMetadata(
                    0.0,
                    ValuePropertyChanged));
        }
Exemplo n.º 8
0
        static ProgressRing()
        {
            MaximumProperty.Changed.Subscribe(CalibrateAngles);
            MinimumProperty.Changed.Subscribe(CalibrateAngles);
            ValueProperty.Changed.Subscribe(CalibrateAngles);

            MaximumProperty.OverrideMetadata <ProgressRing>(new DirectPropertyMetadata <double>(100));
            MinimumProperty.OverrideMetadata <ProgressRing>(new DirectPropertyMetadata <double>(0));
            ValueProperty.OverrideMetadata <ProgressRing>(new DirectPropertyMetadata <double>(25));

            AffectsRender <ProgressRing>(XAngleProperty, YAngleProperty);
        }
Exemplo n.º 9
0
 static ScaledSlider()
 {
     ValueProperty.OverrideMetadata(
         typeof(ScaledSlider),
         new FrameworkPropertyMetadata(propertyChangedCallback: (d, e) => {
         if (e.OldValue.Equals(e.NewValue))
         {
             return;
         }
         (d as ScaledSlider)?.SetValue(
             CustomValueProperty,
             ((ScaledSlider)d).ValueToCustom((double)e.NewValue));
     }));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes the <see cref="ScrollBar"/> type.
        /// </summary>
        static ScrollBar()
        {
            // Dependency property overrides
            ValueProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Double>(HandleValueChanged));
            MinimumProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Double>(HandleMinimumChanged));
            MaximumProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Double>(HandleMaximumChanged));
            SmallChangeProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Double>(HandleSmallChangeChanged));
            LargeChangeProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Double>(HandleLargeChangeChanged));
            FocusableProperty.OverrideMetadata(typeof(ScrollBar), new PropertyMetadata <Boolean>(CommonBoxedValues.Boolean.False));

            // Event handlers
            EventManager.RegisterClassHandler(typeof(ScrollBar), ScrollEvent, new UpfScrollEventHandler(HandleScrollEvent));

            // Commands - vertical scroll
            CommandManager.RegisterClassBindings(typeof(ScrollBar), LineDownCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Down, ModifierKeys.None, "Down"),
                                                 new GamePadGesture(GamePadButton.LeftStickDown, 0, "LeftStickDown"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), LineUpCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Up, ModifierKeys.None, "Up"),
                                                 new GamePadGesture(GamePadButton.LeftStickUp, 0, "LeftStickUp"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), PageDownCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.PageDown, ModifierKeys.None, "PageDown"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), PageUpCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.PageUp, ModifierKeys.None, "PageUp"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), ScrollToBottomCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.End, ModifierKeys.Control, "Ctrl+End"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), ScrollToTopCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Home, ModifierKeys.Control, "Ctrl+Home"));

            // Commands - horizontal scroll
            CommandManager.RegisterClassBindings(typeof(ScrollBar), LineRightCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Right, ModifierKeys.None, "Right"),
                                                 new GamePadGesture(GamePadButton.LeftStickRight, 0, "LeftStickRight"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), LineLeftCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Left, ModifierKeys.None, "Left"),
                                                 new GamePadGesture(GamePadButton.LeftStickLeft, 0, "LeftStickLeft"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), PageRightCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 null);
            CommandManager.RegisterClassBindings(typeof(ScrollBar), PageLeftCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 null);
            CommandManager.RegisterClassBindings(typeof(ScrollBar), ScrollToRightEndCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.End, ModifierKeys.None, "End"));
            CommandManager.RegisterClassBindings(typeof(ScrollBar), ScrollToLeftEndCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 new KeyGesture(Key.Home, ModifierKeys.None, "Home"));

            // Commands - misc
            CommandManager.RegisterClassBindings(typeof(ScrollBar), ScrollHereCommand, ExecutedScrollCommand, CanExecuteScrollCommand,
                                                 null);
        }
Exemplo n.º 11
0
        static RadialSlider()
        {
            MaximumProperty.Changed.Subscribe(CalibrateAngles);
            MinimumProperty.Changed.Subscribe(CalibrateAngles);
            ValueProperty.Changed.Subscribe(CalibrateAngles);

            BoundsProperty.Changed.Subscribe(UpdateRadius);
            StrokeWidthProperty.Changed.Subscribe(UpdateRadius);


            MaximumProperty.OverrideMetadata <RadialSlider>(new DirectPropertyMetadata <double>(100));
            MinimumProperty.OverrideMetadata <RadialSlider>(new DirectPropertyMetadata <double>(0));
            ValueProperty.OverrideMetadata <RadialSlider>(new DirectPropertyMetadata <double>(25));

            AffectsRender <RadialSlider>(XAngleProperty, YAngleProperty);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static Knob3D()
        {
            ValueProperty.OverrideMetadata(
                typeof(Knob3D),
                new UIPropertyMetadata(
                    ValuePropertyChanged));

            MinimumProperty.OverrideMetadata(
                typeof(Knob3D),
                new UIPropertyMetadata(
                    MinimumPropertyChanged));

            MaximumProperty.OverrideMetadata(
                typeof(Knob3D),
                new UIPropertyMetadata(
                    MaximumPropertyChanged));
        }
Exemplo n.º 13
0
        // Static constructor.
        static Slider3D()
        {
            OrientationProperty.OverrideMetadata(typeof(Slider3D),
                                                 new FrameworkPropertyMetadata(PropertyChanged));

            ValueProperty.OverrideMetadata(typeof(Slider3D),
                                           new FrameworkPropertyMetadata(PropertyChanged));

            MinimumProperty.OverrideMetadata(typeof(Slider3D),
                                             new FrameworkPropertyMetadata(PropertyChanged));

            MaximumProperty.OverrideMetadata(typeof(Slider3D),
                                             new FrameworkPropertyMetadata(PropertyChanged));

            IsDirectionReversedProperty.OverrideMetadata(typeof(Slider3D),
                                                         new FrameworkPropertyMetadata(PropertyChanged));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static Knob()
        {
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(Knob),
                new FrameworkPropertyMetadata(typeof(Knob))); // FrameworkPropertyMetadata is required

            ValueProperty.OverrideMetadata(
                typeof(Knob),
                new FrameworkPropertyMetadata(
                    OnValueChanged));

            MinimumProperty.OverrideMetadata(
                typeof(Knob),
                new FrameworkPropertyMetadata(
                    OnMinimumChanged));

            MaximumProperty.OverrideMetadata(
                typeof(Knob),
                new FrameworkPropertyMetadata(
                    OnMaximumChanged));
        }
Exemplo n.º 15
0
        static RangeBar()
        {
            DecrementCommand = new RoutedCommand("Decrement", typeof(RangeBar));
            IncrementCommand = new RoutedCommand("Increment", typeof(RangeBar));

            BlockCountProperty = DependencyProperty.Register(
                "BlockCount",
                typeof(int),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    5,
                    FrameworkPropertyMetadataOptions.AffectsRender,
                    null,
                    CoerceBlockCount));

            BlockMarginProperty = DependencyProperty.Register(
                "BlockMargin",
                typeof(double),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    (double)0,
                    FrameworkPropertyMetadataOptions.AffectsRender,
                    null,
                    CoerceBlockMargin));

            BlockBrushProperty = DependencyProperty.Register(
                "BlockBrush",
                typeof(Brush),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    Brushes.Yellow,
                    FrameworkPropertyMetadataOptions.AffectsRender,
                    null,
                    CoerceBlockBrush));

            FocusVisualStyleProperty.OverrideMetadata(
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    null,
                    FrameworkPropertyMetadataOptions.None,
                    null,
                    (d, value) => null));

            ClipToBoundsProperty.OverrideMetadata(
                typeof(RangeBar),
                new FrameworkPropertyMetadata(true));

            SnapsToDevicePixelsProperty.OverrideMetadata(
                typeof(RangeBar),
                new FrameworkPropertyMetadata(true));

            IsReadOnlyProperty = DependencyProperty.Register(
                "IsReadOnly",
                typeof(bool),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(false));

            PrecisionProperty = DependencyProperty.Register(
                "Precision",
                typeof(int),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    2,
                    null,
                    (d, baseValue) => ((int)baseValue < 0) ? 0 : (int)baseValue));

            IsSnappingEnabledProperty = DependencyProperty.Register(
                "IsSnappingEnabled",
                typeof(bool),
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    false,
                    (d, e) => d.CoerceValue(ValueProperty)));

            SmallChangeProperty.OverrideMetadata(
                typeof(RangeBar),
                new FrameworkPropertyMetadata(0.01));

            ValueProperty.OverrideMetadata(
                typeof(RangeBar),
                new FrameworkPropertyMetadata(
                    0.0,
                    FrameworkPropertyMetadataOptions.AffectsRender,
                    null,
                    CoerceValueProperty));
        }
 static NumericUpDown()
 {
     ValueProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(0.0, null, CoerceValueProperty));
 }