- Timestamp:
- 05/05/10 15:36:28 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3566 r3638 26 26 using HeuristicLab.Core.Views; 27 27 using HeuristicLab.MainForm; 28 using System.Drawing; 28 29 29 30 namespace HeuristicLab.Optimization.Views { … … 58 59 } 59 60 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 60 76 protected override void OnContentChanged() { 61 77 base.OnContentChanged(); … … 65 81 if (Content == null) 66 82 Caption = "Run"; 67 else 83 else { 68 84 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 85 UpdateColorPictureBox(); 86 } 69 87 SetEnabledStateOfControls(); 70 88 } … … 80 98 listView.Enabled = Content != null; 81 99 viewHost.Enabled = Content != null; 100 changeColorButton.Enabled = Content != null; 82 101 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; 83 121 } 84 122
Note: See TracChangeset
for help on using the changeset viewer.