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


C# Vector2.Saturate方法代码示例

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


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

示例1: GetLocationInternal

        /// <summary>
        /// Returns the mouse cursor position from cached values
        /// </summary>
        protected override Vector2 GetLocationInternal()
        {
            var p = control.PointToClient(Cursor.Position);

            var clientSize = control.ClientSize;
            var position = new Vector2((float)p.X / clientSize.Width, (float)p.Y / clientSize.Height);
            position.Saturate();
            return position;
        }
开发者ID:Ziriax,项目名称:SharpDX,代码行数:12,代码来源:MousePlatformDesktop.cs

示例2: GetLocationInternal

        protected override Vector2 GetLocationInternal()
        {
            System.Drawing.Point p = System.Drawing.Point.Empty;
            if (control.InvokeRequired)
            {
                control.Invoke(new Action(delegate { p = control.PointToClient(Cursor.Position); }));
            }
            else
            {
                p = control.PointToClient(Cursor.Position);
            }

            var clientSize = control.ClientSize;
            var position = new Vector2((float)p.X / clientSize.Width, (float)p.Y / clientSize.Height);
            position.Saturate();
            return position;
        }
开发者ID:ukitake,项目名称:Stratum,代码行数:17,代码来源:StratumMousePlatformDesktop.cs

示例3: CreateAndAddPoint

        /// <summary>
        /// Creates a <see cref="PointerPoint"/> instance from current mouse state.
        /// </summary>
        /// <param name="eventType">The type of pointer event.</param>
        /// <param name="pointerUpdateKind">The kind of pointer event.</param>
        /// <param name="wheelDelta">The current mouse wheel delta.</param>
        private void CreateAndAddPoint(PointerEventType eventType, PointerUpdateKind pointerUpdateKind, int wheelDelta)
        {
            var p = control.PointToClient(Control.MousePosition);

            var mouseButtons = Control.MouseButtons;

            var clientSize = control.ClientSize;
            var position = new Vector2((float)p.X / clientSize.Width, (float)p.Y / clientSize.Height);
            position.Saturate();

            var point = new PointerPoint
                   {
                       EventType = eventType,
                       DeviceType = PointerDeviceType.Mouse,
                       KeyModifiers = GetCurrentKeyModifiers(),
                       PointerId = 0,
                       Position = position,
                       Timestamp = (ulong)DateTime.Now.Ticks,
                       ContactRect = new RectangleF(position.X, position.Y, 0f, 0f),
                       IsBarrelButtonPressed = false,
                       IsCanceled = false,
                       IsEraser = false,
                       IsHorizontalMouseWheel = false,
                       IsInRange = false,
                       IsInverted = false,
                       IsLeftButtonPressed = (mouseButtons & MouseButtons.Left) != 0,
                       IsMiddleButtonPressed = (mouseButtons & MouseButtons.Middle) != 0,
                       IsPrimary = true,
                       IsRightButtonPressed = (mouseButtons & MouseButtons.Right) != 0,
                       IsXButton1Pressed = (mouseButtons & MouseButtons.XButton1) != 0,
                       IsXButton2Pressed = (mouseButtons & MouseButtons.XButton2) != 0,
                       MouseWheelDelta = wheelDelta,
                       Orientation = 0f,
                       TouchConfidence = false, // ?
                       Twist = 0f,
                       XTilt = 0f,
                       YTilt = 0f,
                       PointerUpdateKind = pointerUpdateKind
                   };

            manager.AddPointerEvent(ref point);
        }
开发者ID:onefiftyone,项目名称:Toolkit,代码行数:48,代码来源:PointerPlatformDesktop.cs

示例4: SetLocation

 /// <inheritdoc />
 internal override void SetLocation(Vector2 point)
 {
     point.Saturate();
     var clientSize = control.ClientSize;
     Cursor.Position = control.PointToScreen(new System.Drawing.Point((int)(point.X * clientSize.Width), (int)(point.Y * clientSize.Height)));
 }
