- Timestamp:
- 04/21/10 18:42:21 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionTreeChart.Designer.cs
r3244 r3470 25 25 private void InitializeComponent() { 26 26 this.components = new System.ComponentModel.Container(); 27 this.pictureBox = new System.Windows.Forms.PictureBox();28 27 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 29 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();30 28 this.SuspendLayout(); 31 //32 // pictureBox33 //34 this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;35 this.pictureBox.Location = new System.Drawing.Point(0, 0);36 this.pictureBox.Name = "pictureBox";37 this.pictureBox.Size = new System.Drawing.Size(150, 150);38 this.pictureBox.TabIndex = 0;39 this.pictureBox.TabStop = false;40 this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseMove);41 this.pictureBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseDoubleClick);42 this.pictureBox.MouseClick += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseClick);43 this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseDown);44 this.pictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SymbolicExpressionTreeChart_MouseUp);45 29 // 46 30 // SymbolicExpressionTreeChart … … 48 32 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 49 33 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 50 this.Controls.Add(this.pictureBox);51 34 this.Name = "SymbolicExpressionTreeChart"; 52 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();53 35 this.ResumeLayout(false); 54 55 36 } 56 37 57 38 #endregion 58 39 59 private System.Windows.Forms.PictureBox pictureBox;60 40 private System.Windows.Forms.ToolTip toolTip; 61 41 } -
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.