当前位置: 首页>>代码示例>>C#>>正文


C# UITouch.PreviousLocationInView方法代码示例

本文整理汇总了C#中UITouch.PreviousLocationInView方法的典型用法代码示例。如果您正苦于以下问题:C# UITouch.PreviousLocationInView方法的具体用法?C# UITouch.PreviousLocationInView怎么用?C# UITouch.PreviousLocationInView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UITouch的用法示例。


在下文中一共展示了UITouch.PreviousLocationInView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContinueTracking

        public override bool ContinueTracking(UITouch uitouch, UIEvent uievent)
        {

//            PointF previousLocation = uitouch.PreviousLocationInView(this);
//            PointF currentLocation = uitouch.LocationInView(this);
//            float trackingOffset = currentLocation.X - previousLocation.X;
//
//            // Find the scrubbing speed that corresponds to the touch's vertical offset
//            float verticalOffset = Math.Abs(currentLocation.Y - beganTrackingLocation.Y);
//            int scrubbingSpeedChangePosIndex = IndexOfLowerScrubbingSpeed(_scrubbingSpeedChangePositions, verticalOffset);
//            if(scrubbingSpeedChangePosIndex == -1)
//                scrubbingSpeedChangePosIndex = _scrubbingSpeeds.Count;
//            this.scrubbingSpeed = _scrubbingSpeeds[scrubbingSpeedChangePosIndex - 1];
//
//            RectangleF trackRect = TrackRectForBounds(Bounds);
//            this.realPositionValue = this.realPositionValue * (MaxValue - MinValue) * (trackingOffset / trackRect.Size.Width);
//
//            float valueAdjustment = this.scrubbingSpeed * (MaxValue - MinValue) * (trackingOffset / trackRect.Size.Width);
//            float thumbAdjustment = 0;
//            if(((this.beganTrackingLocation.Y < currentLocation.Y) && (currentLocation.Y < previousLocation.Y)) ||
//               ((this.beganTrackingLocation.Y > currentLocation.Y) && (currentLocation.Y > previousLocation.Y)))
//            {
//                thumbAdjustment = (this.realPositionValue - Value) / (1 + Math.Abs(currentLocation.Y - this.beganTrackingLocation.Y));
//            }
//            Value += valueAdjustment + thumbAdjustment;
//
//            if(Continuous)
//                SendActionForControlEvents(UIControlEvent.ValueChanged);
//
//            OnContinueTrackingEvent(new EventArgs());
//            return Tracking;


            PointF ptPrev = uitouch.PreviousLocationInView(this);
            PointF pt = uitouch.LocationInView(this);

            //float relativeX = pt.X - Frame.X;
            //float ratioX = relativeX / Frame.Width;
            float widthWithFinger = Frame.Width + 44;
            float normalizedX = (pt.X < 0) ? 0 : pt.X;
            normalizedX = (pt.X > widthWithFinger) ? widthWithFinger : normalizedX;
            float ratioX = normalizedX / widthWithFinger;

            // Determine type of scrubbing
            var scrubbingType = SliderScrubbingType.HighSpeed;
            if(pt.Y - Frame.Y + Frame.Height > 300)
            {
                scrubbingType = SliderScrubbingType.Fine;
            }
            else if(pt.Y - Frame.Y + Frame.Height > 200)
            {
                scrubbingType = SliderScrubbingType.QuarterSpeed;
            }
            else if(pt.Y - Frame.Y + Frame.Height > 100)
            {
                scrubbingType = SliderScrubbingType.HalfSpeed;
            }
            
            // Check if event needs to be raised
            if(scrubbingType != ScrubbingType)
            {
                //Console.WriteLine("Slider - Changed scrubbing type to " + scrubbingType.ToString());
                ScrubbingType = scrubbingType;
                OnScrubbingTypeChanged(new EventArgs());
            }

            // Calculate new value
            float newValueDelta = (ratioX * 10000) - Value;
            switch(scrubbingType)
            {
                case SliderScrubbingType.HalfSpeed:
                    newValueDelta = newValueDelta * 0.5f;
                    break;
                case SliderScrubbingType.QuarterSpeed:
                    newValueDelta = newValueDelta * 0.25f;
                    break;
                case SliderScrubbingType.Fine:
                    newValueDelta = newValueDelta * 0.1f;
                    break;
            }
//            float newValue = Value + newValueDelta;
//            if(newValue < MinValue)
//                newValue = MinValue;
//            if(newValue > MaxValue)
//                newValue = MaxValue;
//
//            Value = newValue;
//
//            //SetValue(newValue, true);
//            Console.WriteLine("Slider - ContinueTracking - newValue: " + newValue.ToString() + " newValueDelta: " + newValueDelta.ToString() + " (" + ptPrev.X.ToString() + ", " + ptPrev.Y.ToString() + ") (" + pt.X.ToString() + ", " + pt.Y.ToString() + ") normalizedX: " + normalizedX.ToString() + " ratioX: " + ratioX.ToString());
//            
//
//
//            if(Continuous)
//                SendActionForControlEvents(UIControlEvent.ValueChanged);
//
//            return true;

            return base.ContinueTracking(uitouch, uievent);
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:100,代码来源:MPfmSlider.cs

示例2: UpdateReticleView

		void UpdateReticleView (UITouch touch, bool predicated = false)
		{
			if (touch == null || touch.Type != UITouchType.Stylus)
				return;

			ReticleView.PredictedDotLayer.Hidden = !predicated;
			ReticleView.PredictedLineLayer.Hidden = !predicated;

			var azimuthAngle = touch.GetAzimuthAngle (View);
			var azimuthUnitVector = touch.GetAzimuthUnitVector (View);
			var altitudeAngle = touch.AltitudeAngle;

			if (predicated) {
				ReticleView.PredictedAzimuthAngle = azimuthAngle;
				ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector;
				ReticleView.PredictedAltitudeAngle = altitudeAngle;
			} else {
				var location = touch.PreviousLocationInView (View);
				ReticleView.Center = location;
				ReticleView.ActualAzimuthAngle = azimuthAngle;
				ReticleView.ActualAzimuthUnitVector = azimuthUnitVector;
				ReticleView.ActualAltitudeAngle = altitudeAngle;
			}
		}
开发者ID:93asad,项目名称:monotouch-samples,代码行数:24,代码来源:MainViewController.cs

示例3: UpdateWithTouch

		public bool UpdateWithTouch (UITouch touch)
		{
			if (!touch.EstimationUpdateIndex.IsEqualTo(EstimationUpdateIndex))
				return false;

			// An array of the touch properties that may be of interest.
			UITouchProperties[] touchProperties = {
				UITouchProperties.Location,
				UITouchProperties.Force,
				UITouchProperties.Altitude,
				UITouchProperties.Azimuth
			};

			// Iterate through possible properties.
			foreach (var expectedProperty in touchProperties) {
				// If an update to this property is not expected, continue to the next property.
				if (EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty))
					continue;

				switch (expectedProperty) {
				case UITouchProperties.Force:
					Force = touch.Force;
					break;
				case UITouchProperties.Azimuth:
					AzimuthAngle = touch.GetAzimuthAngle (touch.View);
					break;
				case UITouchProperties.Altitude:
					AltitudeAngle = touch.AltitudeAngle;
					break;
				case UITouchProperties.Location:
					Location = touch.LocationInView (touch.View);
					PreciseLocation = touch.PreviousLocationInView (touch.View);
					break;
				}

				// Flag that this point now has a 'final' value for this property.
				if (!touch.EstimatedProperties.HasFlag (expectedProperty))
					EstimatedProperties &= ~expectedProperty;

				// Flag that this point is no longer expecting updates for this property.
				if (!touch.EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty)) {
					EstimatedPropertiesExpectingUpdates &= ~expectedProperty;

					if (EstimatedPropertiesExpectingUpdates == 0) {
						PointType &= ~PointType.NeedsUpdate;
						PointType |= PointType.Updated;
					}
				}
			}

			return true;
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:52,代码来源:LinePoint.cs


注:本文中的UITouch.PreviousLocationInView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。