示例#1
0
        /// <summary>
        /// Initializes the <see cref="Slider"/> type.
        /// </summary>
        static Slider()
        {
            // Dependency property overrides.
            FocusableProperty.OverrideMetadata(typeof(Slider), new PropertyMetadata <Boolean>(CommonBoxedValues.Boolean.False));
            MinimumProperty.AddOwner(typeof(Slider), new PropertyMetadata <Double>(CommonBoxedValues.Double.Zero, PropertyMetadataOptions.AffectsMeasure));
            MaximumProperty.AddOwner(typeof(Slider), new PropertyMetadata <Double>(10.0, PropertyMetadataOptions.AffectsMeasure));
            ValueProperty.AddOwner(typeof(Slider), new PropertyMetadata <Double>(CommonBoxedValues.Double.Zero, PropertyMetadataOptions.AffectsArrange));

            // 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"));
        }
示例#2
0
        /// <summary>
        /// Initializes the <see cref="OrientedSlider"/> type.
        /// </summary>
        static OrientedSlider()
        {
            // Dependency properties
            MinimumProperty.AddOwner(typeof(OrientedSlider), new PropertyMetadata <Double>(CommonBoxedValues.Double.Zero, PropertyMetadataOptions.AffectsMeasure));
            MaximumProperty.AddOwner(typeof(OrientedSlider), new PropertyMetadata <Double>(10.0, PropertyMetadataOptions.AffectsMeasure));
            ValueProperty.AddOwner(typeof(OrientedSlider), new PropertyMetadata <Double>(CommonBoxedValues.Double.Zero, PropertyMetadataOptions.AffectsArrange));

            // Event handlers
            EventManager.RegisterClassHandler(typeof(OrientedSlider), Mouse.PreviewMouseDownEvent, new UpfMouseButtonEventHandler(HandlePreviewMouseDown));
            EventManager.RegisterClassHandler(typeof(OrientedSlider), Thumb.DragStartedEvent, new UpfDragStartedEventHandler(HandleThumbDragStarted));
            EventManager.RegisterClassHandler(typeof(OrientedSlider), Thumb.DragDeltaEvent, new UpfDragDeltaEventHandler(HandleThumbDragDelta));
            EventManager.RegisterClassHandler(typeof(OrientedSlider), Thumb.DragCompletedEvent, new UpfDragCompletedEventHandler(HandleThumbDragCompleted));

            // Commands - decrease
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.DecreaseLargeCommand, ExecutedDecreaseLargeCommand,
                                                 new KeyGesture(Key.PageUp, ModifierKeys.None, "PageUp"));
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.DecreaseSmallCommand, ExecutedDecreaseSmallCommand,
                                                 new ConditionalGesture(src => (src is VSlider) && !((VSlider)src).IsDirectionReversed, new KeyGesture(Key.Up, ModifierKeys.None, "Up")),
                                                 new ConditionalGesture(src => (src is VSlider) && !((VSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickUp, 0, "LeftStickUp")),
                                                 new ConditionalGesture(src => (src is HSlider) && !((HSlider)src).IsDirectionReversed, new KeyGesture(Key.Left, ModifierKeys.None, "Left")),
                                                 new ConditionalGesture(src => (src is HSlider) && !((HSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickLeft, 0, "LeftStickLeft")),
                                                 new ConditionalGesture(src => (src is VSlider) && ((VSlider)src).IsDirectionReversed, new KeyGesture(Key.Down, ModifierKeys.None, "Down")),
                                                 new ConditionalGesture(src => (src is VSlider) && ((VSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickDown, 0, "LeftStickDown")),
                                                 new ConditionalGesture(src => (src is HSlider) && ((HSlider)src).IsDirectionReversed, new KeyGesture(Key.Right, ModifierKeys.None, "Right")),
                                                 new ConditionalGesture(src => (src is HSlider) && ((HSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickRight, 0, "LeftStickRight")));

            // Commands - increase
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.IncreaseLargeCommand, ExecutedIncreaseLargeCommand,
                                                 new KeyGesture(Key.PageDown, ModifierKeys.None, "PageDown"));
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.IncreaseSmallCommand, ExecutedIncreaseSmallCommand,
                                                 new ConditionalGesture(src => (src is VSlider) && !((VSlider)src).IsDirectionReversed, new KeyGesture(Key.Down, ModifierKeys.None, "Down")),
                                                 new ConditionalGesture(src => (src is VSlider) && !((VSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickDown, 0, "LeftStickDown")),
                                                 new ConditionalGesture(src => (src is HSlider) && !((HSlider)src).IsDirectionReversed, new KeyGesture(Key.Right, ModifierKeys.None, "Right")),
                                                 new ConditionalGesture(src => (src is HSlider) && !((HSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickRight, 0, "LeftStickRight")),
                                                 new ConditionalGesture(src => (src is VSlider) && ((VSlider)src).IsDirectionReversed, new KeyGesture(Key.Up, ModifierKeys.None, "up")),
                                                 new ConditionalGesture(src => (src is VSlider) && ((VSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickUp, 0, "LeftStickUp")),
                                                 new ConditionalGesture(src => (src is HSlider) && ((HSlider)src).IsDirectionReversed, new KeyGesture(Key.Left, ModifierKeys.None, "Left")),
                                                 new ConditionalGesture(src => (src is HSlider) && ((HSlider)src).IsDirectionReversed, new GamePadGesture(GamePadButton.LeftStickLeft, 0, "LeftStickLeft")));

            // Commands - min/max
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.MaximizeValueCommand, ExecutedMaximizeValueCommand,
                                                 new KeyGesture(Key.End, ModifierKeys.None, "End"));
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Slider.MinimizeValueCommand, ExecutedMinimizeValueCommand,
                                                 new KeyGesture(Key.Home, ModifierKeys.None, "Home"));

            // Commands - track
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Track.IncreaseCommand, ExecutedIncreaseLargeCommand);
            CommandManager.RegisterClassBindings(typeof(OrientedSlider), Track.DecreaseCommand, ExecutedDecreaseLargeCommand);
        }
 static ProgressBar()
 {
     MinimumProperty.AddOwner(typeof(ProgressBar), new PropertyMetadata(0.0));
     MaximumProperty.AddOwner(typeof(ProgressBar), new PropertyMetadata(100.0));
 }
示例#4
0
 static Slider()
 {
     MinimumProperty.AddOwner(typeof(Slider), new PropertyMetadata(0.0));
     MaximumProperty.AddOwner(typeof(Slider), new PropertyMetadata(100.0));
     ValueProperty.AddOwner(typeof(Slider), new PropertyMetadata(0.0));
 }