Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/19/10 19:43:05 (14 years ago)
Author:
mkommend
Message:

Adjusted the SetEnabledStateOfControls method in all views, added the Enabled property into the IView interface and adapted the ViewHost, View and ContentView class (ticket #1155).

File:
1 edited

Legend:

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

    r4245 r4435  
    9393        else {
    9494          ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
    95           var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    96           views.ForEach(v => v.ReadOnly = true);
    97           views.ForEach(v => v.Locked = true);
     95          SetEnabledStateOfContentViews(content, false);
    9896          ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
    9997        }
     
    120118        if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    121119          ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
    122           var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    123           views.ForEach(v => v.ReadOnly = true);
    124           views.ForEach(v => v.Locked = true);
     120          SetEnabledStateOfContentViews(content, false);
    125121          if (saveFileDialog.FilterIndex == 1) {
    126122            ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
     
    133129    private static void SavingCompleted(IStorableContent content, Exception error) {
    134130      try {
    135         var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    136         views.ForEach(v => v.ReadOnly = false);
    137         views.ForEach(v => v.Locked = false);
     131        SetEnabledStateOfContentViews(content, true);
    138132        if (error != null) throw error;
    139133        MainFormManager.GetMainForm<OptimizerMainForm>().UpdateTitle();
     
    146140      }
    147141    }
     142
     143    private static void SetEnabledStateOfContentViews(IStorableContent content, bool enabled) {
     144      OptimizerMainForm mainForm = MainFormManager.GetMainForm<OptimizerMainForm>();
     145      if (mainForm.InvokeRequired)
     146        mainForm.Invoke((Action<IStorableContent, bool>)SetEnabledStateOfContentViews, content, enabled);
     147      else {
     148        var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
     149        views.ForEach(v => v.Enabled = enabled);
     150      }
     151    }
    148152  }
    149153}
Note: See TracChangeset for help on using the changeset viewer.