Inheritance: ButtonBase, IRepeatButton
Exemplo n.º 1
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += OnGotFocus;
            this.LostFocus += OnLostFocus;
            this.PointerWheelChanged += OnPointerWheelChanged;
            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBlock;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;

            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.KeyDown += OnValueTextBoxKeyDown;
                _valueTextBox.PointerExited += OnValueTextBoxPointerExited;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }
Exemplo n.º 2
0
        /// <summary>${controls_ZoomSlider_method_onApplyTemplate_D}</summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.sliderElement = base.GetTemplateChild("SliderElement") as SliderElement;
            this.zoomInElement = base.GetTemplateChild("ZoomInElement") as RepeatButton;
            this.zoomOutElement = base.GetTemplateChild("ZoomOutElement") as RepeatButton;

            if (this.sliderElement != null)
            {
                if (this.Map != null)
                {
                    this.SetupZoom();
                }
                this.sliderElement.ValueChanged += this.ZoomSlider_ValueChanged;
            }
            if (this.zoomInElement != null)
            {
                this.zoomInElement.Click += new RoutedEventHandler(this.ZoomInButton_Click);
                this.zoomInElement.PointerExited += zoomInElement_PointerExited;
            }
            if (this.zoomOutElement != null)
            {
                this.zoomOutElement.Click += new RoutedEventHandler(this.ZoomOutButton_Click);
                this.zoomOutElement.PointerExited += zoomOutElement_PointerExited;
            }
        }
Exemplo n.º 3
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _incrementButton = GetTemplateChild("PART_IncrementButton") as RepeatButton;
            _decrementButton = GetTemplateChild("PART_DecrementButton") as RepeatButton;

            if (_incrementButton != null)
            {
                _incrementButton.SizeChanged += ResizePartButton;
                _incrementButton.Delay = _delay;
                _incrementButton.Interval = _interval;
                _incrementButton.Click += OnIncrementClicked;
            }
            if (_decrementButton != null)
            {
                _decrementButton.SizeChanged += ResizePartButton;
                _decrementButton.Delay = _delay;
                _decrementButton.Interval = _interval;
                _decrementButton.Click += OnDecrementClicked;
            }

            SetValidIncrementDirection();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += this.OnGotFocus;
            this.LostFocus += this.OnLostFocus;
            this.PointerWheelChanged += this.OnPointerWheelChanged;
            _valueTextBox = this.GetTemplateChild(ValueTextBoxName) as UpDownTextBox;
            _dragOverlay = this.GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = this.GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = this.GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = this.GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += this.OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += this.OnValueTextBoxGotFocus;
                _valueTextBox.Text = this.Value.ToString(CultureInfo.CurrentCulture);
                _valueTextBox.TextChanged += this.OnValueTextBoxTextChanged;
                _valueTextBox.KeyDown += this.OnValueTextBoxKeyDown;
                _valueTextBox.UpPressed += (s, e) => this.Increment();
                _valueTextBox.DownPressed += (s, e) => this.Decrement();
                _valueTextBox.PointerExited += this.OnValueTextBoxPointerExited;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += this.OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += this.OnDragOverlayPointerPressed;
                _dragOverlay.PointerReleased += this.OnDragOverlayPointerReleased;
                _dragOverlay.PointerCaptureLost += this.OnDragOverlayPointerCaptureLost;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += this.OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += this.OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += this.OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += this.OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += this.OnValueBarSizeChanged;

                this.UpdateValueBar();
            }

            this.UpdateIsReadOnlyDependants();
            this.SetValidIncrementDirection();
        }
