Inheritance: Control, IThumb
Esempio n. 1
0
        protected override void OnApplyTemplate()
        {
            _rootGrid = GetTemplateChild(PART_ROOT_NAME) as Grid;
            _grabberGrid = GetTemplateChild(PART_GRABBER_NAME) as Grid;
            _contentPresenter = GetTemplateChild(PART_CONTENT_NAME) as ContentControl;
            _thumb = GetTemplateChild(PART_THUMB_NAME) as Thumb;

            InitEvents();
        }
Esempio n. 2
0
 /// <summary>${controls_SliderElement_method_onApplyTemplate_D}</summary>
 protected override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.trackPanel = base.GetTemplateChild("TrackPanel") as Panel;
     this.thumb = base.GetTemplateChild("ThumbElement") as Thumb;
     if (this.thumb != null)
     {
         this.thumb.DragStarted += new DragStartedEventHandler(this.OnThumbDragStarted);
         this.thumb.DragDelta += new DragDeltaEventHandler(this.OnThumbDragDelta);
         this.thumb.DragCompleted += new DragCompletedEventHandler(this.OnThumbDragCompleted);
     }
     this.bufferElement = base.GetTemplateChild("Buffer") as Rectangle;
     this.UpdateTrackMarks();
 }
Esempio n. 3
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _leftThumb = (Thumb) GetTemplateChild(LeftThumbName);
            _leftThumb.DragDelta += LeftThumbDragDelta;
            _leftThumb.DragCompleted += ThumbDragCompleted;
            _leftThumb.Loaded += LeftThumbLoaded;

            _rightThumb = (Thumb) GetTemplateChild(RightThumbName);
            _rightThumb.DragDelta += RightThumbDragDelta;
            _rightThumb.DragCompleted += ThumbDragCompleted;
            _rightThumb.Loaded += RightThumbLoaded;

            _trackGeometry = (RectangleGeometry) GetTemplateChild("TrackRectangle");
            _trackRect = (Rectangle) GetTemplateChild(TrackRectName);
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Loaded += Clr_Pckr_Loaded;

            clrViewbox = GetTemplateChild("clrViewbox") as Viewbox;
            pointer = GetTemplateChild("pointer") as Grid;
            reference = GetTemplateChild("reference") as Border;
            rtrnsfrm = GetTemplateChild("rtrnsfrm") as CompositeTransform;
            innerCanvas = GetTemplateChild("innerCanvas") as Canvas;
            innerEll = GetTemplateChild("innerEll") as Grid;
            ColorImg = GetTemplateChild("ColorImg") as Image;
           
            thumbInnerEll = GetTemplateChild("thumbInnerEll") as Thumb;
            rectColor = GetTemplateChild("rectColor") as Rectangle;
            gdStop = GetTemplateChild("gdStop") as GradientStop;
            FinalColor = GetTemplateChild("FinalColor") as Ellipse;
            testblock = GetTemplateChild("test") as TextBlock;


            ColorImg.Tapped += ColorImg_Tapped_1;
          
            rectColor.PointerPressed += Rectangle_PointerPressed_1;
            thumbInnerEll.DragDelta += Thumb_DragDelta_1;

            ColorImg.PointerReleased += ColorImg_PointerReleased_1;
            ColorImg.PointerPressed += ColorImg_PointerPressed_1;
            ColorImg.PointerMoved += ColorImg_PointerMoved_1;

            gdStop.Color = SelectedColor;
            FinalColor.Fill = new SolidColorBrush(SelectedColor);



            GeneralTransform gt = pointer.TransformToVisual(reference);

            Point p = new Point();

            p = gt.TransformPoint(p);
            px = p.X;
            py = p.Y;
            loadnew();
        }
