本文整理汇总了C#中System.Windows.Media.GeneralTransform.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralTransform.Transform方法的具体用法?C# GeneralTransform.Transform怎么用?C# GeneralTransform.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.GeneralTransform
的用法示例。
在下文中一共展示了GeneralTransform.Transform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMatrix
internal static Matrix CreateMatrix(GeneralTransform transform)
{
if (transform != null && !IsIdentity(transform))
{
Point offset = transform.Transform(new Point(0, 0));
Point i = transform.Transform(new Point(1, 0)).Minus(offset);
Point j = transform.Transform(new Point(0, 1)).Minus(offset);
Matrix matrix = new Matrix(i.X, i.Y, j.X, j.Y, offset.X, offset.Y);
return matrix;
}
else
{
return Matrix.Identity;
}
}
示例2: TransformRectByMiddlePoint
static Rect TransformRectByMiddlePoint(GeneralTransform transform, Rect r)
{
// we don't want to adjust the size of the control when moving it out of a scaled
// container, we just want to move it correcly
Point p = new Point(r.Left + r.Width / 2, r.Top + r.Height / 2);
Vector movement = transform.Transform(p) - p;
return new Rect(r.TopLeft + movement, r.Size);
}
示例3: MouseMoved
/// <summary>
/// Handles when the mouse moves
/// </summary>
/// <param name="mousePos"></param>
/// <param name="screenToSceneTransform"></param>
public void MouseMoved(Point mousePos, GeneralTransform screenToSceneTransform)
{
if (screenToSceneTransform == null)
return;
// Convert the mouse coordinates to scene coordinates
mousePos = screenToSceneTransform.Transform(mousePos);
bool newLocked = false;
Point newPoint = mousePos;
if (points.Count > 0)
{
// Transform the minimum distance ignoring the translation
Rect minimumBounds = screenToSceneTransform.TransformBounds(minimumDistance);
double nearestDistanceSquared;
newPoint = GetEllipseScaledNearestPoint(points, mousePos, (Vector) (minimumBounds.Size),
out nearestDistanceSquared);
newLocked = nearestDistanceSquared <= 1;
}
bool lockedChanged = newLocked != locked;
bool pointChanged = newPoint != closestPoint;
locked = newLocked;
closestPoint = newPoint;
if ((pointChanged && locked) || lockedChanged)
{
OnClosestPointChanged();
}
}
示例4: MouseMoved
/// <summary>
/// Handles when the mouse moves
/// </summary>
/// <param name="mousePos"></param>
/// <param name="screenToSceneTransform"></param>
public Point MouseMoved(Point mousePos, GeneralTransform screenToSceneTransform) {
if(screenToSceneTransform == null)
return new Point(0, 0);
// Convert the mouse coordinates to scene coordinates
mousePos = screenToSceneTransform.Transform(mousePos);
// Transform the minimum distance ignoring the translation
Rect minimumBounds = screenToSceneTransform.TransformBounds(_minimumDistance);
return MouseMoved(mousePos, minimumBounds);
}
示例5: QueueMouseMove
public void QueueMouseMove(Point mousePos, GeneralTransform screenToSceneTransform) {
mousePos = screenToSceneTransform.Transform(mousePos);
Rect minimumBounds = screenToSceneTransform.TransformBounds(_minimumDistance);
_mousePosQueue.Add(new PointAndBounds(mousePos, minimumBounds));
}
示例6: ArrangeTicksAndMarkers
void ArrangeTicksAndMarkers(IEnumerable<DataAxisTick> ticksOrMarkers, GeneralTransform axisTransform, Size arrangeSize, double tickLength)
{
foreach (var tick in ticksOrMarkers)
{
Point tickLabelPosition;
switch (AxisLocation)
{
case AxisLocation.Top:
case AxisLocation.Bottom:
tick.Location = axisTransform.Transform(new Point(tick.Value, 0)).X;
if (tick.TextBlockBorder != null)
{
var yPos = tickLength;
if (AxisLocation == AxisLocation.Top) yPos += tick.TextBlockBorder.DesiredSize.Height;
tickLabelPosition = axisTransform.Transform(new Point(tick.Value, yPos));
tickLabelPosition.X -= tick.TextBlockBorder.DesiredSize.Width / 2;
tickLabelPosition.X = Math.Min(Math.Max(tickLabelPosition.X, 0), arrangeSize.Width - tick.TextBlockBorder.DesiredSize.Width);
tick.TextBlockBorder.Arrange(new Rect(tickLabelPosition, tick.TextBlockBorder.DesiredSize));
}
break;
case AxisLocation.Left:
case AxisLocation.Right:
tick.Location = axisTransform.Transform(new Point(tick.Value, 0)).Y;
if (tick.TextBlockBorder != null)
{
tickLabelPosition = axisTransform.Transform(new Point(tick.Value, tickLength + 2));
if (AxisLocation == AxisLocation.Left) tickLabelPosition.X -= tick.TextBlockBorder.DesiredSize.Width;
tickLabelPosition.Y -= tick.TextBlockBorder.DesiredSize.Height / 2;
tickLabelPosition.Y = Math.Min(Math.Max(tickLabelPosition.Y, 0), arrangeSize.Height - tick.TextBlockBorder.DesiredSize.Height);
tick.TextBlockBorder.Arrange(new Rect(tickLabelPosition, tick.TextBlockBorder.DesiredSize));
}
break;
default:
throw new ApplicationException("DataAxis: Unknown AxisLocation value.");
}
}
}
示例7: SetCoordinatesOnCursor
/// <summary>
/// Sets the coordinates on the cursor using the transform passed in
/// </summary>
/// <param name="mousePos"></param>
/// <param name="uiElement"></param>
/// <param name="transform"></param>
public void SetCoordinatesOnCursor(Point mousePos, FrameworkElement uiElement, GeneralTransform transform)
{
if (transform != null && hasPermissionToRun)
{
try
{
cursorPosition = mousePos;
lastCoordinate = transform.Transform(mousePos);
SetStringFormat(transform);
SetCoordinatesOnCursor(uiElement);
}
catch (Exception)
{
hasPermissionToRun = false;
}
}
}