Exemplo n.º 5
0
        /// <summary>${controls_NavControl_method_onApplyTemplate_D}</summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            rotateRingElement = GetTemplateChild("RotateRingElement") as FrameworkElement;
            transformRotateElement = GetTemplateChild("TransformRotateElement") as RotateTransform;

            panLeftElement = GetTemplateChild("PanLeftElement") as RepeatButton;
            panRightElement = GetTemplateChild("PanRightElement") as RepeatButton;
            panUpElement = GetTemplateChild("PanUpElement") as RepeatButton;
            panDownElement = GetTemplateChild("PanDownElement") as RepeatButton;
            viewEntireElement = GetTemplateChild("ViewEntireElement") as Button;


            zoomSliderElement = GetTemplateChild("ZoomSlider") as Slider;
            zoomInElement = GetTemplateChild("ZoomInElement") as RepeatButton;
            zoomOutElement = GetTemplateChild("ZoomOutElement") as RepeatButton;

            #region 上下左右
            if (this.panLeftElement != null)
            {
                this.panLeftElement.Click += (sender , args) =>
                           {
                               if (( this.Map != null ) && ( sender != null ))
                               {
                                   this.Map.Pan(-this.Map.ViewBounds.Width * Map.PanFactor , 0);
                               }
                           };
            }

            if (this.panRightElement != null)
            {
                this.panRightElement.Click += (sender , args) =>
                {
                    if (( this.Map != null ) && ( sender != null ))
                    {
                        this.Map.Pan(this.Map.ViewBounds.Width * this.Map.PanFactor , 0);
                    }
                };
            }
            if (this.panDownElement != null)
            {
                this.panDownElement.Click += (sender , args) =>
                {
                    if (( this.Map != null ) && ( sender != null ))
                    {
                        this.Map.Pan(0 , -this.Map.ViewBounds.Height * this.Map.PanFactor);
                    }
                };
            }

            if (this.panUpElement != null)
            {
                this.panUpElement.Click += (sender , args) =>
                {
                    if (( this.Map != null ) && ( sender != null ))
                    {
                        this.Map.Pan(0 , this.Map.ViewBounds.Height * this.Map.PanFactor);
                    }
                };
            }
            #endregion

            SetupZoom();

            if (zoomSliderElement != null)
            {
                zoomSliderElement.PointerEntered += zoomSliderElement_PointerEntered;
                zoomSliderElement.PointerExited += zoomSliderElement_PointerExited;
                zoomSliderElement.ValueChanged += ZoomSlider_ValueChanged;
            }
            if (zoomInElement != null)
            {
                zoomInElement.Click += new RoutedEventHandler(this.ZoomInButton_Click);
            }
            if (zoomOutElement != null)
            {
                zoomOutElement.Click += new RoutedEventHandler(this.ZoomOutButton_Click);
            }

            if (rotateRingElement != null && this.transformRotateElement != null)
            {
                rotateRingElement.PointerPressed += _rotateRingPointerPressed;
                rotateRingElement.PointerMoved += _rotateRingPointerMoved;
                rotateRingElement.PointerReleased += _rotateRingPointerReleased;
            }
            if (viewEntireElement != null)
            {
                viewEntireElement.Click += new RoutedEventHandler(this.ZoomViewEntire_Click);
            }

        }
Exemplo n.º 6
0
        /// <summary>${controls_Compass_method_onApplyTemplate_D}</summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.panLeftElement = base.GetTemplateChild("PanLeftElement") as RepeatButton;
            this.panRightElement = base.GetTemplateChild("PanRightElement") as RepeatButton;
            this.panUpElement = base.GetTemplateChild("PanUpElement") as RepeatButton;
            this.panDownElement = base.GetTemplateChild("PanDownElement") as RepeatButton;
            this.viewEntireElement = base.GetTemplateChild("ViewEntireElement") as Button;

            #region 上下左右
            if (this.panLeftElement != null)
            {
                this.panLeftElement.ClickMode = ClickMode.Press;
                this.panLeftElement.Click += (sender, args) =>
                           {
                               if ((this.Map != null) && (sender != null))
                               {
                                   this.Map.Pan(-this.Map.ViewBounds.Width * this.Map.PanFactor, 0);
                               }
                           };
                this.panLeftElement.PointerExited += (sender, args) =>
                {
                    this.panLeftElement.ReleasePointerCaptures();
                };
            }

            if (this.panRightElement != null)
            {
                this.panRightElement.ClickMode = ClickMode.Press;
                this.panRightElement.Click += (sender, args) =>
                {
                    if ((this.Map != null) && (sender != null))
                    {
                        this.Map.Pan(this.Map.ViewBounds.Width * this.Map.PanFactor, 0);
                    }
                };
                this.panRightElement.PointerExited += (sender, args) =>
                    {
                        this.panRightElement.ReleasePointerCaptures();
                    };
            }
            if (this.panDownElement != null)
            {
                this.panDownElement.ClickMode = ClickMode.Press;
                this.panDownElement.Click += (sender, args) =>
                {
                    if ((this.Map != null) && (sender != null))
                    {
                        this.Map.Pan(0, -this.Map.ViewBounds.Height * this.Map.PanFactor);
                    }
                };
                this.panDownElement.PointerExited += (sender, args) =>
                {
                    this.panDownElement.ReleasePointerCaptures();
                };
            }

            if (this.panUpElement != null)
            {
                this.panUpElement.ClickMode = ClickMode.Press;
                this.panUpElement.Click += (sender, args) =>
                {
                    if ((this.Map != null) && (sender != null))
                    {
                        this.Map.Pan(0, this.Map.ViewBounds.Height * this.Map.PanFactor);
                    }
                };
                this.panUpElement.PointerExited += (sender, args) =>
                {
                    this.panUpElement.ReleasePointerCaptures();
                };
            }
            #endregion

            if (this.viewEntireElement != null)
            {
                this.viewEntireElement.Click += viewEntireElement_Click;
            }
        }
