本文整理汇总了C#中System.Drawing.Graphics.EndContainer方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.EndContainer方法的具体用法?C# Graphics.EndContainer怎么用?C# Graphics.EndContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.EndContainer方法的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: DrawRegionRepresentation
public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
{
if (m_Param.Path.PointCount > 0)
{
GraphicsPath fill = new GraphicsPath();
RectangleF rect = m_Param.Path.GetBounds();
PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
// this will draw beyond the shape's location
for (double i = -rect.Height; i < rect.Height; i++)
{
PointD pt1 = refPt + PointD.Orthogonal(m_Param.V) * i * drawMethods.Spacing(m_Param.C);
PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;
fill.StartFigure();
fill.AddLine((Point)pt2, (Point)pt3);
}
GraphicsContainer c = gc.BeginContainer();
gc.SetClip((Tools.Model.VectorPath)m_Param.Path);
gc.DrawPath(r.RegionGuides, fill);
gc.EndContainer(c);
}
}
示例3: DrawTile
public void DrawTile(Graphics graph)
{
var pointsByColors = this.GetAllBordersPoints();
var containerState = graph.BeginContainer();
graph.RotateTransform(90 * (int)this.Rotation);
this.DrawPoints(graph, pointsByColors);
this.DrawText(graph);
graph.EndContainer(containerState);
}
示例4: Paint
/// <summary>
/// Paints the entity using the given graphics object
/// </summary>
/// <param name="g"></param>
public override void Paint(Graphics g)
{
if(!Visible)
return;
if(mIcon != null)
{
GraphicsContainer cto = g.BeginContainer();
g.SetClip(Shape.Rectangle);
g.DrawImage(mIcon, Rectangle);
g.EndContainer(cto);
}
}
示例5: Paint
public override void Paint(Graphics g, TerrainMap tm)
{
if (tm.IsOnboard(Coords) && tm.Los[Coords])
{
var container = g.BeginContainer();
tm.TranslateGraphicsToHex(g, Coords);
g.DrawImage(_bmp, tm.BoardHexes[Coords].Board.HexgridPath.GetBounds());
if (tm.ShowHexgrid) g.DrawPath(Pens.Black, tm.HexgridPath);
g.EndContainer(container);
}
}
示例6: OnRender
public override void OnRender(Graphics g)
{
//g.DrawRectangle(Pen, new System.Drawing.Rectangle(LocalPosition.X, LocalPosition.Y, Size.Width, Size.Height));
{
g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);
var c = g.BeginContainer();
{
g.RotateTransform(Bearing - Overlay.Control.Bearing);
g.ScaleTransform(Scale, Scale);
g.FillPolygon(Fill, Arrow);
}
g.EndContainer(c);
g.TranslateTransform(-ToolTipPosition.X, -ToolTipPosition.Y);
}
}
示例7: DrawReverseString
public static void DrawReverseString( Graphics g, string drawText, Font drawFont, Rectangle drawRect, Brush drawBrush, StringFormat drawFormat )
{
GraphicsContainer container = g.BeginContainer();
// The text will be rotated around the origin (0,0) and so needs moving
// back into position by using a transform
g.TranslateTransform(drawRect.Left * 2 + drawRect.Width,
drawRect.Top * 2 + drawRect.Height);
// Rotate the text by 180 degress to reverse the direction
g.RotateTransform(180);
// Draw the string as normal and let then transforms do the work
g.DrawString(drawText, drawFont, drawBrush, drawRect, drawFormat);
g.EndContainer(container);
}
示例8: BeginContainerVoid
private void BeginContainerVoid(Graphics g)
{
// Begin graphics container.
GraphicsContainer containerState = g.BeginContainer();
// Translate world transformation.
g.TranslateTransform(100.0F, 100.0F);
// Fill translated rectangle in container with red.
g.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);
// End graphics container.
g.EndContainer(containerState);
// Fill untransformed rectangle with green.
g.FillRectangle(new SolidBrush(Color.Green), 0, 0, 200, 200);
}
示例9: FillShadow
protected virtual void FillShadow(Graphics g, RectangleF r)
{
Color sc = Color.FromArgb(100,
this.ShadowColor.R,
this.ShadowColor.G,
this.ShadowColor.B
);
SolidBrush brush = new SolidBrush(sc);
SmoothingMode m = g.SmoothingMode;
g.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsContainer cont = g.BeginContainer();
g.TranslateTransform(this.ShadowWidth,this.ShadowWidth);
g.FillRectangle(brush,r.X,r.Y,r.Width,r.Height);
g.EndContainer(cont);
g.SmoothingMode = m;
}
示例10: Draw
public override void Draw(Graphics graphics)
{
GraphicsContainer container = graphics.BeginContainer();
Rectangle bounds = base.Bounds;
using (Region region = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1)))
{
graphics.Clip = region;
base.itemStrip.Draw(graphics);
if (base.itemStrip.ScrollPosition > 0)
{
this.DrawButton(graphics, (base.Orientation == Orientation.Horizontal) ? ScrollButton.Left : ScrollButton.Up);
}
if ((base.itemStrip.ScrollPosition + base.itemStrip.MaxVisibleItems) < base.itemStrip.Items.Count)
{
this.DrawButton(graphics, (base.Orientation == Orientation.Horizontal) ? ScrollButton.Right : ScrollButton.Down);
}
}
graphics.EndContainer(container);
}
示例11: DrawInBox
public void DrawInBox(Graphics g, RectangleF box,GraphicsUnit gu)
{
if (box.IsEmpty)return;
GraphicsContainer gc = g.BeginContainer(box,this.GPath.GetBounds(),gu);
SvgElementCollection.ISvgElementEnumerator enumerator1 = base.GraphList.GetEnumerator();
Matrix matrix1 = base.GraphTransform.Matrix.Clone();
while (enumerator1.MoveNext())
{
IGraph graph1 = (IGraph) enumerator1.Current;
Matrix matrix2 = graph1.GraphTransform.Matrix;
graph1.GraphTransform.Matrix =new Matrix();
graph1.Draw(g, 0);
}
g.EndContainer(gc);
}
示例12: Draw
public override void Draw(Graphics g)
{
base.Draw(g);
System.Drawing.Drawing2D.GraphicsContainer gc1 = g.BeginContainer(); {
g.TranslateTransform((int)this.X,(int)this.Y);
// Color
int alpha = (int)( (1.0 - (double)this.Age/(double)_maxAge) * 255 );
if(alpha > 255) alpha = 255;
Color c = Color.FromArgb(alpha,Color.White);
// Focus Circle
g.DrawEllipse(new Pen(c),
(int)(-this.Radius),
(int)(-this.Radius),
(int)(this.Radius*2),
(int)(this.Radius*2) );
// Draw message
g.DrawString(this.Contents.ToString(), Config.DisplayTextFont, new SolidBrush(c), new PointF(-Config.DisplayTextFont.Size/2,this.Radius-Config.DisplayTextFont.Size*2));
} g.EndContainer(gc1);
}
示例13: DrawDropShadow
internal static void DrawDropShadow(Graphics graphics, Rectangle shadowSourceRectangle, Color baseColor, int shadowDepth, LightSourcePosition lightSourcePosition, float lightSourceIntensity, bool roundEdges)
{
if (graphics == null)
{
throw new ArgumentNullException("graphics");
}
if ((shadowSourceRectangle.IsEmpty || (shadowSourceRectangle.Width < 0)) || (shadowSourceRectangle.Height < 0))
{
throw new ArgumentException(SR.GetString("Error_InvalidShadowRectangle"), "shadowRectangle");
}
if ((shadowDepth < 1) || (shadowDepth > 12))
{
throw new ArgumentException(SR.GetString("Error_InvalidShadowDepth"), "shadowDepth");
}
if ((lightSourceIntensity <= 0f) || (lightSourceIntensity > 1f))
{
throw new ArgumentException(SR.GetString("Error_InvalidLightSource"), "lightSourceIntensity");
}
Rectangle rectangle = shadowSourceRectangle;
Size empty = Size.Empty;
if ((lightSourcePosition & LightSourcePosition.Center) > 0)
{
rectangle.Inflate(shadowDepth, shadowDepth);
}
if ((lightSourcePosition & LightSourcePosition.Left) > 0)
{
empty.Width += shadowDepth + 1;
}
else if ((lightSourcePosition & LightSourcePosition.Right) > 0)
{
empty.Width -= shadowDepth + 1;
}
if ((lightSourcePosition & LightSourcePosition.Top) > 0)
{
empty.Height += shadowDepth + 1;
}
else if ((lightSourcePosition & LightSourcePosition.Bottom) > 0)
{
empty.Height -= shadowDepth + 1;
}
rectangle.Offset(empty.Width, empty.Height);
GraphicsContainer container = graphics.BeginContainer();
GraphicsPath path = new GraphicsPath();
if (roundEdges)
{
path.AddPath(GetRoundedRectanglePath(shadowSourceRectangle, 8), true);
}
else
{
path.AddRectangle(shadowSourceRectangle);
}
try
{
using (Region region = new Region(path))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.ExcludeClip(region);
Color color = Color.FromArgb(Convert.ToInt32((float) (40f * lightSourceIntensity)), baseColor);
int num = Math.Max(40 / shadowDepth, 2);
for (int i = 0; i < shadowDepth; i++)
{
rectangle.Inflate(-1, -1);
using (Brush brush = new SolidBrush(color))
{
using (GraphicsPath path2 = new GraphicsPath())
{
if (roundEdges)
{
path2.AddPath(GetRoundedRectanglePath(rectangle, 8), true);
}
else
{
path2.AddRectangle(rectangle);
}
graphics.FillPath(brush, path2);
}
}
color = Color.FromArgb(color.A + num, color.R, color.G, color.B);
}
}
}
finally
{
graphics.EndContainer(container);
}
}
示例14: Draw2
//.........这里部分代码省略.........
float single1 = this.StrokeOpacity;
if (this.svgAnimAttributes.ContainsKey("fill-opacity")) {
single1 = Math.Min(single1, (float)this.svgAnimAttributes["fill-opacity"]);
}
ISvgBrush brush1 = this.GraphBrush;
using (GraphicsPath path1 = (GraphicsPath)this.GPath.Clone()) {
path1.Transform(base.GraphTransform.Matrix);
if (!base.ShowBound) {
float width1 = Width * GraphTransform.Matrix.Elements[0];
Stroke stroke = Stroke.GetStroke(this);
Color color1 = Color.FromArgb(75, 75, 75);
if (stroke.StrokeColor.ToArgb()!=Color.Black.ToArgb()) color1 = stroke.StrokeColor;
using (Pen p = new Pen(Color.FromArgb((int)(single1 * 255), color1))) {
p.Width = width1;
g.DrawPath(p, path1);
}
if (LineType == "3") {
using (Pen p = new Pen(Color.Yellow)) {
if (width1 > 30)
p.Width = 2;
else
p.Width = 1;
//p.DashPattern = new float[] { 10, 10 };
g.DrawPath(p, path1);
}
} else {
//using (Pen p = new Pen(Color.Yellow)) {
// if (width1 > 30)
// p.Width = 2;
// else
// p.Width = 1;
// g.DrawPath(p, path1);
//}
}
if (LineType == "4") {
using (Pen p = new Pen(Color.FromArgb((int)(single1*255),color1))) {
p.Width = width1;
float f22 = width1 / 4f;
ImageAttributes imageAttributes = new ImageAttributes();
ColorMatrix cmatrix1 = new ColorMatrix();
cmatrix1.Matrix00 = 1f;
cmatrix1.Matrix11 = 1f;
cmatrix1.Matrix22 = 1f;
cmatrix1.Matrix33 = single1;//����
cmatrix1.Matrix44 = 1f;
//��������
imageAttributes.SetColorMatrix(cmatrix1, ColorMatrixFlag.Default, ColorAdjustType.Default);
if (BackgroundImage == null) BackgroundImageFile = "road.png";
TextureBrush tbush = new TextureBrush(BackgroundImage,new Rectangle(0,0,BackgroundImage.Width,BackgroundImage.Height),imageAttributes);
tbush.WrapMode = WrapMode.Tile;
for (int i = 0; i < path1.PointCount - 1;i++ ) {
float k = (path1.PathPoints[i+1].Y - path1.PathPoints[i].Y) / (path1.PathPoints[i+1].X - path1.PathPoints[i].X);
float y1 = path1.PathPoints[i].Y - path1.PathPoints[i+1].Y;
float y2 = path1.PathPoints[i].X - path1.PathPoints[i+1].X;
float k2 = (float)Math.Abs(k);
float angle = (float)Math.Atan(k2) * 180 / (float)Math.PI;
if (k < 0) { angle = 360-angle; }
PointF[] pts = new PointF[] { new PointF(path1.PathPoints[i].X, path1.PathPoints[i].Y - 26) };
Matrix matrix11 = new Matrix();
matrix11.RotateAt(angle, path1.PathPoints[i]);
matrix11.Translate(path1.PathPoints[i].X, path1.PathPoints[i].Y);
matrix11.Scale(width1 / 50, width1 / 50);
//tbush.ScaleTransform(width1 / 50, width1 / 50, MatrixOrder.Append);
//tbush.RotateTransform(angle, MatrixOrder.Append);
//tbush.TranslateTransform(path1.PathPoints[i].X, path1.PathPoints[i].Y , MatrixOrder.Append);
tbush.Transform = matrix11;
p.Brush = tbush.Clone() as TextureBrush;
p.Alignment = PenAlignment.Center;
g.DrawLine(p, path1.PathPoints[i], path1.PathPoints[i + 1]);
tbush.ResetTransform();
}
}
if (BackgroundImageFile == "road.png") {
using (Pen p = new Pen(Color.Yellow)) {
if (width1 > 30)
p.Width = 2;
else
p.Width = 1;
g.DrawPath(p, path1);
}
}
}
} else {
g.DrawPath(new Pen(base.BoundColor), path1);
}
this.DrawConnect(g);
}
matrix1.Dispose();
ClipAndMask.ClipPath.DrawClip(g, time, this);
g.EndContainer(container1);
this.pretime = time;
}
}
示例15: PaintMarkers
protected void PaintMarkers(Graphics g)
{
string markerStartUrl = extractMarkerUrl(this.GetAttribute("marker-start"));
string markerEndUrl = extractMarkerUrl(this.GetAttribute("marker-end"));
PointF[] points1 = this.Points.Clone() as PointF[];
int num1 = 0;
int num11 = 1;
int num3 = 0;
int num33 = 1;
if (points1.Length > 3) {
num33 = points1.Length - 1;
num3 = num33 - 1;
}
base.GraphTransform.Matrix.TransformPoints(points1);
float angle = 0f;//(float)(180*Math.Atan2(points1[1].Y - points1[0].Y,points1[1].X-points1[0].X)/Math.PI);
GraphicsContainer container1 = g.BeginContainer();
Marker element1;
if (markerStartUrl.Length > 0) {
angle = (float)(180 * Math.Atan2(points1[num11].Y - points1[num1].Y, points1[num11].X - points1[num1].X) / Math.PI);
element1 = (Marker)NodeFunc.GetRefNode(markerStartUrl, this.OwnerDocument);
if (element1 is Marker) {
((Marker)element1).GraphTransform.Matrix = new Matrix();
Matrix matrix1 = ((Marker)element1).MarkerTransForm;
matrix1.Rotate(angle);
matrix1.Translate(points1[num1].X, points1[num1].Y, MatrixOrder.Append);
element1.GraphStroke = this.GraphStroke;
element1.IsMarkerChild = true;
((Marker)element1).Draw(g, 0);
}
}
if (markerEndUrl.Length > 0) {
angle = (float)(180 * Math.Atan2(points1[num33].Y - points1[num3].Y, points1[num33].X - points1[num3].X) / Math.PI);
element1 = (Marker)NodeFunc.GetRefNode(markerEndUrl, this.OwnerDocument);
if (element1 is Marker) {
((Marker)element1).GraphTransform.Matrix = new Matrix();
Matrix matrix1 = ((Marker)element1).MarkerTransForm;
matrix1.Rotate(angle);
matrix1.Translate(points1[num33].X, points1[num33].Y, MatrixOrder.Append);
element1.GraphStroke = this.GraphStroke;
element1.IsMarkerChild = true;
((Marker)element1).Draw(g, 0);
}
}
g.EndContainer(container1);
}