本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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)));
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}