Changeset 1240 for trunk/sources/HeuristicLab.Visualization/Canvas.cs
- Timestamp:
- 03/02/09 22:03:41 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/Canvas.cs
r1038 r1240 1 using System; 1 2 using System.Diagnostics; 2 3 using System.Drawing; … … 4 5 5 6 namespace HeuristicLab.Visualization { 6 public class Canvas : I Canvas{7 private WorldShape world;7 public class Canvas : IShape { 8 private readonly WorldShape worldShape; 8 9 9 public WorldShape WorldShape { 10 get { return world; } 11 set { world = value; } 10 private Rectangle viewport; 11 12 public Canvas() { 13 worldShape = new WorldShape(); 14 worldShape.Parent = this; 12 15 } 13 16 17 public void AddShape(IShape shape) { 18 worldShape.AddShape(shape); 19 } 14 20 15 public void Draw(Graphics graphics, Rectangle viewport) { 21 public void RemoveShape(IShape shape) { 22 worldShape.RemoveShape(shape); 23 } 24 25 public void ClearShapes() { 26 worldShape.ClearShapes(); 27 } 28 29 public Rectangle Viewport { 30 get { return viewport; } 31 set { 32 viewport = value; 33 worldShape.ClippingArea = new RectangleD(0, 0, viewport.Width, viewport.Height); 34 worldShape.BoundingBox = worldShape.ClippingArea; 35 } 36 } 37 38 public RectangleD ClippingArea { 39 get { return worldShape.ClippingArea; } 40 } 41 42 public RectangleD BoundingBox { 43 get { throw new InvalidOperationException(); } 44 } 45 46 public IShape Parent { 47 get { throw new InvalidOperationException(); } 48 set { throw new InvalidOperationException(); } 49 } 50 51 public void Draw(Graphics graphics) { 16 52 Stopwatch sw = new Stopwatch(); 17 53 sw.Start(); 18 54 19 GraphicsState gstate = graphics.Save(); 55 graphics.SmoothingMode = SmoothingMode.AntiAlias; 56 graphics.FillRectangle(Brushes.White, Viewport); 20 57 21 graphics.SetClip(viewport);58 worldShape.Draw(graphics); 22 59 23 world.Draw(graphics, viewport, world.BoundingBox); 24 25 graphics.Restore(gstate); 60 graphics.DrawRectangle(Pens.Black, 0, 0, Viewport.Width - 1, Viewport.Height - 1); 26 61 27 62 sw.Stop();
Note: See TracChangeset
for help on using the changeset viewer.