开发者ID:Ziriax,项目名称:SharpDX,代码行数:7,代码来源:MousePlatformDesktop.cs

示例5: CreateAndAddPoint

        /// <summary>
        /// Creates a platform-independent instance of <see cref="PointerPoint"/> class from WP8-specific objects.
        /// </summary>
        /// <param name="type">The pointer event type.</param>
        /// <param name="point">The WP8-specific instance of pointer point.</param>
        /// <returns>An instance of <see cref="PointerPoint"/> class.</returns>
        private void CreateAndAddPoint(PointerEventType type, global::Windows.UI.Input.PointerPoint point)
        {
            if (point == null) throw new ArgumentNullException("point");

            // If we can't access the uiElement (this can happen here), then run this code on the UI thread
            if (!uiElement.Dispatcher.CheckAccess())
            {
                uiElement.Dispatcher.BeginInvoke(() => CreateAndAddPoint(type, point));
                return;
            }

            var p = point.Position;
            var properties = point.Properties;
            var contactRect = properties.ContactRect;
            var width = (float)uiElement.ActualWidth;
            var height = (float)uiElement.ActualHeight;

            var position = new Vector2((float)p.X / width, (float)p.Y / height);
            position.Saturate();

            var result = new PointerPoint
                         {
                             EventType = type,
                             DeviceType = PointerDeviceType.Touch,
                             KeyModifiers = KeyModifiers.None,
                             PointerId = point.PointerId,
                             Position = position,
                             Timestamp = point.Timestamp,
                             ContactRect = new RectangleF((float)contactRect.X / width, (float)contactRect.Y / height, (float)contactRect.Width / width, (float)contactRect.Height / height),
                             IsBarrelButtonPressed = properties.IsBarrelButtonPressed,
                             IsCanceled = properties.IsCanceled,
                             IsEraser = properties.IsEraser,
                             IsHorizontalMouseWheel = properties.IsHorizontalMouseWheel,
                             IsInRange = properties.IsInRange,
                             IsInverted = properties.IsInverted,
                             IsLeftButtonPressed = properties.IsLeftButtonPressed,
                             IsMiddleButtonPressed = properties.IsMiddleButtonPressed,
                             IsPrimary = properties.IsPrimary,
                             IsRightButtonPressed = properties.IsRightButtonPressed,
                             IsXButton1Pressed = properties.IsXButton1Pressed,
                             IsXButton2Pressed = properties.IsXButton2Pressed,
                             MouseWheelDelta = properties.MouseWheelDelta,
                             Orientation = properties.Orientation,
                             TouchConfidence = properties.TouchConfidence,
                             Twist = properties.Twist,
                             XTilt = properties.XTilt,
                             YTilt = properties.YTilt,
                             PointerUpdateKind = PointerUpdateKind.Other
                         };

            manager.AddPointerEvent(ref result);
        }
开发者ID:numo16,项目名称:SharpDX,代码行数:58,代码来源:PointerPlatformWP8.cs

示例6: GetLocationInternal

        /// <summary>
        /// Returns the mouse cursor position from cached values
        /// </summary>
        protected override Vector2 GetLocationInternal()
        {
            Point p;
            GetCursorPos(out p);
            ScreenToClient(control.Handle, ref p);

            var clientSize = control.ClientSize;
            var position = new Vector2((float)p.X / clientSize.Width, (float)p.Y / clientSize.Height);
            position.Saturate();
            return position;
        }
开发者ID:SickheadGames,项目名称:SharpDX,代码行数:14,代码来源:MousePlatformDesktop.cs

