本文整理汇总了C#中System.Drawing.Graphics.TranslateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.TranslateTransform方法的具体用法?C# Graphics.TranslateTransform怎么用?C# Graphics.TranslateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.TranslateTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(Graphics g)
{
g.FillRectangle(SystemBrushes.AppWorkspace, Bounds);
g.DrawRectangle(Pens.Black, mCanvasMarginWidth - 1, mCanvasMarginHeight - 1, 800 + 1, 600 + 1);
g.TranslateTransform(mCanvasMarginWidth, mCanvasMarginHeight);
GraphicsContainer containerState = g.BeginContainer();
g.SmoothingMode = SmoothingMode.HighQuality;
DrawCanvas(g);
g.SmoothingMode = SmoothingMode.Default;
g.EndContainer(containerState);
g.TranslateTransform(-mCanvasMarginWidth, -mCanvasMarginHeight);
//mCanvasBufferGraphics.FillRectangle(SystemBrushes.AppWorkspace, Bounds);
//mCanvasBufferGraphics.DrawRectangle(Pens.Black, mCanvasMarginWidth - 1, mCanvasMarginHeight - 1, 800 + 1, 600 + 1);
//DrawCanvas(mCanvasBufferGraphics);
//Rectangle src = Bounds;
//Rectangle dest = new Rectangle(0, 0, (int)(Bounds.Width * mScale), (int)(Bounds.Height * mScale));
//dest.X = (Bounds.Width / 2) - (dest.Width / 2);
//dest.Y = (Bounds.Height / 2) - (dest.Height / 2);
//g.DrawImage(mCanvasBufferImage, dest, src, GraphicsUnit.Pixel);
}
示例2: RenderSymbols
private void RenderSymbols( Graphics g )
{
float radius = _textureSize / 2 * 0.84f;
float centerX = _textureSize / 2;
float centerY = _textureSize / 2;
var symbols = GetSymbols();
using ( var font = new Font( "Meroitic - Hieroglyphics", _fontSize, FontStyle.Bold ) )
{
for ( int index = 0; index < _symbolCount; index++ )
{
char character = symbols[index];
float arc = 360f / _symbolCount;
float thetaDegrees = arc * index;
float thetaRadians = AsRadians( thetaDegrees );
var characterSize = MeasureCharacter( g, font, character );
var centerPoint = new PointF( centerX - characterSize.Width / 2, centerY - characterSize.Height / 2 );
float x = centerX + (float) Math.Cos( thetaRadians ) * radius;
float y = centerY + (float) Math.Sin( thetaRadians ) * radius;
g.TranslateTransform( x, y );
g.RotateTransform( thetaDegrees + 90 );
g.TranslateTransform( -x, -y );
g.TranslateTransform( -( characterSize.Width / 2 ), -( characterSize.Height / 2 ) );
g.DrawString( character.ToString(), font, _greenBrush, x, y );
g.ResetTransform();
}
}
}
示例3: PaintBackground
private void PaintBackground(Graphics g, Control control, Rectangle clipRect)
{
Control parent = control;
IPaintBackground asIpb = null;
while (true)
{
parent = parent.Parent;
if (parent == null)
{
break;
}
asIpb = parent as IPaintBackground;
if (asIpb != null)
{
break;
}
}
if (asIpb != null)
{
Rectangle screenRect = control.RectangleToScreen(clipRect);
Rectangle parentRect = parent.RectangleToClient(screenRect);
int dx = parentRect.Left - clipRect.Left;
int dy = parentRect.Top - clipRect.Top;
g.TranslateTransform(-dx, -dy, MatrixOrder.Append);
asIpb.PaintBackground(g, parentRect);
g.TranslateTransform(dx, dy, MatrixOrder.Append);
}
}
示例4: DrawLabel
/// <summary>
/// Renders a label to the map.
/// </summary>
/// <param name="graphics">Graphics reference</param>
/// <param name="labelPoint">Label placement</param>
/// <param name="offset">Offset of label in screen coordinates</param>
/// <param name="font">Font used for rendering</param>
/// <param name="forecolor">Font forecolor</param>
/// <param name="backcolor">Background color</param>
/// <param name="halo">Color of halo</param>
/// <param name="rotation">Text rotation in degrees</param>
/// <param name="text">Text to render</param>
/// <param name="viewport"></param>
public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
{
SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
{
graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
graphics.RotateTransform((float)rotation);
graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
var path = new GraphicsPath();
path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
}
else
{
if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
var path = new GraphicsPath();
//Arial hack
path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
if (halo != null)
graphics.DrawPath(halo.ToGdi(context), path);
graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
//g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
}
}
示例5: onManagedDraw
public override void onManagedDraw(Graphics graphics)
{
graphics.TranslateTransform (this.CenterX, this.CenterY);
graphics.RotateTransform (90 + this.Angle / (float)Math.PI * 180);
graphics.TranslateTransform (-this.CenterX, -this.CenterY);
base.onManagedDraw (graphics);
graphics.ResetTransform ();
}
示例6: Paint
public virtual void Paint(Graphics graphics)
{
foreach (GraphElement element in SubElements)
{
graphics.TranslateTransform(element.X, element.Y);
element.Paint(graphics);
graphics.TranslateTransform(-element.X, -element.Y);
}
}
示例7: Draw
public override void Draw(Graphics graphics)
{
if (graphics == null) return;
CollapseShape.DrawButton(graphics);
graphics.TranslateTransform(1, 1);
CollapseShape.DrawArrow(graphics);
graphics.TranslateTransform(0, 6);
CollapseShape.DrawArrow(graphics);
}
示例8: DrawArrow
private void DrawArrow(Graphics g,float dx,float dy,Color color)
{
int cx = 20;
int cy = 20;
Pen penWide = new Pen(color,2);
Point[] apt = {new Point(5*cx/32,3*cy/8),new Point(20*cx/32,0),new Point(20*cx/32,5*cy/8)};
penWide.LineJoin = LineJoin.Miter;
g.TranslateTransform(dx,dy);
g.DrawLines(penWide,apt);
g.TranslateTransform(-dx,-dy);
}
示例9: DrawElement
private void DrawElement(Graphics g, Act2DMapLayoutObject.Element e)
{
var bitmap = file.CreateBitmapForResource(e.resourceID);
if (bitmap == null) return;
g.TranslateTransform(e.x, e.y);
g.TranslateTransform(bitmap.Width * 0.5f, bitmap.Height * 0.5f);
g.RotateTransform(e.rotate);
g.ScaleTransform(e.scale_x, e.scale_y);
g.TranslateTransform(-bitmap.Width * 0.5f, -bitmap.Height * 0.5f);
g.DrawImage(bitmap, new PointF(0.0f, 0.0f));
}
示例10: Paint
public static void Paint(Graphics g, Report report)
{
g.TranslateTransform(10, 10);
PaintPlayer(g, report.Attacker.Village);
g.TranslateTransform(0, 27);
PaintTroops(g, report.Attack);
g.TranslateTransform(0, 70);
PaintPlayer(g, report.Defender.Village);
g.TranslateTransform(0, 27);
PaintTroops(g, report.Defense);
}
示例11: Draw
public void Draw(Graphics g)
{
float dL = length / 2.0f;
float dW = width / 2.0f;
g.TranslateTransform(x + dL, y + dW);
g.RotateTransform(angle);
g.TranslateTransform(-dL, -dW);
g.DrawRectangle(new Pen(Color.Black), 0, 0, length, width);
g.TranslateTransform(dL, dW);
g.RotateTransform(-angle);
g.TranslateTransform(-x - dL, -y - dW);
}
示例12: ApplyAlteration
/// <summary>
/// Apply the rotation
/// </summary>
/// <param name="p_g">Graphic object</param>
/// <param name="p_point">Location where to draw object</param>
/// <param name="p_bitmap">Reference to bitmap to draw on</param>
public virtual void ApplyAlteration(Graphics p_g, Point p_point, ref Bitmap p_bitmap)
{
p_g.TranslateTransform((float)(p_point.X), (float)(p_point.Y));
// Rotate desired degrees
p_g.RotateTransform((float)rotation * -1);
// Move the origin back to where it belongs while it is rotated
p_g.TranslateTransform((float)(p_point.X) * -1, (float)(p_point.Y) * -1);
rotation += angle;
if (rotation > 360) rotation -= 360;
}
示例13: Draw
public void Draw(Graphics gr, Point center, double textSizePercentage, bool showName)
{
gr.TranslateTransform(center.X, center.Y);
// center of logo is now considered (0,0)
gr.FillPolygon(Brushes.Yellow, new Point[] { starPoints[0], starPoints[2], starPoints[4], starPoints[1], starPoints[3] }, FillMode.Winding);
int r = (int)radius;
//gr.DrawEllipse(Pens.Black,- r, - r, 2 * r, 2 * r);
if (showName)
{
Font font = new Font("Tahoma", (float) (textSizePercentage * Radius / 500));
SizeF sizeF = gr.MeasureString(name, font);
gr.DrawString(name, font, Brushes.Black, new PointF(-sizeF.Width / 2, -sizeF.Height / 2));
}
gr.TranslateTransform(-center.X, -center.Y);
}
示例14: Draw
public void Draw(Graphics g, Player player)
{
if (ShootingPoints.Count > 0)
{
try
{
g.DrawCurve(shootingPen, ShootingPoints.ToArray());
g.TranslateTransform(1, 0);
g.DrawCurve(shootingPen1, ShootingPoints.ToArray());
g.ResetTransform();
}
catch (Exception e)
{
Console.WriteLine("Shot.cs-Draw-EXCEPTION : {0}", e.Message);
}
//STRELKA
Point lastOne = (Point)ShootingPoints[ShootingPoints.Count-1];
trianglePoints = new Point[3];
trianglePoints[0] = new Point(lastOne.X - 2, lastOne.Y - 10);
trianglePoints[1] = new Point(lastOne.X - 8, lastOne.Y + 2);
trianglePoints[2] = new Point(lastOne.X + 4, lastOne.Y + 2);
g.FillPolygon(new SolidBrush(Color.Black), trianglePoints);
trianglePoints = new Point[3];
}
}
示例15: OnRender
public override void OnRender(Graphics g)
{
#if !PocketPC
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.shadow50, LocalPosition.X, LocalPosition.Y);
}
g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);
if(Bearing.HasValue)
{
g.RotateTransform(Bearing.Value - Overlay.Control.Bearing);
g.FillPolygon(Brushes.Lime, Arrow);
}
g.ResetTransform();
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.bigMarkerGreen, LocalPosition.X, LocalPosition.Y);
}
#else
DrawImageUnscaled(g, Resources.shadow50, LocalPosition.X, LocalPosition.Y);
DrawImageUnscaled(g, Resources.marker, LocalPosition.X, LocalPosition.Y);
#endif
}