コード例 #1
0
 public static void SetSliderValue(RangeBase control, double value)
 {
     if (control != null)
     {
         control.Value = value;
     }
 }
コード例 #2
0
ファイル: RangeBaseAutomationPeer.cs プロジェクト: dfr0/moon
		public RangeBaseAutomationPeer (RangeBase owner)
			: base (owner)
		{
			// UIA Event RangeValuePatternIdentifiers.ValueProperty
			// Raised by RangeBase.OnValuePropertyChanged()
			owner.IsEnabledChanged += (o, e) => {
				RaisePropertyChangedEvent (RangeValuePatternIdentifiers.IsReadOnlyProperty, 
				                           e.OldValue, 
							   e.NewValue);
			};
			owner.UIAPropertyChanged += (o, e) => {
				AutomationProperty property = null;
				switch (e.Change) {
				case RangeBase.Change.Large: 
					property = RangeValuePatternIdentifiers.LargeChangeProperty;
					break;
				case RangeBase.Change.Small: 
					property = RangeValuePatternIdentifiers.SmallChangeProperty;
					break;
				case RangeBase.Change.Maximum: 
					property = RangeValuePatternIdentifiers.MaximumProperty;
					break;
				case RangeBase.Change.Minimum: 
					property = RangeValuePatternIdentifiers.MinimumProperty;
					break;
				}
				RaisePropertyChangedEvent (property,
				                           e.OldValue, 
							   e.NewValue);
			};
		}
コード例 #3
0
        // Token: 0x06005F4A RID: 24394 RVA: 0x001AB80C File Offset: 0x001A9A0C
        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase rangeBase = (RangeBase)d;
            RangeBaseAutomationPeer rangeBaseAutomationPeer = UIElementAutomationPeer.FromElement(rangeBase) as RangeBaseAutomationPeer;

            if (rangeBaseAutomationPeer != null)
            {
                rangeBaseAutomationPeer.RaiseValuePropertyChangedEvent((double)e.OldValue, (double)e.NewValue);
            }
            rangeBase.OnValueChanged((double)e.OldValue, (double)e.NewValue);
        }
コード例 #4
0
        private static object CoerceMaximum(DependencyObject d, object value)
        {
            RangeBase ctrl = (RangeBase)d;
            double    min  = ctrl.Minimum;

            if ((double)value < min)
            {
                return(min);
            }
            return(value);
        }
コード例 #5
0
ファイル: RangeBase.cs プロジェクト: ynkbt/moon
        /// <summary>
        /// SmallChangeProperty property changed handler.
        /// </summary>
        /// <param name="d">RangeBase that changed its SmallChange.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnSmallChangePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase range = d as RangeBase;

            Debug.Assert(range != null);

            // Ensure it's a valid value
            if (!IsValidChange(e.NewValue))
            {
                throw new ArgumentException(Resource.RangeBase_InvalidChangeValue, SmallChangeProperty.ToString());
            }
        }
コード例 #6
0
ファイル: RangeBase.cs プロジェクト: ynkbt/moon
        /// <summary>
        /// MinimumProperty property changed handler.
        /// </summary>
        /// <param name="d">RangeBase that changed its Minimum.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        ///
        private static void OnMinimumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase range = d as RangeBase;

            Debug.Assert(range != null);

            // Ensure it's a valid value
            if (!IsValidDoubleValue(e.NewValue))
            {
                throw new ArgumentException();
            }

            // Note: this section is a workaround, containing my
            // logic to hold all calls to the property changed
            // methods until after all coercion has completed
            // ----------
            if (range._levelsFromRootCall == 0)
            {
                range._initialMax = range.Maximum;
                range._initialVal = range.Value;
            }
            range._levelsFromRootCall++;
            // ----------

            range.CoerceMaximum();
            range.CoerceValue();

            // Note: this section completes my workaround to call
            // the property changed logic if all coercion has completed
            // ----------
            range._levelsFromRootCall--;
            if (range._levelsFromRootCall == 0)
            {
                range.OnMinimumChanged((double)e.OldValue, (double)e.NewValue);
                // UIA event
                range.RaiseChangeEvent(Change.Minimum, (double)e.OldValue, (double)e.NewValue);
                double maximum = range.Maximum;
                if (range._initialMax != maximum)
                {
                    range.OnMaximumChanged(range._initialMax, maximum);
                    // UIA event
                    range.RaiseChangeEvent(Change.Maximum, range._initialMax, maximum);
                }
                double value = range.Value;
                if (range._initialVal != value)
                {
                    range.OnValueChanged(range._initialVal, value);
                }
            }
            // ----------
        }
