本文整理汇总了C#中System.Drawing.Graphics.MultiplyTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.MultiplyTransform方法的具体用法?C# Graphics.MultiplyTransform怎么用?C# Graphics.MultiplyTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.MultiplyTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawDisabled
protected override void DrawDisabled(Graphics g, ArrowDirection direction)
{
g.DrawEllipse(_disabledPen, _circleRect);
if (direction == ArrowDirection.Right)
g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 23, 0));
g.DrawPath(_disabledArrowPen, _arrowPath);
}
示例2: TransformGraphics
/// <summary>
/// Transforms the graphics context is such a way, that the object can be drawn in local coordinates.
/// </summary>
/// <param name="g">Graphics context (should be saved beforehand).</param>
protected override void TransformGraphics(Graphics g)
{
g.MultiplyTransform(_transformation);
}
示例3: Paint
public virtual void Paint(Graphics g)
{
GraphicsState savedgstate = g.Save();
//g.TranslateTransform(m_LayerPosition.X,m_LayerPosition.Y);
//g.RotateTransform(m_LayerAngle);
g.MultiplyTransform(_cachedForwardMatrix);
RectangleF layerBounds = new RectangleF(_cachedLayerPosition, _cachedLayerSize);
_gridPlanes.Paint(g, this);
_axisStyles.Paint(g, this);
if (ClipDataToFrame==LayerDataClipping.StrictToCS)
{
g.Clip = CoordinateSystem.GetRegion();
}
foreach (IGPlotItem pi in _plotItems)
{
pi.Paint(g, this);
}
if (ClipDataToFrame==LayerDataClipping.StrictToCS)
{
g.ResetClip();
}
_graphObjects.DrawObjects(g, 1, this);
_legends.DrawObjects(g, 1, this);
g.Restore(savedgstate);
}
示例4: GraphToLayerCoordinates
/// <summary>
/// This switches the graphics context from printable area coordinates to layer coordinates.
/// </summary>
/// <param name="g">The graphics state to change.</param>
public void GraphToLayerCoordinates(Graphics g)
{
g.MultiplyTransform(_cachedForwardMatrix);
}
示例5: DrawListsToGraphics
private void DrawListsToGraphics(ref Graphics g)
{
if (mGfxBuff == null) return;
mCurPen.Width = -1;
{
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.PageUnit = GraphicsUnit.Inch;
g.ResetTransform();
g.MultiplyTransform(mMtxWCS);
//Draw the axis indicator and axis lines
foreach (clsDisplayList p in mWcsDisplayLists)
{
if (p.Rapid)
{
mWCSPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
mWCSPen.DashPattern = mAxisDashStyle;
}
else
{
mWCSPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
}
mWCSPen.Color = p.Color;
g.DrawLines(mWCSPen, p.Points);
}
g.ResetTransform();
//Now draw the toolpath
mRapidDashStyle[0] = 0.05f / mScaleToReal;
mRapidDashStyle[1] = 0.05f / mScaleToReal;
g.MultiplyTransform(mMtxDraw);
foreach (clsDisplayList p in mDisplayLists)
{
if (!p.InView)
{
continue;
}
if (p.Rapid)
{
mCurPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
mCurPen.DashPattern = mRapidDashStyle;
}
else
{
mCurPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
}
mCurPen.Color = p.Color;
LineFixUp(ref p.Points);
g.DrawLines(mCurPen, p.Points);
}
}
}
示例6: PlotLabels
protected virtual void PlotLabels(Graphics g, float labelspacing)
{
if (!OKToRender())
return;
int ypos = Height - ProtectedBottomPadding; //y2Pxl(0.0);
float ylabelspacing = GetTickSpacingEstimate(MinY, MaxY);
SizeF size = g.MeasureString("0", LabelFont);
while (size.Height > (ConvertYToPixel(0) - ConvertYToPixel(ylabelspacing)))
{
ylabelspacing = ylabelspacing*2;
}
if (labelspacing == 0 || ylabelspacing == 0)
return;
double xval = FindMin(MinX, labelspacing);
float yval = FindMin(MinY, ylabelspacing);
double oldxval = xval;
float oldyval = yval;
// draw the x grid labels
xval = oldxval;
StringFormat format = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
using (Brush labelBrush = new SolidBrush(LabelColor))
{
using (Brush titleBrush = new SolidBrush(TitleColor))
{
using (Brush axesLabelBrush = new SolidBrush(AxesLabelColor))
{
int xpos;
string cstr;
SizeF strsize;
if (_showTickLabels)
{
float tMax = MaxX;
while (xval <= tMax)
{
double displayXVal = xval + XAxisOffset;
xpos = (int) ConvertXToPixel(xval);
if (displayXVal == (int) displayXVal)
cstr = string.Format("{0}", (int) displayXVal);
else
{
if (labelspacing < 0.06 || xval < .01)
cstr = string.Format("{0:F3}", displayXVal);
else if (labelspacing < 0.6 || xval < .1)
cstr = string.Format("{0:F2}", displayXVal);
else
cstr = string.Format("{0:F1}", displayXVal);
}
if (cstr.EndsWith("000000000")) cstr = cstr.Substring(0, cstr.Length - 9) + "G";
if (cstr.EndsWith("000000")) cstr = cstr.Substring(0, cstr.Length - 6) + "M";
if (cstr.EndsWith("000")) cstr = cstr.Substring(0, cstr.Length - 3) + "K";
strsize = g.MeasureString(cstr, LabelFont);
if (!_hideXLabels)
{
g.DrawString(cstr, LabelFont, labelBrush,
new Rectangle(xpos - (int) strsize.Width/2 - 2,
Height - ProtectedBottomPadding + 1,
(int) strsize.Width + 4, (int) strsize.Height), format);
}
xval = xval + labelspacing;
}
}
else if (XAxisLabels.Count > 0 && _hideXLabels == false)
{
int minimumXPos = int.MinValue;
float sin = (float) Math.Sin(Math.PI*Math.Abs(_xAxisLabelRotation)/180);
foreach (AxisLabel label in XAxisLabels)
{
xpos = (int) ConvertXToPixel(label.Position);
int ytry = Height - ProtectedBottomPadding + 1;
strsize = g.MeasureString(label.Value, LabelFont);
Matrix saveCoordFrame1 = g.Transform.Clone();
int xtry;
int xkeepout;
if (_xAxisLabelRotation != 0)
{
xtry = xpos - 2 - (int) strsize.Width;
ytry = Height - ProtectedBottomPadding - 1;
xkeepout = (int) (strsize.Height/sin) + 1;
Matrix m1 = new Matrix();
m1.RotateAt(_xAxisLabelRotation, new PointF(xpos, Height - ProtectedBottomPadding));
g.MultiplyTransform(m1);
if (xpos > minimumXPos)
{
g.DrawString(label.Value, LabelFont, labelBrush,
new Rectangle(xtry, ytry, (int) (strsize.Width + 1),
(int) (strsize.Height + 1)), format);
minimumXPos = xpos + xkeepout;
//.........这里部分代码省略.........
示例7: DrawPressed
protected override void DrawPressed(Graphics g, ArrowDirection direction)
{
g.FillEllipse(_pressedBrush,
new RectangleF(_circleRect.X - 0.5f, _circleRect.Y - 0.5f, _circleRect.Width + 1,
_circleRect.Height + 1));
if (direction == ArrowDirection.Right)
g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 23, 0));
g.DrawPath(_hoverArrowPen, _arrowPath);
}
示例8: AfterPaint
/// <summary>
/// Draws the temporary line(s) from the first point to the mouse.
/// </summary>
/// <param name="g"></param>
public override void AfterPaint(Graphics g)
{
if (_currentPoint >= 1)
{
if (null != _grac.ActiveLayer)
{
g.MultiplyTransform(_cachedActiveLayerTransformationGdi);
// g.TranslateTransform((float)_grac.ActiveLayer.Position.X, (float)_grac.ActiveLayer.Position.Y);
// g.RotateTransform((float)-_grac.ActiveLayer.Rotation);
var currLayerCoord = _cachedActiveLayerTransformation.InverseTransformPoint(_positionCurrentMouseInRootLayerCoordinates);
DrawRectangleFromLTRB(g, _Points[0].LayerCoordinates, currLayerCoord);
}
else
{
DrawRectangleFromLTRB(g, _Points[0].RootLayerCoordinates, _positionCurrentMouseInRootLayerCoordinates);
}
}
}
示例9: Paint
//.........这里部分代码省略.........
// next statement is necessary to have a consistent string length both
// on 0 degree rotated text and rotated text
// without this statement, the text is fitted to the pixel grid, which
// leads to "steps" during scaling
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
double[] relpositions;
AltaxoVariant[] ticks;
if (useMinorTicks)
{
relpositions = ticking.GetMinorTicksNormal(raxis);
ticks = ticking.GetMinorTicksAsVariant();
}
else
{
relpositions = ticking.GetMajorTicksNormal(raxis);
ticks = ticking.GetMajorTicksAsVariant();
}
if (!_suppressedLabels.IsEmpty)
{
List<AltaxoVariant> filteredTicks = new List<AltaxoVariant>();
List<double> filteredRelPositions = new List<double>();
for (int i = 0; i < ticks.Length; i++)
{
if (_suppressedLabels.ByValues.Contains(ticks[i]))
continue;
if (_suppressedLabels.ByNumbers.Contains(i))
continue;
if (_suppressedLabels.ByNumbers.Contains(i - ticks.Length))
continue;
filteredTicks.Add(ticks[i]);
filteredRelPositions.Add(relpositions[i]);
}
ticks = filteredTicks.ToArray();
relpositions = filteredRelPositions.ToArray();
}
IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks);
double emSize = _font.Size;
CSAxisSide labelSide = null != _labelSide ? _labelSide.Value : styleInfo.PreferredLabelSide;
for (int i = 0; i < ticks.Length; i++)
{
double r = relpositions[i];
if (!Altaxo.Calc.RMath.IsInIntervalCC(r, -1000, 1000))
continue;
outer = coordSyst.GetLogicalDirection(styleID.ParallelAxisNumber, labelSide);
PointD2D tickorg = coordSyst.GetNormalizedDirection(r0, r1, r, outer, out outVector);
PointD2D tickend = tickorg + outVector * outerDistance;
PointD2D msize = labels[i].Size;
PointD2D morg = tickend;
if (_automaticRotationShift)
{
double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
double shift = msize.Y * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.X + _font.Size / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
morg = morg + outVector * shift;
}
else
{
morg = morg.WithXPlus(outVector.X * _font.Size / 3);
}
RectangleD2D mrect = new RectangleD2D(morg, msize);
if (_automaticRotationShift)
AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
else
AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);
math.Reset();
math.Translate((float)morg.X, (float)morg.Y);
if (this._rotation != 0)
{
math.Rotate((float)-this._rotation);
}
math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));
System.Drawing.Drawing2D.GraphicsState gs = g.Save();
g.MultiplyTransform(math);
if (this._backgroundStyle != null)
_backgroundStyle.Draw(g, new RectangleD2D(PointD2D.Empty, msize));
_brush.SetEnvironment(new RectangleD2D(PointD2D.Empty, msize), BrushX.GetEffectiveMaximumResolution(g, 1));
labels[i].Draw(g, _brush, new PointF(0, 0));
g.Restore(gs); // Restore the graphics state
helperPath.Reset();
helperPath.AddRectangle(new RectangleF(PointF.Empty, (SizeF)msize));
helperPath.Transform(math);
_enclosingPath.AddPath(helperPath, true);
}
}
示例10: GraphicsPath
private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected
public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks)
{
_cachedStyleID = styleInfo.Identifier;
CSLineID styleID = styleInfo.Identifier;
Scale raxis = styleID.ParallelAxisNumber==0 ? layer.XAxis : layer.YAxis;
_enclosingPath.Reset();
_enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
GraphicsPath helperPath = new GraphicsPath();
Matrix math = new Matrix();
Logical3D r0 = _cachedStyleID.Begin;
Logical3D r1 = _cachedStyleID.End;
SizeF layerSize = layer.Size;
PointF outVector;
Logical3D outer;
float outerDistance = null==axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide);
float dist_x = outerDistance; // Distance from axis tick point to label
float dist_y = outerDistance; // y distance from axis tick point to label
// dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks
// next statement is necessary to have a consistent string length both
// on 0 degree rotated text and rotated text
// without this statement, the text is fitted to the pixel grid, which
// leads to "steps" during scaling
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
double[] relpositions;
AltaxoVariant[] ticks;
if(useMinorTicks)
{
relpositions = raxis.GetMinorTicksNormal();
ticks = raxis.GetMinorTicksAsVariant();
}
else
{
relpositions = raxis.GetMajorTicksNormal();
ticks = raxis.GetMajorTicksAsVariant();
}
IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g,_font,_stringFormat,ticks);
float emSize = _font.SizeInPoints;
for(int i=0;i<ticks.Length;i++)
{
double r = relpositions[i];
outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide);
PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
PointF tickend = tickorg;
tickend.X += outVector.X * outerDistance;
tickend.Y += outVector.Y * outerDistance;
SizeF msize = labels[i].Size;
PointF morg = tickend;
if (_automaticRotationShift)
{
double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
morg.X += (float)(outVector.X * shift);
morg.Y += (float)(outVector.Y * shift);
}
else
{
morg.X += (float)(outVector.X * _font.SizeInPoints/3);
}
RectangleF mrect = new RectangleF(morg,msize);
if(_automaticRotationShift)
AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
else
AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);
math.Reset();
math.Translate((float)morg.X, (float)morg.Y);
if (this._rotation != 0)
{
math.Rotate((float)-this._rotation);
}
math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));
System.Drawing.Drawing2D.GraphicsState gs = g.Save();
g.MultiplyTransform(math);
if(this._backgroundStyle!=null)
_backgroundStyle.Draw(g,new RectangleF(PointF.Empty,msize));
_brush.Rectangle = new RectangleF(PointF.Empty, msize);
labels[i].Draw(g,_brush,new PointF(0,0));
g.Restore(gs); // Restore the graphics state
helperPath.Reset();
helperPath.AddRectangle(new RectangleF(PointF.Empty, msize));
//.........这里部分代码省略.........
示例11: ApplyAlteration
/// <summary>
/// Fulfill the IAlteration contract. Applies the matrix alteration
/// to the Graphics object of the sprite.
/// Bug:
/// </summary>
/// <param name="p_g">
/// A <see cref="Graphics"/> on which the sprite is being drawn
/// </param>
/// <param name="p_point">
/// A <see cref="Point"/> indicating where the sprite will be drawn
/// </param>
/// <param name="p_bitmap">
/// A <see cref="Bitmap"/> of the sprite
/// </param>
public void ApplyAlteration(Graphics p_g, Point p_point, ref Bitmap p_bitmap)
{
//p_g.Transform = matrix;
p_g.MultiplyTransform(matrix);
}
示例12: DrawLineArrowInternal
private static PointF DrawLineArrowInternal(Graphics gfx, Pen pen, Brush brush, float x, float y, float angle, ArrowStyle style)
{
PointF pt;
var rt = new Matrix();
rt.RotateAt(angle, new PointF(x, y));
double rx = style.RadiusX;
double ry = style.RadiusY;
double sx = 2.0 * rx;
double sy = 2.0 * ry;
switch (style.ArrowType)
{
default:
case ArrowType.None:
{
pt = new PointF(x, y);
}
break;
case ArrowType.Rectangle:
{
var pts = new PointF[] { new PointF(x - (float)sx, y) };
rt.TransformPoints(pts);
pt = pts[0];
var rect = new Rect2(x - sx, y - ry, sx, sy);
var gs = gfx.Save();
gfx.MultiplyTransform(rt);
DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
gfx.Restore(gs);
}
break;
case ArrowType.Ellipse:
{
var pts = new PointF[] { new PointF(x - (float)sx, y) };
rt.TransformPoints(pts);
pt = pts[0];
var gs = gfx.Save();
gfx.MultiplyTransform(rt);
var rect = new Rect2(x - sx, y - ry, sx, sy);
DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
gfx.Restore(gs);
}
break;
case ArrowType.Arrow:
{
var pts = new PointF[]
{
new PointF(x, y),
new PointF(x - (float)sx, y + (float)sy),
new PointF(x, y),
new PointF(x - (float)sx, y - (float)sy),
new PointF(x, y)
};
rt.TransformPoints(pts);
pt = pts[0];
var p11 = pts[1];
var p21 = pts[2];
var p12 = pts[3];
var p22 = pts[4];
DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
}
break;
}
return pt;
}
示例13: drawInputImage
private void drawInputImage(Graphics g, int width, int height)
{
using (var brush = new SolidBrush(Color.Black))
{
if (inputBGImage != null)
g.DrawImage(inputBGImage, 0, 0);
g.Transform = currentM;
g.MultiplyTransform(transM, MatrixOrder.Append);
g.InterpolationMode = InterpolationMode.High;
g.DrawString(inputWord, inputStringFontDialog.Font, brush, 0, 0);
g.ResetTransform();
}
}
示例14: SetupGraphics
public void SetupGraphics(Graphics g, string detail)
{
scale = (double)(this.Height - 2 * padding_top) / Table.Height;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TranslateTransform((this.Width / 2) - (int)((scale * Table.Width) / 2), this.Height - padding_top);
g.DrawString(detail, this.Font, Brushes.Black, 0, 10);
g.MultiplyTransform(flip_vertically);
}
示例15: DrawDisabled
protected override void DrawDisabled(Graphics g, ArrowDirection direction)
{
g.FillPath(_disabledUpperBackgroundBrush, _upperBackgroundPath);
g.FillPath(_disabledLowerBackgroundBrush, _lowerBackgroundPath);
g.FillPath(_disabledUpperBrush, _upperBackgroundPath);
g.FillPath(_disabledLowerBrush, _lowerBackgroundPath);
if (direction == ArrowDirection.Right)
g.MultiplyTransform(new Matrix(-1, 0, 0, 1, 24f, 0));
g.DrawPath(_disabledArrowPen, _arrowPath);
}