diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Configuration/Commands.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Configuration/Commands.xml
index 18dbb7ee..36e3f177 100644
--- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Configuration/Commands.xml
+++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Configuration/Commands.xml
@@ -12,6 +12,7 @@
+
@@ -79,6 +80,7 @@
+
diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/English.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/English.xml
index 04595d93..2bcf0b5e 100644
--- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/English.xml
+++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/English.xml
@@ -72,7 +72,8 @@
-
+
+
diff --git a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/Japanese.xml b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/Japanese.xml
index 11dfbbce..0a7d7612 100644
--- a/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/Japanese.xml
+++ b/CSharp/Content/UniversalEditor.Content.PlatformIndependent/Languages/Japanese.xml
@@ -30,7 +30,8 @@
-
+
+
diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
index 7aa8f0bc..2fb5a1e8 100644
--- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
+++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/WindowsFormsEngine.cs
@@ -388,15 +388,20 @@ namespace UniversalEditor.UserInterface.WindowsForms
return mw;
}
- public override void ExitApplication()
+ protected override void RestartApplicationInternal()
{
- if (LocalConfiguration.ConfirmExit)
+ Application.Restart();
+ }
+ protected override bool BeforeStopApplication()
+ {
+ if (ConfigurationManager.GetValue(new string[] { "Application", "ConfirmExit" }, false))
{
- if (MessageBox.Show("Are you sure you wish to quit " + LocalConfiguration.ApplicationName + "?", "Quit Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
- {
- return;
- }
+ if (MessageBox.Show("Are you sure you wish to quit " + LocalConfiguration.ApplicationName + "?", "Quit Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) return false;
}
+ return base.BeforeStopApplication();
+ }
+ protected override void StopApplicationInternal()
+ {
Application.Exit();
}
}
diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
index 738972f5..0bc1b97f 100644
--- a/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
+++ b/CSharp/Libraries/UniversalEditor.UserInterface/Engine.cs
@@ -124,9 +124,13 @@ namespace UniversalEditor.UserInterface
{
LastWindow.CloseFile();
});
+ AttachCommandEventHandler("FileRestart", delegate(object sender, EventArgs e)
+ {
+ RestartApplication();
+ });
AttachCommandEventHandler("FileExit", delegate(object sender, EventArgs e)
{
- ExitApplication();
+ StopApplication();
});
#endregion
#region Edit
@@ -251,10 +255,6 @@ namespace UniversalEditor.UserInterface
#endregion
}
- public virtual void ExitApplication()
- {
- }
-
private IHostApplicationWindowCollection mvarWindows = new IHostApplicationWindowCollection();
public IHostApplicationWindowCollection Windows { get { return mvarWindows; } }
@@ -897,51 +897,79 @@ namespace UniversalEditor.UserInterface
HideSplashScreen();
}
+ private bool mvarRunning = false;
+ public bool Running { get { return mvarRunning; } }
+
public void StartApplication()
{
Engine.mvarCurrentEngine = this;
+ mvarRunning = true;
- string INSTANCEID = GetType().FullName + "$2d429aa3371c421fb63b42525e51a50c$92751853175891031214292357218181357901238$";
- if (ConfigurationManager.GetValue("SingleInstanceUniquePerDirectory", true))
+ while (mvarRunning)
{
- // The single instance should be unique per directory
- INSTANCEID += System.Reflection.Assembly.GetEntryAssembly().Location;
+ string INSTANCEID = GetType().FullName + "$2d429aa3371c421fb63b42525e51a50c$92751853175891031214292357218181357901238$";
+ if (ConfigurationManager.GetValue("SingleInstanceUniquePerDirectory", true))
+ {
+ // The single instance should be unique per directory
+ INSTANCEID += System.Reflection.Assembly.GetEntryAssembly().Location;
+ }
+ if (!SingleInstanceManager.CreateSingleInstance(INSTANCEID, new EventHandler(SingleInstanceManager_Callback))) return;
+
+ string[] args1 = Environment.GetCommandLineArgs();
+ string[] args = new string[args1.Length - 1];
+ Array.Copy(args1, 1, args, 0, args.Length);
+
+ System.Collections.ObjectModel.Collection selectedFileNames = new System.Collections.ObjectModel.Collection();
+ foreach (string commandLineArgument in args)
+ {
+ selectedFileNames.Add(commandLineArgument);
+ }
+ mvarSelectedFileNames = new System.Collections.ObjectModel.ReadOnlyCollection(selectedFileNames);
+
+ // Set up the base path for the current application. Should this be able to be
+ // overridden with a switch (/basepath:...) ?
+ mvarBasePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
+
+ BeforeInitialization();
+
+ // Initialize the branding for the selected application
+ InitializeBranding();
+
+ Initialize();
+
+ AfterInitializationInternal();
+ AfterInitialization();
+
+ OpenWindow(SelectedFileNames.ToArray());
+
+ MainLoop();
+
+ SessionManager.Save();
+ BookmarksManager.Save();
+ RecentFileManager.Save();
+ ConfigurationManager.Save();
}
- if (!SingleInstanceManager.CreateSingleInstance(INSTANCEID, new EventHandler(SingleInstanceManager_Callback))) return;
-
- string[] args1 = Environment.GetCommandLineArgs();
- string[] args = new string[args1.Length - 1];
- Array.Copy(args1, 1, args, 0, args.Length);
-
- System.Collections.ObjectModel.Collection selectedFileNames = new System.Collections.ObjectModel.Collection();
- foreach (string commandLineArgument in args)
- {
- selectedFileNames.Add(commandLineArgument);
- }
- mvarSelectedFileNames = new System.Collections.ObjectModel.ReadOnlyCollection(selectedFileNames);
-
- // Set up the base path for the current application. Should this be able to be
- // overridden with a switch (/basepath:...) ?
- mvarBasePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
-
- BeforeInitialization();
-
- // Initialize the branding for the selected application
- InitializeBranding();
-
- Initialize();
-
- AfterInitializationInternal();
- AfterInitialization();
-
- OpenWindow(SelectedFileNames.ToArray());
-
- MainLoop();
-
- SessionManager.Save();
- BookmarksManager.Save();
- RecentFileManager.Save();
- ConfigurationManager.Save();
+ }
+ public void RestartApplication()
+ {
+ RestartApplicationInternal();
+ }
+ public void StopApplication()
+ {
+ if (!BeforeStopApplication()) return;
+ StopApplicationInternal();
+ }
+ protected virtual void RestartApplicationInternal()
+ {
+ StopApplication();
+ StartApplication();
+ }
+ protected virtual bool BeforeStopApplication()
+ {
+ return true;
+ }
+ protected virtual void StopApplicationInternal()
+ {
}
}
}