Exemplo n.º 7
0
 protected override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _isInitializing = true;
     _minusPad = this.GetTemplateChild("PART_MinusPad") as RepeatButton;
     _plusPad = this.GetTemplateChild("PART_PlusPad") as RepeatButton;
     if (_minusPad != null && _plusPad != null)
     {
         _minusPad.Click += this.OnPadClick;
         _plusPad.Click += this.OnPadClick;
         _minusPad.PointerEntered += this.OnPadPointerEntered;
         _plusPad.PointerEntered += this.OnPadPointerEntered;
         _minusPad.PointerExited += this.OnPadPointerExited;
         _plusPad.PointerExited += this.OnPadPointerExited;
         _minusPad.PointerReleased += this.OnPadPointerReleased;
         _plusPad.PointerReleased += this.OnPadPointerReleased;
     }
     this.CheckRange();
 }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBox;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.TextChanged += OnValueTextBoxTextChanged;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += OnDragOverlayPointerPressed;
                _dragOverlay.ManipulationDelta += OnDragOverlayManipulationDelta;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (DesignMode.DesignModeEnabled)
            {
                return;
            }

            this.GotFocus += OnGotFocus;
            this.LostFocus += OnLostFocus;
            this.PointerWheelChanged += OnPointerWheelChanged;
            _valueTextBox = GetTemplateChild(ValueTextBoxName) as TextBox;
            _dragOverlay = GetTemplateChild(DragOverlayName) as UIElement;
            _decrementButton = GetTemplateChild(DecrementButtonName) as RepeatButton;
            _incrementButton = GetTemplateChild(IncrementButtonName) as RepeatButton;
            _valueBar = GetTemplateChild(ValueBarName) as FrameworkElement;
            
            if (_valueTextBox != null)
            {
                _valueTextBox.LostFocus += OnValueTextBoxLostFocus;
                _valueTextBox.GotFocus += OnValueTextBoxGotFocus;
                _valueTextBox.Text = Value.ToString();
                _valueTextBox.TextChanged += OnValueTextBoxTextChanged;
            }

            if (_dragOverlay != null)
            {
                _dragOverlay.Tapped += OnDragOverlayTapped;
                _dragOverlay.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
                _dragOverlay.PointerPressed += OnDragOverlayPointerPressed;
                Window.Current.CoreWindow.PointerReleased += CoreWindowOnPointerReleased;
                Window.Current.CoreWindow.VisibilityChanged += OnCoreWindowVisibilityChanged;
                _dragOverlay.PointerReleased += OnDragOverlayPointerReleased;
                _dragOverlay.PointerCaptureLost += OnDragOverlayPointerCaptureLost;
            }

            if (_decrementButton != null)
            {
                _decrementButton.Click += OnDecrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_decrementButton, "IsPressed");
                pcc.ValueChanged += OnDecrementButtonIsPressedChanged;
            }

            if (_incrementButton != null)
            {
                _incrementButton.Click += OnIncrementButtonClick;
                var pcc =
                    new PropertyChangeEventSource<bool>
                        (_incrementButton, "IsPressed");
                pcc.ValueChanged += OnIncrementButtonIsPressedChanged;
            }

            if (_valueBar != null)
            {
                _valueBar.SizeChanged += OnValueBarSizeChanged;

                UpdateValueBar();
            }

            UpdateIsReadOnlyDependants();
            SetValidIncrementDirection();
        }