Esempio n. 5
0
        /// <summary>
        /// Update the visual state of the control when its template is changed.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            // need to make sure the values can be set in XAML and don't overwrite eachother
            VerifyValues();
            _valuesAssigned = true;

            OutOfRangeContentContainer = GetTemplateChild("OutOfRangeContentContainer") as Border;
            ActiveRectangle = GetTemplateChild("ActiveRectangle") as Rectangle;
            MinThumb = GetTemplateChild("MinThumb") as Thumb;
            MaxThumb = GetTemplateChild("MaxThumb") as Thumb;
            ContainerCanvas = GetTemplateChild("ContainerCanvas") as Canvas;

            OutOfRangeContentContainer.PointerPressed += OutOfRangeContentContainer_PointerPressed;
            OutOfRangeContentContainer.PointerMoved += OutOfRangeContentContainer_PointerMoved;
            OutOfRangeContentContainer.PointerReleased += OutOfRangeContentContainer_PointerReleased;
            OutOfRangeContentContainer.PointerExited += OutOfRangeContentContainer_PointerExited;

            MinThumb.DragCompleted += Thumb_DragCompleted;
            MinThumb.DragDelta += MinThumb_DragDelta;
            MinThumb.DragStarted += MinThumb_DragStarted;

            MaxThumb.DragCompleted += Thumb_DragCompleted;
            MaxThumb.DragDelta += MaxThumb_DragDelta;
            MaxThumb.DragStarted += MaxThumb_DragStarted;

            ContainerCanvas.SizeChanged += ContainerCanvas_SizeChanged;

            if (IsEnabled)
            {
                VisualStateManager.GoToState(this, "Normal", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "Disabled", true);
            }

            IsEnabledChanged += RangeSelector_IsEnabledChanged;


            base.OnApplyTemplate();
        }
        void InitRangeSlider()
        {
            try
            {
                (this.GetTemplateChild(HoriontalTemplate) as Grid).Visibility = this.Orientation == Orientation.Vertical ? Visibility.Collapsed : Visibility.Visible;
                (this.GetTemplateChild(VerticalTemplate) as Grid).Visibility = this.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Collapsed;
                thumbFrom = this.Orientation == Orientation.Vertical ? this.GetTemplateChild(thumbVerticalFrom) as Thumb : this.GetTemplateChild(thumbHoriontalFrom) as Thumb;
                thumbTo = this.Orientation == Orientation.Vertical ? this.GetTemplateChild(thumbVerticalTo) as Thumb : this.GetTemplateChild(thumbHoriontalTo) as Thumb;
                fromLength = this.Orientation == Orientation.Vertical ? this.thumbFrom.Height : this.thumbFrom.Width;
                toLength = this.Orientation == Orientation.Vertical ? this.thumbTo.Height : this.thumbTo.Width;
                totalLength = this.Orientation == Orientation.Vertical ? this.Height : this.Width;
            }
            catch { }
            totalValue = FromThumbVisbilty == Visibility.Visible ? totalLength - fromLength - toLength - toLength / 2 : totalLength - toLength;

            if ((this.Maximum - this.Minimum) >= 0)
            {
                perValue = totalValue / (this.Maximum - this.Minimum);
                if (FromThumbVisbilty == Visibility.Collapsed)
                {
                    RangeFrom = 0;
                    RangeTo = perValue * (this.Maximum - this.Value) + toLength;
                }
                else
                {
                    RangeFrom = perValue * (FromValue - this.Minimum) + fromLength;
                    RangeTo = perValue * (this.Maximum - Value) + toLength;

                }

            }

            MinValue = FromValue.ToString();
            MaxValue = Value.ToString();
            if (thumbFrom != null)
            {
                thumbFrom.ManipulationStarted += fromThumb_ManipulationStarted;
                thumbFrom.ManipulationDelta += fromThumb_ManipulationDelta;
                thumbFrom.PointerEntered += thumbFrom_PointerEntered;
                thumbFrom.ManipulationCompleted += thumbFrom_ManipulationCompleted;
                thumbFrom.LostFocus += thumbTo_LostFocus;
                thumbFrom.PointerExited += thumbTo_PointerExited;
            }
            if (thumbTo != null)
            {
                thumbTo.ManipulationStarted += thumbTo_ManipulationStarted;
                thumbTo.ManipulationDelta += thumbTo_ManipulationDelta;
                thumbTo.PointerEntered += thumbTo_PointerEntered;
                thumbTo.ManipulationCompleted += thumbFrom_ManipulationCompleted;
                thumbTo.LostFocus += thumbTo_LostFocus;
                thumbTo.PointerExited += thumbTo_PointerExited;
            }

            try
            {
                Grid rectLeftHoriontal = this.GetTemplateChild(gridLeftHoriontal) as Grid;
                Rectangle MiddleHoriontal = this.GetTemplateChild(rectMiddleHoriontal) as Rectangle;
                Grid rectRightHoriontal = this.GetTemplateChild(gridRightHoriontal) as Grid;
                Grid rectLeftVertical = this.GetTemplateChild(gridLeftVertical) as Grid;
                Rectangle MiddleVertical = this.GetTemplateChild(rectMiddleVertical) as Rectangle;
                Grid rectRightVertical = this.GetTemplateChild(gridRightVertical) as Grid;

                rectLeftHoriontal.Tapped += rect_Tapped;
                MiddleHoriontal.Tapped += rect_Tapped;
                rectRightHoriontal.Tapped += rect_Tapped;
                rectLeftVertical.Tapped += rect_Tapped;
                MiddleVertical.Tapped += rect_Tapped;
                rectRightVertical.Tapped += rect_Tapped;
            }
            catch { }
        }
