Changeset 3576


Ignore:
Timestamp:
05/01/10 02:46:16 (12 years ago)
Author:
swagner
Message:

Fixed exception in CloseAllMenuItem and corrected default enabled state of CloseMenuItem and CloseAllMenuItem (#972)

Location:
trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CloseAllMenuItem.cs

    r3571 r3576  
    4040
    4141    protected override void OnToolStripItemSet(EventArgs e) {
    42       ToolStripItem.Enabled = false;
     42      ToolStripItem.Enabled = MainFormManager.MainForm.Views.Any<IView>(v => v.IsShown && !(v is Sidebar));
    4343    }
    4444    protected override void OnActiveViewChanged(object sender, EventArgs e) {
     
    4747
    4848    public override void Execute() {
    49       foreach (IView view in MainFormManager.MainForm.Views)
    50         if (!(view is Sidebar))
    51           view.Close();
     49      var views = MainFormManager.MainForm.Views.Where(x => !(x is Sidebar)).ToArray();
     50      foreach (IView view in views)
     51        view.Close();
    5252    }
    5353  }
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CloseMenuItem.cs

    r3571 r3576  
    3939
    4040    protected override void OnToolStripItemSet(EventArgs e) {
    41       ToolStripItem.Enabled = false;
     41      ToolStripItem.Enabled = !(MainFormManager.MainForm.ActiveView is Sidebar);
    4242    }
    4343    protected override void OnActiveViewChanged(object sender, EventArgs e) {
    44       IView view = MainFormManager.MainForm.ActiveView;
    45       ToolStripItem.Enabled = !(view is Sidebar);
     44      ToolStripItem.Enabled = !(MainFormManager.MainForm.ActiveView is Sidebar);
    4645    }
    4746
Note: See TracChangeset for help on using the changeset viewer.