Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/05/10 15:36:28 (14 years ago)
Author:
mkommend
Message:

corrected behavior auf RunCollectionBubbleChart and added color to RunView (ticket #970)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r3566 r3638  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using System.Drawing;
    2829
    2930namespace HeuristicLab.Optimization.Views {
     
    5859    }
    5960
     61    protected override void RegisterContentEvents() {
     62      base.RegisterContentEvents();
     63      Content.Changed += new EventHandler(Content_Changed);
     64    }
     65    protected override void DeregisterContentEvents() {
     66      base.DeregisterContentEvents();
     67      Content.Changed -= new EventHandler(Content_Changed);
     68    }
     69    private void Content_Changed(object sender, EventArgs e) {
     70      if (InvokeRequired)
     71        this.Invoke(new EventHandler(Content_Changed), sender, e);
     72      else
     73        UpdateColorPictureBox();
     74    }
     75
    6076    protected override void OnContentChanged() {
    6177      base.OnContentChanged();
     
    6581      if (Content == null)
    6682        Caption = "Run";
    67       else
     83      else {
    6884        Caption = Content.Name + " (" + Content.GetType().Name + ")";
     85        UpdateColorPictureBox();
     86      }
    6987      SetEnabledStateOfControls();
    7088    }
     
    8098      listView.Enabled = Content != null;
    8199      viewHost.Enabled = Content != null;
     100      changeColorButton.Enabled = Content != null;
    82101      showAlgorithmButton.Enabled = Content != null && !Locked;
     102    }
     103
     104    private void changeColorButton_Click(object sender, EventArgs e) {
     105      if (colorDialog.ShowDialog(this) == DialogResult.OK) {
     106        this.Content.Color = this.colorDialog.Color;
     107      }
     108    }
     109    private void UpdateColorPictureBox() {
     110      this.colorDialog.Color = this.Content.Color;
     111      this.colorPictureBox.Image = this.GenerateImage(colorPictureBox.Width, colorPictureBox.Height, this.Content.Color);
     112    }
     113    private Image GenerateImage(int width, int height, Color fillColor) {
     114      Image colorImage = new Bitmap(width, height);
     115      using (Graphics gfx = Graphics.FromImage(colorImage)) {
     116        using (SolidBrush brush = new SolidBrush(fillColor)) {
     117          gfx.FillRectangle(brush, 0, 0, width, height);
     118        }
     119      }
     120      return colorImage;
    83121    }
    84122
Note: See TracChangeset for help on using the changeset viewer.