public EndContainer ( GraphicsContainer container ) : void | ||
container | GraphicsContainer | |
return | void |
using System.Drawing; using System.Drawing.Drawing2D; public void DrawRectangleWithMatrix() { Graphics gr = CreateGraphics(); GraphicsContainer container = gr.BeginContainer(); ColorMatrix cm = new ColorMatrix(new float[][] { new float[] {1, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {0, 0, 1, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1}}); ImageAttributes ia = new ImageAttributes(); ia.SetColorMatrix(cm); gr.Transform = new Matrix(1, 0, 0, -1, 0, 300); Rectangle rect = new Rectangle(50, 50, 100, 100); gr.DrawRectangle(new Pen(Color.Black, 2), rect); gr.EndContainer(container); gr.Dispose(); }
using System.Drawing; using System.Drawing.Drawing2D; public void DrawTwoTransformedRectangles() { Graphics gr = CreateGraphics(); GraphicsContainer container1 = gr.BeginContainer(); gr.Transform = new Matrix(1, 0, 0, -1, 0, 300); Rectangle rect1 = new Rectangle(50, 50, 100, 100); gr.DrawRectangle(new Pen(Color.Red, 2), rect1); gr.EndContainer(container1); GraphicsContainer container2 = gr.BeginContainer(); gr.Transform = new Matrix(1, 0, 0, 1, 200, 100); Rectangle rect2 = new Rectangle(50, 50, 100, 100); gr.DrawRectangle(new Pen(Color.Blue, 2), rect2); gr.EndContainer(container2); gr.Dispose(); }Both of these examples use the System.Drawing namespace, which is included in the .NET Framework class library.