本文整理汇总了C#中System.Drawing.Graphics.BeginContainer方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.BeginContainer方法的具体用法?C# Graphics.BeginContainer怎么用?C# Graphics.BeginContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.BeginContainer方法的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: Draw
public override void Draw(Graphics g, int time)
{
// this.GPath.Reset();
GraphicsContainer container1 = g.BeginContainer();
g.SmoothingMode = base.OwnerDocument.SmoothingMode;
Matrix matrix1 = base.Transform.Matrix.Clone();
if (!base.Visible)
{
g.SetClip(Rectangle.Empty);
}
markerTransForm.Multiply(matrix1, MatrixOrder.Prepend);
base.GraphTransform.Matrix.Multiply(markerTransForm, MatrixOrder.Prepend);
SvgElementCollection.ISvgElementEnumerator enumerator1 = base.GraphList.GetEnumerator();
while (enumerator1.MoveNext())
{
IGraph graph1 = (IGraph) enumerator1.Current;
graph1.GraphTransform.Matrix = base.GraphTransform.Matrix.Clone();
graph1.IsMarkerChild = IsMarkerChild;
graph1.Draw(g, time);
}
this.pretime = time;
g.EndContainer(container1);
}
示例3: 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);
}
}
示例4: 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);
}
示例5: 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;
StringFormat format = new StringFormat {
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center,
Trimming = StringTrimming.Character,
FormatFlags = StringFormatFlags.NoWrap
};
int maxVisibleItems = base.MaxVisibleItems;
int scrollPosition = base.ScrollPosition;
for (int i = scrollPosition; (i < base.Items.Count) && (i < (scrollPosition + maxVisibleItems)); i++)
{
System.Workflow.ComponentModel.Design.ItemInfo itemInfo = base.Items[i];
Rectangle itemBounds = base.GetItemBounds(itemInfo);
int pageFoldSize = itemBounds.Width / 5;
GraphicsPath[] pathArray = ActivityDesignerPaint.GetPagePaths(itemBounds, pageFoldSize, DesignerContentAlignment.TopRight);
using (GraphicsPath path = pathArray[0])
{
using (GraphicsPath path2 = pathArray[1])
{
Brush white = Brushes.White;
if (base.SelectedItem == itemInfo)
{
white = PageStrip.SelectionBrush;
}
else if (base.HighlitedItem == itemInfo)
{
white = PageStrip.HighliteBrush;
}
graphics.FillPath(white, path);
graphics.DrawPath(Pens.DarkBlue, path);
graphics.FillPath(Brushes.White, path2);
graphics.DrawPath(Pens.DarkBlue, path2);
if (itemInfo.Image == null)
{
itemBounds.Y += pageFoldSize;
itemBounds.Height -= pageFoldSize;
graphics.DrawString((i + 1).ToString(CultureInfo.CurrentCulture), Control.DefaultFont, SystemBrushes.ControlText, itemBounds, format);
}
else
{
itemBounds.Y += pageFoldSize;
itemBounds.Height -= pageFoldSize;
itemBounds.X += (itemBounds.Width - itemBounds.Height) / 2;
itemBounds.Width = itemBounds.Height;
itemBounds.Inflate(-2, -2);
ActivityDesignerPaint.DrawImage(graphics, itemInfo.Image, itemBounds, DesignerContentAlignment.Center);
}
}
}
}
}
graphics.EndContainer(container);
}
示例6: 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);
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
}
示例13: Draw
public override void Draw(Graphics graphics)
{
GraphicsContainer graphicsState = graphics.BeginContainer();
Rectangle bounds = Bounds;
using (Region clipRegion = new Region(new Rectangle(bounds.X, bounds.Y, bounds.Width + 1, bounds.Height + 1)))
{
graphics.Clip = clipRegion;
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
format.Trimming = StringTrimming.Character;
format.FormatFlags = StringFormatFlags.NoWrap;
int visibleItems = MaxVisibleItems;
int scrollPosition = ScrollPosition;
for (int itemIndex = scrollPosition; itemIndex < Items.Count && itemIndex < (scrollPosition + visibleItems); itemIndex++)
{
ItemInfo itemInfo = Items[itemIndex];
Rectangle itemRectangle = GetItemBounds(itemInfo);
int margin = itemRectangle.Width / 5;
GraphicsPath[] graphicsPath = ActivityDesignerPaint.GetPagePaths(itemRectangle, margin, DesignerContentAlignment.TopRight);
using (GraphicsPath pagePath = graphicsPath[0])
using (GraphicsPath pageFoldPath = graphicsPath[1])
{
Brush pageBrush = Brushes.White;
if (SelectedItem == itemInfo)
pageBrush = PageStrip.SelectionBrush;
else if (HighlitedItem == itemInfo)
pageBrush = PageStrip.HighliteBrush;
graphics.FillPath(pageBrush, pagePath);
graphics.DrawPath(Pens.DarkBlue, pagePath);
graphics.FillPath(Brushes.White, pageFoldPath);
graphics.DrawPath(Pens.DarkBlue, pageFoldPath);
if (itemInfo.Image == null)
{
itemRectangle.Y += margin;
itemRectangle.Height -= margin;
int index = itemIndex + 1;
graphics.DrawString(index.ToString(CultureInfo.CurrentCulture), Control.DefaultFont, SystemBrushes.ControlText, (RectangleF)itemRectangle, format);
}
else
{
itemRectangle.Y += margin; itemRectangle.Height -= margin;
itemRectangle.X += (itemRectangle.Width - itemRectangle.Height) / 2;
itemRectangle.Width = itemRectangle.Height;
itemRectangle.Inflate(-2, -2);
ActivityDesignerPaint.DrawImage(graphics, itemInfo.Image, itemRectangle, DesignerContentAlignment.Center);
}
}
}
}
graphics.EndContainer(graphicsState);
}
示例14: 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);
}
}
示例15: Draw2
/// <summary>
/// ��·
/// </summary>
/// <param name="g"></param>
/// <param name="time"></param>
private void Draw2(Graphics g, int time)
{
if (base.DrawVisible) {
Matrix matrix1 = base.Transform.Matrix.Clone();
GraphicsContainer container1 = g.BeginContainer();
g.SmoothingMode = base.OwnerDocument.SmoothingMode;
Matrix matrix2 = base.GraphTransform.Matrix.Clone();
base.GraphTransform.Matrix.Multiply(matrix1, MatrixOrder.Prepend);
ClipAndMask.ClipPath.Clip(g, time, this);
bool flag1 = base.Visible;
if (!base.Visible) {
g.SetClip(Rectangle.Empty);
}
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();
}
}
//.........这里部分代码省略.........