Esempio n. 7
0
        public bool IsSupportTouchMode { get; set; } = true; // 是否支持触摸模式
        #endregion

        #region Loaded
        /// <summary>
        ///  垂直滚动条加载完成
        /// </summary>
        private void VerticalThumb_OnLoaded(object sender, RoutedEventArgs e)
        {
            _verticalThumb = sender as Thumb;
            if (_indicatorMode == ScrollingIndicatorMode.TouchIndicator)
            {
                CheckUserInteractionMode();
            }

            ReCalThumbSize();
        }
Esempio n. 8
0
        private double DragThumb(Thumb thumb, double min, double max, double nextPos)
        {
            nextPos = Math.Max(min, nextPos);
            nextPos = Math.Min(max, nextPos);

            Canvas.SetLeft(thumb, nextPos);

            return (Minimum + (nextPos / ContainerCanvas.ActualWidth) * (Maximum - Minimum)); ;
        }
Esempio n. 9
0
 public ThumbGestureRecognizer(Thumb thumb)
 {
     this._thumb = thumb;
 }
Esempio n. 10
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _ring1 = GetTemplateChild("PART_Ring1") as RingPart;
            _ring2 = GetTemplateChild("PART_Ring2") as RingPart;
            _thumb = GetTemplateChild("PART_Thumb") as Thumb;

            if (_thumb != null)
            {
                _thumb.DragStarted += OnDragStarted;
                _thumb.DragDelta += OnDragDelta;
                _thumb.DragCompleted += OnDragCompleted;
            }
        }
		protected override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			_verticalThumb = GetTemplateChild(VerticalThumbName) as Thumb;
			_verticalDecreaseRect = GetTemplateChild(VerticalDecreaseRectName) as Shape;

			_horizontalThumb = GetTemplateChild(HorizontalThumbName) as Thumb;
			_horizontalDecreaseRect = GetTemplateChild(HorizontalDecreaseRectName) as Shape;
		}
Esempio n. 12
0
 private void VerticalThumb_OnLoaded(object sender, RoutedEventArgs e)
 {
     _thumb = sender as Thumb;
 }
Esempio n. 13
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _upperThumb = (Thumb)GetTemplateChild(ThumbPartNameUpper);
            _upperThumb.DragDelta += UpperThumb_DragDelta;

            _lowerThumb = (Thumb)GetTemplateChild(ThumbPartNameLower);
            _lowerThumb.DragDelta += LowerThumb_DragDelta;

            _middleThumb = (Thumb)GetTemplateChild(MiddleThumbPartName);
            _middleThumb.DragDelta += MiddleThumbDrageDelta;

            _rightRect = (Rectangle)GetTemplateChild(RightRectPartName);
            _rightRect.Tapped += RightRectTapped;

            _leftRect = (Rectangle)GetTemplateChild(LeftRectPartName);
            _leftRect.Tapped += LeftRectTapped;
        }
 public ThumbEvents(Thumb This)
     : base(This)
 {
     this.This = This;
 }