Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/21/10 18:42:21 (14 years ago)
Author:
mkommend
Message:

updated SymbolicExpressionTreeChart (ticket #938)

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  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
    27       this.pictureBox = new System.Windows.Forms.PictureBox();
    2827      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    29       ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    3028      this.SuspendLayout();
    31       //
    32       // pictureBox
    33       //
    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);
    4529      //
    4630      // SymbolicExpressionTreeChart
     
    4832      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    4933      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    50       this.Controls.Add(this.pictureBox);
    5134      this.Name = "SymbolicExpressionTreeChart";
    52       ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
    5335      this.ResumeLayout(false);
    54 
    5536    }
    5637
    5738    #endregion
    5839
    59     private System.Windows.Forms.PictureBox pictureBox;
    6040    private System.Windows.Forms.ToolTip toolTip;
    6141  }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionTreeChart.cs

    r3442 r3470  
    3131namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3232  public sealed partial class SymbolicExpressionTreeChart : UserControl {
     33    private Image image;
    3334    private StringFormat stringFormat;
    3435    private Dictionary<SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
     
    3637    public SymbolicExpressionTreeChart() {
    3738      InitializeComponent();
     39      this.image = new Bitmap(Width, Height);
    3840      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;
    4243      this.spacing = 5;
    4344      this.lineColor = Color.Black;
     
    101102    }
    102103
     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    }
    103116
    104117    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)) {
    106124        graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
    107125        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     
    111129          DrawFunctionTree(tree, graphics, 0, 0, this.Width, height);
    112130        }
    113 
    114         pictureBox.Refresh();
    115131      }
    116132    }
     
    188204
    189205    #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 
    196206    private void DrawFunctionTree(SymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) {
    197207      DrawFunctionTree(tree.Root, graphics, x, y, width, height, Point.Empty);
     
    276286    }
    277287    #endregion
    278 
    279288  }
    280289}
Note: See TracChangeset for help on using the changeset viewer.