Changeset 3470 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionTreeChart.cs
- Timestamp:
- 04/21/10 18:42:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionTreeChart.cs
r3442 r3470 31 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { 32 32 public sealed partial class SymbolicExpressionTreeChart : UserControl { 33 private Image image; 33 34 private StringFormat stringFormat; 34 35 private Dictionary<SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; … … 36 37 public SymbolicExpressionTreeChart() { 37 38 InitializeComponent(); 39 this.image = new Bitmap(Width, Height); 38 40 this.stringFormat = new StringFormat(); 39 stringFormat.Alignment = StringAlignment.Center; 40 stringFormat.LineAlignment = StringAlignment.Center; 41 pictureBox.Image = new Bitmap(pictureBox.Width, pictureBox.Height); 41 this.stringFormat.Alignment = StringAlignment.Center; 42 this.stringFormat.LineAlignment = StringAlignment.Center; 42 43 this.spacing = 5; 43 44 this.lineColor = Color.Black; … … 101 102 } 102 103 104 protected override void OnPaint(PaintEventArgs e) { 105 base.OnPaint(e); 106 e.Graphics.DrawImage(image, 0, 0); 107 } 108 protected override void OnResize(EventArgs e) { 109 base.OnResize(e); 110 if (this.Width == 0 || this.Height == 0) 111 this.image = new Bitmap(1, 1); 112 else 113 this.image = new Bitmap(Width, Height); 114 this.Repaint(); 115 } 103 116 104 117 public void Repaint() { 105 using (Graphics graphics = Graphics.FromImage(pictureBox.Image)) { 118 this.GenerateImage(); 119 this.Refresh(); 120 } 121 122 private void GenerateImage() { 123 using (Graphics graphics = Graphics.FromImage(image)) { 106 124 graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; 107 125 graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; … … 111 129 DrawFunctionTree(tree, graphics, 0, 0, this.Width, height); 112 130 } 113 114 pictureBox.Refresh();115 131 } 116 132 } … … 188 204 189 205 #region methods for painting the symbolic expression tree 190 protected override void OnResize(EventArgs e) {191 base.OnResize(e);192 pictureBox.Image = new Bitmap(pictureBox.Width, pictureBox.Height);193 Repaint();194 }195 196 206 private void DrawFunctionTree(SymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) { 197 207 DrawFunctionTree(tree.Root, graphics, x, y, width, height, Point.Empty); … … 276 286 } 277 287 #endregion 278 279 288 } 280 289 }
Note: See TracChangeset
for help on using the changeset viewer.