本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Multiply方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.Matrix.Multiply方法的具体用法?C# System.Drawing.Drawing2D.Matrix.Multiply怎么用?C# System.Drawing.Drawing2D.Matrix.Multiply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.Matrix.Multiply方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Area_Paint
/// <summary>
/// Draw all areas of the selected quest and highlight the selected area.
/// </summary>
private void Area_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Area.BackColor);
Matrix transformMatrix = new Matrix();
transformMatrix.Rotate(90);
transformMatrix.Multiply(new Matrix(-1, 0, 0, 1, 0, 0)); // Flip x-axis
WoWQuestStep[] steps = ((QuestDisplayData)bsQuests.Current).Steps;
float maxX = steps.Max(step => step.AreaPoints.Max(ap => ap.X));
float maxY = steps.Max(step => step.AreaPoints.Max(ap => ap.Y));
transformMatrix.Translate(-maxX - 5, -maxY - 5);
e.Graphics.Transform = transformMatrix;
// Draw all areas
foreach (WoWQuestStep step in steps)
{
PointF[] drawPoints = ConvertToDrawingPoints(step.AreaPoints);
if (drawPoints.Length < 3)
{
foreach (PointF point in drawPoints)
{
// Draw a point 5x5 pixels
e.Graphics.FillEllipse(AREA_FILL, point.X - 2, point.Y - 2, 5F, 5F);
e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
}
}
else
{
e.Graphics.FillPolygon(AREA_FILL, drawPoints);
e.Graphics.DrawPolygon(AREA_BORDER, drawPoints);
}
}
// Highlight selected area
if (SelectedAreaPoints != null)
{
if (SelectedAreaPoints.Length < 3)
{
foreach (PointF point in SelectedAreaPoints)
{
e.Graphics.FillEllipse(AREA_HIGHLIGHT, point.X - 2, point.Y - 2, 5F, 5F);
e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
}
}
else
{
e.Graphics.FillPolygon(AREA_HIGHLIGHT, this.SelectedAreaPoints);
e.Graphics.DrawPolygon(AREA_BORDER, this.SelectedAreaPoints);
}
}
}
示例2: Draw
/// <summary>
/// Draw page and its children
/// </summary>
/// <param name="gc"></param>
/// <param name="clipRect"></param>
public void Draw(Graphics gc, Rectangle clipRect)
{
System.Drawing.Drawing2D.Matrix finalMatrix = new System.Drawing.Drawing2D.Matrix();
finalMatrix = this.drawMatrix.Clone();
finalMatrix.Multiply(this.ViewMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
gc.Transform = finalMatrix;
// draw fill color
using (SolidBrush brush = new SolidBrush(fillColor))
{
gc.FillRectangle(brush, 0, 0, (float)this.WidthInPixels, (float)this.HeightInPixels);
}
// draw background image
if (pictureForDisplay != null)
{
gc.DrawImage(pictureForDisplay, 0, 0, (float)this.WidthInPixels, (float)this.HeightInPixels);
}
this.LastDrawMatrix = finalMatrix;
EditorController.Instance.Grid.Draw(gc);
foreach(EditorItem item in Children)
{
item.Draw(this.ViewMatrix, gc, clipRect);
}
// draw item commands
foreach (EditorItem child in Children)
{
child.DrawCommands((float)this.ZoomLevel / 100, gc);
}
}
示例3: DrawFillPattern
//.........这里部分代码省略.........
var pen = new Pen(System.Drawing.Color.Black)
{
Width = 1f / matrixScale
};
float dashLength = 1;
var segments = fillGrid.GetSegments();
if (segments.Count > 0)
{
pen.DashPattern = segments
.Select(Convert.ToSingle)
.ToArray();
Debug.Print("\tSegments:");
foreach (var segment in segments)
{
Debug.Print("\t\t{0}", segment);
}
dashLength = pen.DashPattern.Sum();
}
g.ResetTransform();
var rotateMatrix = new Matrix();
rotateMatrix.Rotate(degreeAngle);
var matrix = new Matrix(1, 0,
0, -1,
centerX, centerY); //-1 reflects about x-axis
matrix.Scale(matrixScale, matrixScale);
matrix.Translate((float)fillGrid.Origin.U,
(float)fillGrid.Origin.V);
var backMatrix = matrix.Clone();
backMatrix.Multiply(rotateMatrix);
matrix.Multiply(rotateMatrix);
var offset = (-10) * dashLength;
matrix.Translate(offset, 0);
backMatrix.Translate(offset, 0);
Debug.Print("Offset: {0}", offset);
bool moving_forward = true;
bool moving_back = true;
int safety = 500;
double alternator = 0;
while (moving_forward || moving_back) //draw segments shifting and offsetting each time
{
Debug.Write("*");
var rectF1 = new RectangleF(-2 / matrixScale, -2 / matrixScale, 4 / matrixScale, 4 / matrixScale);
if (moving_forward && LineIntersectsRect(matrix, viewRect))
{
g.Transform = matrix;
g.DrawLine(pen, new PointF(0, 0), new PointF(LENGTH, 0));
}
else
{
moving_forward = false;
Debug.Print("\n----> Matrix does not intersect view");
}
if (moving_back && LineIntersectsRect(backMatrix, viewRect))
{
g.Transform = backMatrix;
g.DrawLine(pen, new PointF(0, 0), new PointF(LENGTH, 0));
}
示例4: 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;
}
}
示例5: Draw
public virtual void Draw(float zoomLevel, System.Drawing.Graphics gc)
{
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(this.Owner.ViewMatrix, System.Drawing.Drawing2D.MatrixOrder.Append);
gc.Transform = mat;
float w = (float)this.WidthInPixels / this.Owner.ViewMatrix.Elements[0];
float h = (float)this.HeightInPixels / this.Owner.ViewMatrix.Elements[3];
Pen p = new Pen(Color.Gray, 1.0f / zoomLevel);
gc.DrawRectangle(p, 0, 0, w, h);
}
示例6: 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;
}
}
示例7: drawUsingPolygon
private void drawUsingPolygon(DrawContext context, System.Drawing.Drawing2D.Matrix transform, ScenicColor color)
{
#if PENDING
if (glyphPolygons == null)
{
glyphPolygons = new FilledPath[glyphCodes.Length];
for (int i = 0; i < glyphCodes.Length; i++)
{
System.Drawing.Drawing2D.Matrix temp_Matrix;
temp_Matrix = new System.Drawing.Drawing2D.Matrix();
temp_Matrix.Translate((float) positions[i * 2], (float) positions[i * 2 + 1]);
System.Drawing.Drawing2D.Matrix at = temp_Matrix;
//UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"'
System.Drawing.Drawing2D.GraphicsPath shape = TextRenderer.getGlyphOutline(font, at, glyphCodes[i]);
Path path = new AWTShapePath(shape);
glyphPolygons[i] = new FilledPath(path);
}
}
System.Drawing.Drawing2D.Matrix temp = new System.Drawing.Drawing2D.Matrix();
for (int i = 0; i < glyphPolygons.Length; i++)
{
System.Drawing.Drawing2D.Matrix temp_Matrix2;
temp_Matrix2 = new System.Drawing.Drawing2D.Matrix();
temp_Matrix2.Translate((float) positions[i * 2], (float) positions[i * 2 + 1]);
System.Drawing.Drawing2D.Matrix at = temp_Matrix2;
//UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.setTransform' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtgeomAffineTransformsetTransform_javaawtgeomAffineTransform_3"'
temp.setTransform(transform);
//UPGRADE_TODO: Method 'java.awt.geom.AffineTransform.concatenate' was converted to 'System.Drawing.Drawing2D.Matrix.Multiply' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_javaawtgeomAffineTransformconcatenate_javaawtgeomAffineTransform_3"'
temp.Multiply(at, System.Drawing.Drawing2D.MatrixOrder.Append);
glyphPolygons[i].draw(context, temp, color);
}
#endif
}