Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10498


Ignore:
Timestamp:
02/21/14 14:14:47 (11 years ago)
Author:
gkronber
Message:

#2104 show the warning when closing the optimizer only when a view for IStorableContent is still open.

Location:
trunk/sources/HeuristicLab.Optimizer/3.3
Files:
3 edited

Legend:

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

    r9456 r10498  
    8686    protected override void OnClosing(CancelEventArgs e) {
    8787      base.OnClosing(e);
    88       if (MainFormManager.MainForm.Views.OfType<IContentView>().FirstOrDefault() != null) {
     88      if (MainFormManager.MainForm.Views.OfType<IContentView>().Any(v=>v.Content is IStorableContent)) {
    8989        if (MessageBox.Show(this, "Some views are still opened. If their content has not been saved, it will be lost after closing. Do you really want to close HeuristicLab Optimizer?", "Close Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
    9090          e.Cancel = true;
     
    110110      else {
    111111        IContentView activeView = ActiveView as IContentView;
    112         if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IStorableContent)) {
     112        if ((activeView != null) && (activeView.Content is IStorableContent)) {
    113113          IStorableContent content = (IStorableContent)activeView.Content;
    114114          Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]";
  • trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerMultipleDocumentMainForm.cs

    r9456 r10498  
    8686    protected override void OnClosing(CancelEventArgs e) {
    8787      base.OnClosing(e);
    88       if (MainFormManager.MainForm.Views.OfType<IContentView>().FirstOrDefault() != null) {
     88      if (MainFormManager.MainForm.Views.OfType<IContentView>().Any(v => v.Content is IStorableContent)) {
    8989        if (MessageBox.Show(this, "Some views are still opened. If their content has not been saved, it will be lost after closing. Do you really want to close HeuristicLab Optimizer?", "Close Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
    9090          e.Cancel = true;
     
    110110      else {
    111111        IContentView activeView = ActiveView as IContentView;
    112         if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IStorableContent)) {
     112        if ((activeView != null) && (activeView.Content is IStorableContent)) {
    113113          IStorableContent content = (IStorableContent)activeView.Content;
    114114          Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]";
  • trunk/sources/HeuristicLab.Optimizer/3.3/OptimizerSingleDocumentMainForm.cs

    r9456 r10498  
    8686    protected override void OnClosing(CancelEventArgs e) {
    8787      base.OnClosing(e);
    88       if (MainFormManager.MainForm.Views.OfType<IContentView>().FirstOrDefault() != null) {
     88      if (MainFormManager.MainForm.Views.OfType<IContentView>().Any(v => v.Content is IStorableContent)) {
    8989        if (MessageBox.Show(this, "Some views are still opened. If their content has not been saved, it will be lost after closing. Do you really want to close HeuristicLab Optimizer?", "Close Optimizer", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
    9090          e.Cancel = true;
     
    110110      else {
    111111        IContentView activeView = ActiveView as IContentView;
    112         if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IStorableContent)) {
     112        if ((activeView != null) && (activeView.Content is IStorableContent)) {
    113113          IStorableContent content = (IStorableContent)activeView.Content;
    114114          Title = title + " [" + (string.IsNullOrEmpty(content.Filename) ? "Unsaved" : content.Filename) + "]";
Note: See TracChangeset for help on using the changeset viewer.