|
|
|
@ -242,7 +242,7 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -242,7 +242,7 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
|
|
|
|
|
static void BeforeLoadSolution() |
|
|
|
|
{ |
|
|
|
|
if (openSolution != null) { |
|
|
|
|
if (openSolution != null && !IsClosingCanceled()) { |
|
|
|
|
SaveSolutionPreferences(); |
|
|
|
|
WorkbenchSingleton.Workbench.CloseAllViews(); |
|
|
|
|
CloseSolution(); |
|
|
|
@ -258,6 +258,10 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -258,6 +258,10 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
{ |
|
|
|
|
if (!Path.IsPathRooted(fileName)) |
|
|
|
|
throw new ArgumentException("Path must be rooted!"); |
|
|
|
|
|
|
|
|
|
if (IsClosingCanceled()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
BeforeLoadSolution(); |
|
|
|
|
OnSolutionLoading(fileName); |
|
|
|
|
try { |
|
|
|
@ -500,7 +504,28 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -500,7 +504,28 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void CloseSolution() |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Executes the OnBeforeSolutionClosing event.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>This method must be used after CloseSolution is called.</remarks>
|
|
|
|
|
/// <returns><c>true</c>, if closing solution was canceled; <c>false</c>, otherwise.</returns>
|
|
|
|
|
internal static bool IsClosingCanceled() |
|
|
|
|
{ |
|
|
|
|
// run onbefore closing
|
|
|
|
|
var beforeClosingArgs = new SolutionCancelEventArgs(openSolution); |
|
|
|
|
OnBeforeSolutionClosing(beforeClosingArgs); |
|
|
|
|
|
|
|
|
|
return beforeClosingArgs.Cancel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Closes the solution: cancels build, clears solution data, fires the SolutionClosing and SolutionClosed events.
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Before invoking this method, one should check if the closing was canceled (<see cref="IsClosingCanceled"/>),
|
|
|
|
|
/// save solution and project data (e.g. files, bookmarks), then invoke CloseSolution().
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal static void CloseSolution() |
|
|
|
|
{ |
|
|
|
|
// If a build is running, cancel it.
|
|
|
|
|
// If we would let a build run but unload the MSBuild projects, the next project.StartBuild call
|
|
|
|
@ -541,6 +566,13 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -541,6 +566,13 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void OnBeforeSolutionClosing(SolutionCancelEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (BeforeSolutionClosing != null) { |
|
|
|
|
BeforeSolutionClosing(null, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void OnSolutionLoading(string fileName) |
|
|
|
|
{ |
|
|
|
|
if (SolutionLoading != null) { |
|
|
|
@ -714,6 +746,15 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -714,6 +746,15 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
public static event EventHandler<SolutionEventArgs> SolutionClosing; |
|
|
|
|
public static event EventHandler SolutionClosed; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raised before SolutionClosing.
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// When one modifies the e.Cancel property, should have in mind that other consumers might want to cancel the closing.<br/>
|
|
|
|
|
/// Setting e.Cancel = false might override other consumers (if they exist) e.Cancel = true, and might break other functionalities.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler<SolutionCancelEventArgs> BeforeSolutionClosing; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Raised before the solution preferences are being saved. Allows you to save
|
|
|
|
|
/// your additional properties in the solution preferences.
|
|
|
|
|