Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2555


Ignore:
Timestamp:
12/14/09 00:23:57 (15 years ago)
Author:
swagner
Message:

Continued work on Optimizer (#770)

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/IItemView.cs

    r2547 r2555  
    4040    /// </summary>
    4141    event EventHandler ItemChanged;
    42 
    43     event EventHandler Closed;
    4442  }
    4543}
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemViewBase.cs

    r2547 r2555  
    112112    }
    113113
    114     public event EventHandler Closed;
    115     public override void OnClosed(object sender, EventArgs e) {
    116       base.OnClosed(sender, e);
    117       if (Closed != null)
    118         Closed(this, e);
    119     }
    120 
    121114    /// <summary>
    122115    /// Asynchron call of GUI updating.
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r2547 r2555  
    4646      waitingCursors = 0;
    4747      newDocumentsCounter = 1;
     48      // NOTE: Events fired by the main form are registered in HeuristicLabOptimizerApplication.
    4849    }
    4950
     
    5152      if (newItemDialog == null) newItemDialog = new NewItemDialog();
    5253      if (newItemDialog.ShowDialog() == DialogResult.OK) {
    53         IItemView view = MainFormManager.CreateDefaultView(newItemDialog.Item) as IItemView;
    54         if (view != null) {
    55           view.Closed += new EventHandler(ViewClosed);
     54        IView view = MainFormManager.CreateDefaultView(newItemDialog.Item);
     55        if (view is IItemView) {
    5656          view.Caption = "Item" + newDocumentsCounter.ToString() + ".hl";
    5757          newDocumentsCounter++;
    58           MainFormManager.MainForm.ShowView(view);
    5958        }
     59        MainFormManager.MainForm.ShowView(view);
    6060      }
    6161    }
     
    140140    }
    141141
    142     private static void ViewClosed(object sender, EventArgs e) {
    143       IItemView view = (IItemView)sender;
    144       view.Closed -= new EventHandler(ViewClosed);
     142    // NOTE: This event is fired by the main form. It is registered in HeuristicLabOptimizerApplication.
     143    internal static void ViewClosed(object sender, ViewEventArgs e) {
     144      IItemView view = e.View as IItemView;
    145145      files.Remove(view);
    146146    }
     
    187187                IItemView view = MainFormManager.CreateDefaultView(item) as IItemView;
    188188                if (view != null) {
    189                   view.Closed += new EventHandler(ViewClosed);
    190189                  view.Caption = Path.GetFileName(filename);
    191190                  files.Add(view, new FileInfo(filename));
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLabOptimizerApplication.cs

    r2547 r2555  
    2727using HeuristicLab.PluginInfrastructure;
    2828using HeuristicLab.Common.Resources;
     29using HeuristicLab.MainForm;
    2930using HeuristicLab.MainForm.WindowsForms;
    3031
     
    3435    public override void Run() {
    3536      OptimizerMainForm mainForm = new OptimizerMainForm(typeof(IOptimizerUserInterfaceItemProvider));
     37      mainForm.ViewClosed += new EventHandler<ViewEventArgs>(FileManager.ViewClosed);
    3638      Application.Run(mainForm);
    3739    }
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/SaveAllMenuItem.cs

    r2546 r2555  
    88using HeuristicLab.MainForm.WindowsForms;
    99using HeuristicLab.Common.Resources;
     10using HeuristicLab.Core;
     11using HeuristicLab.Core.Views;
    1012
    1113namespace HeuristicLab.Optimizer.MenuItems {
     
    3133    }
    3234    public override void ActiveViewChanged(object sender, EventArgs e) {
    33       ToolStripItem.Enabled = MainFormManager.MainForm.Views.FirstOrDefault() != null;
     35      var views = from v in MainFormManager.MainForm.Views
     36                  where v is IItemView
     37                  where CreatableAttribute.IsCreatable(((IItemView)v).Item.GetType())
     38                  select v;
     39      ToolStripItem.Enabled = views.FirstOrDefault() != null;
    3440    }
    3541
  • trunk/sources/HeuristicLab.Optimizer/3.3/ToolBarItems/SaveAllToolBarItem.cs

    r2546 r2555  
    88using HeuristicLab.MainForm.WindowsForms;
    99using HeuristicLab.Common.Resources;
     10using HeuristicLab.Core;
     11using HeuristicLab.Core.Views;
    1012
    1113namespace HeuristicLab.Optimizer {
     
    2830    }
    2931    public override void ActiveViewChanged(object sender, EventArgs e) {
    30       ToolStripItem.Enabled = MainFormManager.MainForm.Views.FirstOrDefault() != null;
     32      var views = from v in MainFormManager.MainForm.Views
     33                  where v is IItemView
     34                  where CreatableAttribute.IsCreatable(((IItemView)v).Item.GetType())
     35                  select v;
     36      ToolStripItem.Enabled = views.FirstOrDefault() != null;
    3137    }
    3238
Note: See TracChangeset for help on using the changeset viewer.