コード例 #7
0
        /// <summary>
        ///     Called when MaximumProperty is changed on "d."
        /// </summary>
        private static void OnMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase ctrl = (RangeBase)d;

            RangeBaseAutomationPeer peer = UIElementAutomationPeer.FromElement(ctrl) as RangeBaseAutomationPeer;

            if (peer != null)
            {
                peer.RaiseMaximumPropertyChangedEvent((double)e.OldValue, (double)e.NewValue);
            }

            ctrl.CoerceValue(ValueProperty);
            ctrl.OnMaximumChanged((double)e.OldValue, (double)e.NewValue);
        }
コード例 #8
0
ファイル: RangeBase.cs プロジェクト: ynkbt/moon
        /// <summary>
        /// SmallChangeProperty property changed handler.
        /// </summary>
        /// <param name="d">RangeBase that changed its SmallChange.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnSmallChangePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase range = d as RangeBase;

            Debug.Assert(range != null);

            // Ensure it's a valid value
            if (!IsValidChange(e.NewValue))
            {
                throw new ArgumentException();
            }

            // UIA event
            range.RaiseChangeEvent(Change.Small, (double)e.OldValue, (double)e.NewValue);
        }
コード例 #9
0
ファイル: RangeBase.cs プロジェクト: ynkbt/moon
        /// <summary>
        /// ValueProperty property changed handler.
        /// </summary>
        /// <param name="d">RangeBase that changed its Value.</param>
        /// <param name="e">DependencyPropertyChangedEventArgs.</param>
        private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RangeBase range = d as RangeBase;

            Debug.Assert(range != null);

            // Ensure it's a valid value
            if (!IsValidDoubleValue(e.NewValue))
            {
                throw new ArgumentException();
            }

            // Note: this section is a workaround, containing my
            // logic to hold all calls to the property changed
            // methods until after all coercion has completed
            // ----------
            if (range._levelsFromRootCall == 0)
            {
                range._requestedVal = (double)e.NewValue;
                range._initialVal   = (double)e.OldValue;
            }
            range._levelsFromRootCall++;
            // ----------

            range.CoerceValue();

            // Note: this section completes my workaround to call
            // the property changed logic if all coercion has completed
            // ----------
            range._levelsFromRootCall--;
            if (range._levelsFromRootCall == 0)
            {
                double value = range.Value;
                if (range._initialVal != value)
                {
                    range.OnValueChanged(range._initialVal, value);

                    // Raises UIA event
                    if (range.AutomationPeer != null)
                    {
                        range.AutomationPeer.RaisePropertyChangedEvent(RangeValuePatternIdentifiers.ValueProperty,
                                                                       e.OldValue,
                                                                       e.NewValue);
                    }
                }
            }
            // ----------
        }
コード例 #10
0
        // Token: 0x06005F47 RID: 24391 RVA: 0x001AB7A4 File Offset: 0x001A99A4
        internal static object ConstrainToRange(DependencyObject d, object value)
        {
            RangeBase rangeBase = (RangeBase)d;
            double    minimum   = rangeBase.Minimum;
            double    num       = (double)value;

            if (num < minimum)
            {
                return(minimum);
            }
            double maximum = rangeBase.Maximum;

            if (num > maximum)
            {
                return(maximum);
            }
            return(value);
        }
