Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Main/Base/Project/Src/Commands/FileMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class CloseSolution : AbstractMenuCommand
public override void Run()
{
ProjectService.SaveSolutionPreferences();
WorkbenchSingleton.Workbench.CloseAllViews();
if (WorkbenchSingleton.Workbench.WorkbenchWindowCollection.Count == 0) {
if (WorkbenchSingleton.Workbench.CloseAllSolutionViews()) {
ProjectService.CloseSolution();
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Main/Base/Project/Src/Gui/IWorkbench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ bool IsActiveWindow {
/// </summary>
void CloseAllViews();

/// <summary>
/// Closes all views related to current solution.
/// </summary>
/// <returns>
/// True if all views were closed properly, false if closing was aborted.
/// </returns>
bool CloseAllSolutionViews();

/// <summary>
/// Is called, when a workbench view was opened
/// </summary>
Expand Down
41 changes: 41 additions & 0 deletions src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Windows.Navigation;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Project;

namespace ICSharpCode.SharpDevelop.Gui
{
Expand Down Expand Up @@ -433,6 +434,46 @@ public void CloseAllViews()
}
}

public bool CloseAllSolutionViews()
{
bool isSolutionWindow;
bool result = true;

WorkbenchSingleton.AssertMainThread();
try
{
closeAll = true;
foreach (IWorkbenchWindow window in this.WorkbenchWindowCollection.ToArray())
{
isSolutionWindow = false;
foreach (IViewContent content in window.ViewContents)
{
foreach (OpenedFile file in content.Files)
{
if (ProjectService.OpenSolution.FindProjectContainingFile(file.FileName) != null)
{
isSolutionWindow = true;
break;
}
}

if (isSolutionWindow)
break;
}

if (isSolutionWindow)
result = window.CloseWindow(false) && result;
}
}
finally
{
closeAll = false;
OnActiveWindowChanged(this, EventArgs.Empty);
}

return result;
}

#region ViewContent Memento Handling
string viewContentMementosFileName;

Expand Down