Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/03/13 15:55:36 (11 years ago)
Author:
ascheibe
Message:

#1042 merged r9849, r9851, r9865, r9867, r9868, r9893, r9894, r9895, r9896, r9900, r9901, r9905, r9907 into stable branch

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimizer/3.3/FileManager.cs

    r9456 r9933  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
     24using System.IO;
    2525using System.Windows.Forms;
    2626using HeuristicLab.Common;
     
    9898          SaveAs(view);
    9999        else {
    100           ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    101           SetEnabledStateOfContentViews(content, false);
     100          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
     101          SetSaveOperationProgressInContentViews(content, true);
    102102          ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
    103103        }
     
    123123
    124124        if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    125           ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    126           SetEnabledStateOfContentViews(content, false);
     125          MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor();
     126          SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName);
    127127          if (saveFileDialog.FilterIndex == 1) {
    128128            ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
     
    135135    private static void SavingCompleted(IStorableContent content, Exception error) {
    136136      try {
    137         SetEnabledStateOfContentViews(content, true);
    138137        if (error != null) throw error;
    139138        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle();
     
    143142      }
    144143      finally {
    145         ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor();
     144        SetSaveOperationProgressInContentViews(content, false);
     145        MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor();
    146146      }
    147147    }
    148148
    149     private static void SetEnabledStateOfContentViews(IStorableContent content, bool enabled) {
     149    private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) {
    150150      HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>();
    151151      #region Mono Compatibility
    152152      // removed the InvokeRequired check because of Mono
    153153      mainForm.Invoke((Action)delegate {
    154         var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    155         views.ForEach(v => v.Enabled = enabled);
     154        if (showProgress) {
     155          mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename)));
     156        } else
     157          mainForm.RemoveOperationProgressFromContent(content);
    156158      });
    157159      #endregion
Note: See TracChangeset for help on using the changeset viewer.