Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/11 13:59:25 (13 years ago)
Author:
epitzer
Message:

#1530 integrate changes from trunk

Location:
branches/PersistenceSpeedUp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PersistenceSpeedUp

  • branches/PersistenceSpeedUp/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs

    r5832 r6760  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    2423using System.Windows.Forms;
    25 using HeuristicLab.Common;
    2624using HeuristicLab.Core;
    27 using HeuristicLab.Core.Views;
    2825using HeuristicLab.MainForm;
    29 using HeuristicLab.PluginInfrastructure;
    3026
    3127namespace HeuristicLab.Optimization.Views {
    32   /// <summary>
    33   /// The base class for visual representations of items.
    34   /// </summary>
    3528  [View("Experiment View")]
    3629  [Content(typeof(Experiment), true)]
    37   public sealed partial class ExperimentView : NamedItemView {
     30  public sealed partial class ExperimentView : IOptimizerView {
     31    public ExperimentView() {
     32      InitializeComponent();
     33    }
     34
    3835    public new Experiment Content {
    3936      get { return (Experiment)base.Content; }
     
    4138    }
    4239
    43     /// <summary>
    44     /// Initializes a new instance of <see cref="ItemBaseView"/>.
    45     /// </summary>
    46     public ExperimentView() {
    47       InitializeComponent();
    48     }
    49 
    50     protected override void DeregisterContentEvents() {
    51       Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    52       Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    53       Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    54       Content.Prepared -= new EventHandler(Content_Prepared);
    55       Content.Started -= new EventHandler(Content_Started);
    56       Content.Paused -= new EventHandler(Content_Paused);
    57       Content.Stopped -= new EventHandler(Content_Stopped);
    58       base.DeregisterContentEvents();
    59     }
    60     protected override void RegisterContentEvents() {
    61       base.RegisterContentEvents();
    62       Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    63       Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    64       Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
    65       Content.Prepared += new EventHandler(Content_Prepared);
    66       Content.Started += new EventHandler(Content_Started);
    67       Content.Paused += new EventHandler(Content_Paused);
    68       Content.Stopped += new EventHandler(Content_Stopped);
    69     }
    70 
    7140    protected override void OnContentChanged() {
    7241      base.OnContentChanged();
    7342      if (Content == null) {
    74         optimizerListView.Content = null;
     43        experimentTreeView.Content = null;
    7544        runsViewHost.Content = null;
    76         executionTimeTextBox.Text = "-";
    7745      } else {
    78         Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started;
    79         optimizerListView.Content = Content.Optimizers;
     46        experimentTreeView.Content = Content;
    8047        runsViewHost.Content = Content.Runs;
    81         executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    8248      }
    8349    }
     
    8551    protected override void SetEnabledStateOfControls() {
    8652      base.SetEnabledStateOfControls();
    87       optimizerListView.Enabled = Content != null;
     53      experimentTreeView.Enabled = Content != null;
    8854      runsViewHost.Enabled = Content != null;
    89       executionTimeTextBox.Enabled = Content != null;
    90       SetEnabledStateOfExecutableButtons();
    9155    }
    9256
     
    10266      base.OnClosed(e);
    10367    }
    104 
    105     #region Content Events
    106     private void Content_ExecutionStateChanged(object sender, EventArgs e) {
    107       if (InvokeRequired)
    108         Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
    109       else
    110         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    111     }
    112     private void Content_Prepared(object sender, EventArgs e) {
    113       if (InvokeRequired)
    114         Invoke(new EventHandler(Content_Prepared), sender, e);
    115       else {
    116         nameTextBox.Enabled = infoLabel.Enabled = true;
    117         ReadOnly = Locked = false;
    118         SetEnabledStateOfExecutableButtons();
    119       }
    120     }
    121     private void Content_Started(object sender, EventArgs e) {
    122       if (InvokeRequired)
    123         Invoke(new EventHandler(Content_Started), sender, e);
    124       else {
    125         nameTextBox.Enabled = infoLabel.Enabled = false;
    126         ReadOnly = Locked = true;
    127         SetEnabledStateOfExecutableButtons();
    128       }
    129     }
    130     private void Content_Paused(object sender, EventArgs e) {
    131       if (InvokeRequired)
    132         Invoke(new EventHandler(Content_Paused), sender, e);
    133       else {
    134         nameTextBox.Enabled = infoLabel.Enabled = true;
    135         ReadOnly = Locked = false;
    136         SetEnabledStateOfExecutableButtons();
    137       }
    138     }
    139     private void Content_Stopped(object sender, EventArgs e) {
    140       if (InvokeRequired)
    141         Invoke(new EventHandler(Content_Stopped), sender, e);
    142       else {
    143         nameTextBox.Enabled = infoLabel.Enabled = true;
    144         ReadOnly = Locked = false;
    145         SetEnabledStateOfExecutableButtons();
    146       }
    147     }
    148     private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    149       if (InvokeRequired)
    150         Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
    151       else
    152         executionTimeTextBox.Text = Content == null ? "-" : Content.ExecutionTime.ToString();
    153     }
    154     private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    155       if (InvokeRequired)
    156         Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    157       else
    158         ErrorHandling.ShowErrorDialog(this, e.Value);
    159     }
    160     #endregion
    161 
    162     #region Control events
    163     private void startButton_Click(object sender, EventArgs e) {
    164       Content.Start();
    165     }
    166     private void pauseButton_Click(object sender, EventArgs e) {
    167       Content.Pause();
    168     }
    169     private void stopButton_Click(object sender, EventArgs e) {
    170       Content.Stop();
    171     }
    172     private void resetButton_Click(object sender, EventArgs e) {
    173       Content.Prepare(false);
    174     }
    175     #endregion
    176 
    177     #region Helpers
    178     private void SetEnabledStateOfExecutableButtons() {
    179       if (Content == null) {
    180         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    181       } else {
    182         startButton.Enabled = (Content.ExecutionState == ExecutionState.Prepared) || (Content.ExecutionState == ExecutionState.Paused);
    183         pauseButton.Enabled = Content.ExecutionState == ExecutionState.Started;
    184         stopButton.Enabled = (Content.ExecutionState == ExecutionState.Started) || (Content.ExecutionState == ExecutionState.Paused);
    185         resetButton.Enabled = Content.ExecutionState != ExecutionState.Started;
    186       }
    187     }
    188     #endregion
    18968  }
    19069}
Note: See TracChangeset for help on using the changeset viewer.