コード例 #11
0
        // made this internal because Slider wants to leverage it
        internal static object ConstrainToRange(DependencyObject d, object value)
        {
            RangeBase ctrl = (RangeBase)d;
            double    min  = ctrl.Minimum;
            double    v    = (double)value;

            if (v < min)
            {
                return(min);
            }

            double max = ctrl.Maximum;

            if (v > max)
            {
                return(max);
            }

            return(value);
        }
コード例 #12
0
        /// <summary>
        /// Track automatically sets bindings to its templated parent
        /// to aid styling
        /// </summary>
        internal override void OnPreApplyTemplate()
        {
            base.OnPreApplyTemplate();

            RangeBase rangeBase = TemplatedParent as RangeBase;

            if (rangeBase != null)
            {
                BindToTemplatedParent(MinimumProperty, RangeBase.MinimumProperty);
                BindToTemplatedParent(MaximumProperty, RangeBase.MaximumProperty);
                BindToTemplatedParent(ValueProperty, RangeBase.ValueProperty);

                // Setup ScrollBar specific bindings
                ScrollBar scrollBar = rangeBase as ScrollBar;

                if (scrollBar != null)
                {
                    BindToTemplatedParent(ViewportSizeProperty, ScrollBar.ViewportSizeProperty);
                    BindToTemplatedParent(OrientationProperty, ScrollBar.OrientationProperty);
                }
                else
                {
                    // Setup Slider specific bindings
                    Slider slider = rangeBase as Slider;

                    if (slider != null)
                    {
                        BindToTemplatedParent(OrientationProperty, Slider.OrientationProperty);
                        BindToTemplatedParent(IsDirectionReversedProperty, Slider.IsDirectionReversedProperty);

                        BindChildToTemplatedParent(DecreaseRepeatButton, RepeatButton.DelayProperty, Slider.DelayProperty);
                        BindChildToTemplatedParent(DecreaseRepeatButton, RepeatButton.IntervalProperty, Slider.IntervalProperty);
                        BindChildToTemplatedParent(IncreaseRepeatButton, RepeatButton.DelayProperty, Slider.DelayProperty);
                        BindChildToTemplatedParent(IncreaseRepeatButton, RepeatButton.IntervalProperty, Slider.IntervalProperty);
                    }
                }
            }
        }
コード例 #13
0
ファイル: RangeProps.g.cs プロジェクト: binki/Alba.Framework
 public static void SetMaxInt (RangeBase d, int value)
 {
     d.SetValue(MaxIntProperty, value);
 }
コード例 #14
0
ファイル: RangeProps.g.cs プロジェクト: binki/Alba.Framework
 public static int GetMaxInt (RangeBase d)
 {
     return (int)d.GetValue(MaxIntProperty);
 }
コード例 #15
0
ファイル: DoubleSlider.cs プロジェクト: Titaye/SLExtensions
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.Slider2 = GetTemplateChild(ElementSlider2) as RangeBase;
            this.Slider1 = GetTemplateChild(ElementSlider1) as RangeBase;

            if (this.Slider2 != null)
            {
                this.Slider2.ValueChanged += Slider_ValueChanged;
                this.Slider2.Value = MaxValue;
            }

            if (this.Slider1 != null)
            {
                this.Slider1.ValueChanged += Slider_ValueChanged;
                this.Slider1.Value = MinValue;
            }

            RangeLength = MaxValue - MinValue;
        }
コード例 #16
0
        // Token: 0x06005F4D RID: 24397 RVA: 0x001AB8BC File Offset: 0x001A9ABC
        private static bool IsValidChange(object value)
        {
            double num = (double)value;

            return(RangeBase.IsValidDoubleValue(value) && num >= 0.0);
        }
コード例 #17
0
ファイル: RangeProps.cs プロジェクト: binki/Alba.Framework
 private static void MinInt_Changed (RangeBase slider, DpChangedEventArgs<int> args)
 {
     slider.SetCurrentValue(RangeBase.MinimumProperty, (double)args.NewValue);
 }
コード例 #18
0
 ///
 public RangeBaseAutomationPeer(RangeBase owner): base(owner)
 {
 }