Index: src/Common/DelftTools.Shell.Gui/IGuiCommandHandler.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/Common/DelftTools.Shell.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Common/DelftTools.Shell.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -9,7 +9,13 @@
///
public interface IGuiCommandHandler : IDisposable
{
- void CreateNewProject();
+ ///
+ /// Tries to create a new WTI project.
+ ///
+ ///
+ /// The creation action might be cancelled (due to user interaction).
+ ///
+ void TryCreateNewWTIProject();
///
/// Tries to open an existing WTI project.
@@ -30,6 +36,13 @@
/// Whether or not an existing WTI project was correctly opened.
bool TryOpenExistingWTIProject(string filePath);
+ ///
+ /// Tries to close a WTI project.
+ ///
+ ///
+ /// The closing action might be cancelled (due to user interaction).
+ ///
+ /// Whether or not the WTI project was correctly closed.
bool TryCloseWTIProject();
bool SaveProject();
Index: src/DeltaShell/DeltaShell.Gui/Forms/MainWindow/MainWindow.xaml.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/DeltaShell/DeltaShell.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/DeltaShell/DeltaShell.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -639,7 +639,7 @@
private void OnFileNewClicked(object sender, RoutedEventArgs e)
{
- Gui.CommandHandler.CreateNewProject();
+ Gui.CommandHandler.TryCreateNewWTIProject();
ValidateItems();
}
Index: src/DeltaShell/DeltaShell.Gui/GuiCommandHandler.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/DeltaShell/DeltaShell.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/DeltaShell/DeltaShell.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -5,7 +5,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using System.Windows.Input;
@@ -16,7 +15,6 @@
using DelftTools.Utils;
using DelftTools.Utils.Aop;
using DelftTools.Utils.Collections;
-using DeltaShell.Core;
using DeltaShell.Gui.Forms;
using DeltaShell.Gui.Forms.MainWindow;
using DeltaShell.Gui.Forms.ViewManager;
@@ -46,6 +44,21 @@
guiExportHandler = CreateGuiExportHandler();
}
+ public void TryCreateNewWTIProject()
+ {
+ if (!TryCloseWTIProject())
+ {
+ Log.Warn(Resources.Opening_new_wti_project_cancelled);
+ return;
+ }
+
+ Log.Info(Resources.Opening_new_wti_project);
+ gui.Application.CreateNewProject();
+ Log.Info(Resources.New_wti_project_successfully_opened);
+
+ RefreshGui();
+ }
+
public bool TryOpenExistingWTIProject()
{
var openFileDialog = new OpenFileDialog
@@ -78,71 +91,16 @@
ProgressBarDialog.PerformTask(Resources.Loading_wti_project_from_selected_file, () => result = gui.Application.OpenProject(filePath));
- RefreshMainWindowTitle();
+ RefreshGui();
return result;
}
- public IProjectItem GetProjectItemForActiveView()
- {
- var activeView = gui.DocumentViews.ActiveView;
- if (activeView == null || activeView.Data == null)
- {
- return null;
- }
-
- var projectItemActiveView = activeView.Data as IProjectItem;
- if (projectItemActiveView != null)
- {
- return projectItemActiveView;
- }
-
- return null;
- }
-
- ///
- /// Create new project in the temporary path.
- ///
- ///
- public void CreateNewProject()
- {
- while (DeltaShellApplication.TemporaryProjectBeingSaved) // called second time, wait ...
- {
- Application.DoEvents();
- Thread.Sleep(250);
- }
-
- if (gui.Application.Project != null)
- {
- if (!TryCloseWTIProject())
- {
- return;
- }
- }
-
- gui.Application.CreateNewProject();
-
- if (DeltaShellApplication.TemporaryProjectSavedAsynchroneously)
- {
- while (!DeltaShellApplication.TemporaryProjectSaved)
- {
- Application.DoEvents();
- Thread.Sleep(250);
- }
- }
-
- gui.Selection = gui.Application.Project;
-
- RefreshMainWindowTitle();
- }
-
public bool TryCloseWTIProject()
{
- gui.Selection = null;
-
if (gui.Application.Project != null)
{
- Log.Info(Resources.GuiCommandHandler_CloseProject_Closing_current_project____);
+ Log.Info("Closing current WTI project.");
// Ask to save any changes first
if (gui.Application.Project.IsChanged)
@@ -158,11 +116,12 @@
if (alwaysOkResult != DialogResult.OK)
{
if (!SaveProject())
- return false;
- AddProjectToMruListIfNotYetAdded();
+ {
+
+ }
}
}
-
+
if (result == DialogResult.Cancel)
{
return false;
@@ -182,13 +141,31 @@
gui.Application.CloseProject();
- RefreshMainWindowTitle();
+ RefreshGui();
Log.Info(Resources.GuiCommandHandler_CloseProject_Project_closed);
}
+
return true;
}
+ public IProjectItem GetProjectItemForActiveView()
+ {
+ var activeView = gui.DocumentViews.ActiveView;
+ if (activeView == null || activeView.Data == null)
+ {
+ return null;
+ }
+
+ var projectItemActiveView = activeView.Data as IProjectItem;
+ if (projectItemActiveView != null)
+ {
+ return projectItemActiveView;
+ }
+
+ return null;
+ }
+
public bool SaveProject()
{
var project = gui.Application.Project;
@@ -204,8 +181,11 @@
UnselectActiveControlToForceBinding();
SaveProjectWithProgressDialog(path);
- RefreshMainWindowTitle();
+ AddProjectToMruList();
+
+ RefreshGui();
+
return true;
}
@@ -251,8 +231,10 @@
return false;
}
- RefreshMainWindowTitle();
+ AddProjectToMruList();
+ RefreshGui();
+
return true;
}
@@ -516,13 +498,15 @@
}
}
- private void AddProjectToMruListIfNotYetAdded()
+ private void AddProjectToMruList()
{
- if (gui.Application.Project.IsTemporary) //first save, so not yet added to mru list before
+ var mruList = (StringCollection) Settings.Default["mruList"];
+ if (mruList.Contains(gui.Application.ProjectFilePath))
{
- var mruList = (StringCollection) Settings.Default["mruList"];
- mruList.Add(gui.Application.ProjectFilePath);
+ mruList.Remove(gui.Application.ProjectFilePath);
}
+
+ mruList.Insert(0, gui.Application.ProjectFilePath);
}
private static void UnselectActiveControlToForceBinding()
@@ -609,7 +593,7 @@
return;
}
- RefreshMainWindowTitle();
+ RefreshGui();
}
[InvokeRequired]
@@ -623,14 +607,17 @@
}
[InvokeRequired]
- private void RefreshMainWindowTitle()
+ private void RefreshGui()
{
- string mainWindowTitle = gui.Application.Settings != null
- ? gui.Application.Settings["mainWindowTitle"]
- : "DeltaShell";
-
var project = gui.Application.Project;
+ // Set the gui selection to the current project
+ gui.Selection = gui.Application.Project;
+
+ var mainWindowTitle = gui.Application.Settings != null
+ ? gui.Application.Settings["mainWindowTitle"]
+ : "DeltaShell";
+
if (project == null)
{
gui.MainWindow.Title = string.Format(Resources.GuiCommandHandler_UpdateGui__no_project_opened_____0_, mainWindowTitle);
Index: src/DeltaShell/DeltaShell.Gui/Properties/Resources.Designer.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/DeltaShell/DeltaShell.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/DeltaShell/DeltaShell.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -1306,15 +1306,6 @@
}
///
- /// Looks up a localized string similar to Closing current project ....
- ///
- public static string GuiCommandHandler_CloseProject_Closing_current_project____ {
- get {
- return ResourceManager.GetString("GuiCommandHandler_CloseProject_Closing_current_project____", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Closing project ....
///
public static string GuiCommandHandler_CloseProject_Closing_project____ {
@@ -2190,6 +2181,15 @@
}
///
+ /// Looks up a localized string similar to New WTI project successfully opened..
+ ///
+ public static string New_wti_project_successfully_opened {
+ get {
+ return ResourceManager.GetString("New_wti_project_successfully_opened", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap newspaper {
@@ -2238,6 +2238,24 @@
}
///
+ /// Looks up a localized string similar to Opening new WTI project..
+ ///
+ public static string Opening_new_wti_project {
+ get {
+ return ResourceManager.GetString("Opening_new_wti_project", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Opening new WTI project cancelled..
+ ///
+ public static string Opening_new_wti_project_cancelled {
+ get {
+ return ResourceManager.GetString("Opening_new_wti_project_cancelled", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap OptionsHS {
Index: src/DeltaShell/DeltaShell.Gui/Properties/Resources.nl-NL.resx
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/DeltaShell/DeltaShell.Gui/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/DeltaShell/DeltaShell.Gui/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -369,9 +369,6 @@
NL There needs to be a project to add an item
-
- NL Closing current project ...
-
NL Closing project ...
@@ -908,4 +905,13 @@
Inladen WTI project uit geselecteerd bestand.
+
+ Openen nieuw WTI project geannuleerd.
+
+
+ Openen nieuw WTI project.
+
+
+ Nieuw WTI project succesvol geopend.
+
\ No newline at end of file
Index: src/DeltaShell/DeltaShell.Gui/Properties/Resources.resx
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/DeltaShell/DeltaShell.Gui/Properties/Resources.resx (.../Resources.resx) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/DeltaShell/DeltaShell.Gui/Properties/Resources.resx (.../Resources.resx) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -871,9 +871,6 @@
{0} gui plugin(s) were loaded
-
- Closing current project ...
-
Save changes to the project: {0}
@@ -1215,4 +1212,13 @@
Loading WTI project from selected file.
+
+ Opening new WTI project cancelled.
+
+
+ Opening new WTI project.
+
+
+ New WTI project successfully opened.
+
\ No newline at end of file
Index: src/Plugins/PluginDemo/DeltaShell.Plugins.DemoGuiPlugin/Ribbon.xaml
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- src/Plugins/PluginDemo/DeltaShell.Plugins.DemoGuiPlugin/Ribbon.xaml (.../Ribbon.xaml) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ src/Plugins/PluginDemo/DeltaShell.Plugins.DemoGuiPlugin/Ribbon.xaml (.../Ribbon.xaml) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -11,7 +11,7 @@
-
+
Index: test/DeltaShell/DeltaShell.IntegrationTests/DeltaShell/DeltaShell.Gui/DeltaShellGuiIntegrationTest.cs
===================================================================
diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -rdd8fa121d83cc3dd233c4a44d27d9683180f844b
--- test/DeltaShell/DeltaShell.IntegrationTests/DeltaShell/DeltaShell.Gui/DeltaShellGuiIntegrationTest.cs (.../DeltaShellGuiIntegrationTest.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9)
+++ test/DeltaShell/DeltaShell.IntegrationTests/DeltaShell/DeltaShell.Gui/DeltaShellGuiIntegrationTest.cs (.../DeltaShellGuiIntegrationTest.cs) (revision dd8fa121d83cc3dd233c4a44d27d9683180f844b)
@@ -63,8 +63,8 @@
Action onShown = delegate
{
- gui.CommandHandler.CreateNewProject();
- gui.CommandHandler.CreateNewProject();
+ gui.CommandHandler.TryCreateNewWTIProject();
+ gui.CommandHandler.TryCreateNewWTIProject();
};
WpfTestHelper.ShowModal((Control) gui.MainWindow, onShown);
@@ -246,7 +246,7 @@
{
app.Project.IsTemporary.Should("Project is temporary at the beginning").Be.True();
- gui.CommandHandler.CreateNewProject();
+ gui.CommandHandler.TryCreateNewWTIProject();
app.Project.IsTemporary.Should("Project is temporary after create new").Be.True();
});