本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Invert方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.Matrix.Invert方法的具体用法?C# System.Drawing.Drawing2D.Matrix.Invert怎么用?C# System.Drawing.Drawing2D.Matrix.Invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.Matrix.Invert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCursor
/// <summary>
/// Return cursor for command
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="zoomLevel"></param>
/// <returns>null if coordinates are not fine</returns>
public Cursor GetCursor(float x, float y, System.Drawing.Drawing2D.Matrix viewMatrix)
{
// transform x,y back to object coordinates to check for selection
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
mat.Multiply(this.TransformationMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Multiply(this.Owner.DrawMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Multiply(viewMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Invert();
PointF tmpPoint = new PointF(x, y);
PointF[] points = new PointF[1];
points[0] = tmpPoint;
mat.TransformPoints(points);
tmpPoint = points[0];
// check if this item should be selected
float w = (float)this.WidthInPixels / this.Owner.ViewMatrix.Elements[0];
float h = (float)this.HeightInPixels / this.Owner.ViewMatrix.Elements[3];
// if starting coordinate fall inside this component rect
if (tmpPoint.X >= 0 && tmpPoint.X <= w && tmpPoint.Y >= 0 && tmpPoint.Y <= h)
{
return this.cursor;
}
else
{
return null;
}
}
示例2: CanBeSelected
/// <summary>
/// Check if this command can be selected and return true in case it can
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool CanBeSelected(float x, float y, System.Drawing.Drawing2D.Matrix viewMatrix)
{
// transform x,y back to object coordinates to check for selection
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
mat.Multiply(this.TransformationMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Multiply(this.Owner.DrawMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Multiply(viewMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
mat.Invert();
PointF tmpPoint = new PointF(x, y);
PointF[] points = new PointF[1];
points[0] = tmpPoint;
mat.TransformPoints(points);
tmpPoint = points[0];
// check if this item should be selected
//float tmpX = LocationInPixelsX * zoomLevel;
//float tmpY = LocationInPixelsY * zoomLevel;
//float w = widthInPixels; //** zoomLevel;
//float h = heightInPixels; //* zoomLevel;
float w = (float)this.WidthInPixels / this.Owner.ViewMatrix.Elements[0];
float h = (float)this.HeightInPixels / this.Owner.ViewMatrix.Elements[3];
// if starting coordinate fall inside this component rect
if (tmpPoint.X >= 0 && tmpPoint.X <= w && tmpPoint.Y >= 0 && tmpPoint.Y <= h)
{
return true;
}
else
{
return false;
}
}
示例3: walk
public virtual void walk(PathWalker walker, System.Drawing.Drawing2D.Matrix errorMatrix, double error)
{
//UPGRADE_TODO: Interface 'java.awt.geom.PathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
//UPGRADE_TODO: Method 'java.awt.Shape.getPathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator.GraphicsPathIterator' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtShapegetPathIterator_javaawtgeomAffineTransform_double_3"'
System.Drawing.Drawing2D.GraphicsPathIterator itr = new System.Drawing.Drawing2D.GraphicsPathIterator(shape);
double[] point = new double[6];
int i = 0;
System.Drawing.Drawing2D.Matrix inv;
double m00, m01, m10, m11, dx, dy;
try
{
System.Drawing.Drawing2D.Matrix temp_Matrix;
temp_Matrix = new System.Drawing.Drawing2D.Matrix();
temp_Matrix = errorMatrix.Clone();
temp_Matrix.Invert();
inv = temp_Matrix;
}
catch (System.Exception e)
{
return ;
}
m00 = (float) inv.Elements.GetValue(0);
m01 = (float) inv.Elements.GetValue(2);
m10 = (float) inv.Elements.GetValue(1);
m11 = (float) inv.Elements.GetValue(3);
dx = (System.Single) inv.OffsetX;
dy = (System.Single) inv.OffsetY;
//UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.isDone' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorisDone_3"'
while (!itr.isDone())
{
//UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.currentSegment' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorcurrentSegment_double[]_3"'
int type = itr.currentSegment(point);
//UPGRADE_ISSUE: Method 'java.awt.geom.PathIterator.next' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratornext_3"'
itr.next();
//UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_MOVETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_MOVETO_f_3"'
if (type == PathIterator.SEG_MOVETO)
{
if (i > 0)
{
walk(walker, points, i, false);
i = 0;
}
points[i++] = m00 * point[0] + m01 * point[1] + dx;
points[i++] = m10 * point[0] + m11 * point[1] + dy;
}
else
{
//UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_LINETO' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_LINETO_f_3"'
if (type == PathIterator.SEG_LINETO)
{
points[i++] = m00 * point[0] + m01 * point[1] + dx;
points[i++] = m10 * point[0] + m11 * point[1] + dy;
}
else
{
//UPGRADE_ISSUE: Field 'java.awt.geom.PathIterator.SEG_CLOSE' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomPathIteratorSEG_CLOSE_f_3"'
if (type == PathIterator.SEG_CLOSE)
{
if (i > 0)
{
walk(walker, points, i, true);
i = 0;
}
}
}
}
}
if (i > 0)
{
walk(walker, points, i, false);
i = 0;
}
}
示例4: TransformPoints
/// <summary>
/// use matrix to transform point
/// </summary>
/// <param name="pts">contain the points to be transformed</param>
private void TransformPoints(Point[] pts)
{
System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(
1, 0, 0, 1, m_sizePictureBox.Width / 2, m_sizePictureBox.Height / 2);
matrix.Invert();
matrix.TransformPoints(pts);
}
示例5: GraphicsView_MouseMove
private void GraphicsView_MouseMove(object sender, MouseEventArgs e)
{
if (movestart == null) return;
if (!TranslateFocus)
return;
System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
//m.Translate(Translate.X, Translate.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
m.Scale(ZoomScale, ZoomScale, System.Drawing.Drawing2D.MatrixOrder.Append);
m.Invert();
Point movement = new Point(movestart.X - e.X, movestart.Y - e.Y);
movement.X = -movement.X;
movement.Y = -movement.Y;
Point[] t = new Point[] { movement };
m.TransformPoints(t);
movement = t[0];
Translate.X -= movestart.X - e.X;
Translate.Y -= movestart.Y - e.Y;
movestart = e.Location;
HighPrecisionDraw = false;
this.Refresh();
}