示例7: FillPointInformation

        private void FillPointInformation(ref PointerPoint point,
                                          PointerEventType eventType,
                                          PointerDeviceType deviceType,
                                          PointerUpdateKind updateKind,
                                          System.Windows.Point positionPoint)
        {
            var position = new Vector2((float)(positionPoint.X / element.ActualWidth), (float)(positionPoint.Y / element.ActualHeight));
            position.Saturate();

            point.EventType = eventType;
            point.DeviceType = deviceType;
            point.KeyModifiers = GetPressedKeyModifiers();
            point.PointerId = 0;
            point.Position = position;
            point.Timestamp = (ulong)DateTime.Now.Ticks;
            point.ContactRect = new RectangleF(position.X, position.Y, 0f, 0f);
            point.IsBarrelButtonPressed = false;
            point.IsCanceled = false;
            point.IsEraser = false;
            point.IsHorizontalMouseWheel = false;
            point.IsInRange = false;
            point.IsInverted = false;
            point.IsPrimary = true;
            point.MouseWheelDelta = 0;
            point.Orientation = 0f;
            point.TouchConfidence = false;
            point.Twist = 0f;
            point.XTilt = 0f;
            point.YTilt = 0f;
            point.PointerUpdateKind = updateKind;
        }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:31,代码来源:PointerPlatformDesktopWpf.cs

示例8: DecodeAndDispatchTouchPoint

        /// <summary>
        /// Decodes a single touch point and creates from it the <see cref="PointerPoint"/> class.
        /// </summary>
        /// <param name="input">The touch point input structure.</param>
        private void DecodeAndDispatchTouchPoint(TOUCHINPUT input)
        {
            var p = control.PointToClient(new System.Drawing.Point(AdjustX(input.x), AdjustY(input.y)));

            var mask = input.dwMask;
            var flags = input.dwFlags;

            var isPrimary = (flags & User32.TOUCHEVENTF_PRIMARY) != 0;

            PointerUpdateKind pointerUpdateKind;
            PointerEventType eventType;
            if ((flags & User32.TOUCHEVENTF_DOWN) != 0)
            {
                pointerUpdateKind = PointerUpdateKind.LeftButtonPressed;
                eventType = PointerEventType.Pressed;
            }
            else if ((flags & User32.TOUCHEVENTF_DOWN) != 0)
            {
                pointerUpdateKind = PointerUpdateKind.LeftButtonReleased;
                eventType = PointerEventType.Released;
            }
            else
            {
                pointerUpdateKind = PointerUpdateKind.Other;
                eventType = PointerEventType.Moved;
            }

            var clientSize = control.ClientSize;
            var position = new Vector2((float)p.X / clientSize.Width, (float)p.Y / clientSize.Height);
            position.Saturate();

            var point = new PointerPoint
                        {
                            EventType = eventType,
                            DeviceType = ((flags & User32.TOUCHEVENTF_PEN) != 0) ? PointerDeviceType.Pen : PointerDeviceType.Touch,
                            PointerId = (uint)input.dwID,
                            Timestamp = (ulong)input.dwTime,
                            Position = position,
                            KeyModifiers = GetCurrentKeyModifiers(),
                            IsPrimary = isPrimary,
                            IsInRange = (flags & User32.TOUCHEVENTF_INRANGE) != 0,
                            TouchConfidence = (flags & User32.TOUCHEVENTF_PALM) != 0,
                            PointerUpdateKind = pointerUpdateKind,
                        };

            if ((mask & User32.TOUCHINPUTMASKF_CONTACTAREA) != 0)
                point.ContactRect = new RectangleF(position.X, position.Y, (float)AdjustX(input.cxContact) / clientSize.Width, (float)AdjustY(input.cyContact) / clientSize.Height);

            manager.AddPointerEvent(ref point);
        }
开发者ID:onefiftyone,项目名称:Toolkit,代码行数:54,代码来源:PointerPlatformDesktopTouch.cs

示例9: GetLocationInternal

        /// <inheritdoc />
        protected override Vector2 GetLocationInternal()
        {
            var p = Mouse.GetPosition(element);

            var position = new Vector2((float)(p.X / element.ActualWidth), (float)(p.Y / element.ActualHeight));
            position.Saturate();
            return position;
        }
开发者ID:chantsunman,项目名称:Toolkit,代码行数:9,代码来源:MousePlatformDesktopWpf.cs


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