Index: Application/Application.Ringtoets/App.xaml.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -rbd7193e87115fb658d306e07483c99dad0e59c14 --- Application/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Application/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision bd7193e87115fb658d306e07483c99dad0e59c14) @@ -21,7 +21,6 @@ using Core.Plugins.SharpMapGis; using Core.Plugins.SharpMapGis.Gui; using log4net; -using NDesk.Options; using Ringtoets.Integration.Plugin; using Ringtoets.Piping.Plugin; @@ -44,7 +43,9 @@ private static RingtoetsGui gui; - private static int waitForProcessId = -1; // start Ringtoets after this process will exit (used during restart) + // Start application after this process will exit (used during restart) + private const string aurgumentWaitForProcess = "--wait-for-process="; + private static int waitForProcessId = -1; private static string projectFilePath; @@ -154,14 +155,16 @@ private void App_Startup(object sender, StartupEventArgs e) { + ParseArguments(e.Args); + WaitForPreviousInstanceToExit(); if (ShutdownIfNotFirstInstance()) { return; } Resources.Add(SystemParameters.MenuPopupAnimationKey, PopupAnimation.None); - ParseArguments(e.Args); + gui = new RingtoetsGui { @@ -225,9 +228,13 @@ return false; } + /// + /// If variable waitForProcessId > -1, the application will hold until + /// the process with that ID has exited. + /// private static void WaitForPreviousInstanceToExit() { - // wait until previous version of Ringtoets has exited + // Wait until previous version of Ringtoets has exited if (waitForProcessId == -1) { return; @@ -357,34 +364,32 @@ private static void Restart() { - Process.Start(typeof(App).Assembly.Location, "--wait-for-process=" + Process.GetCurrentProcess().Id); + Process.Start(typeof(App).Assembly.Location, aurgumentWaitForProcess + Process.GetCurrentProcess().Id); Environment.Exit(1); } + /// + /// Parses the process' start-up parameters + /// + /// private static void ParseArguments(IEnumerable arguments) { - var p = new OptionSet + + var waitForProcess = arguments.FirstOrDefault(args => args.IndexOf(aurgumentWaitForProcess, StringComparison.InvariantCultureIgnoreCase) == 0); + if ( ! string.IsNullOrEmpty(waitForProcess)) { + // Get process by id + try { - "<>", delegate(string projectPath) + var pid = int.Parse(waitForProcess.Remove(0, aurgumentWaitForProcess.Length)); + if (pid > 0) { - if (Path.GetExtension(projectPath) == ".dsproj") - { - projectFilePath = projectPath; - } + waitForProcessId = pid; } - }, - { - "r|run-activity=", Core.Common.Gui.Properties.Resources.App_ParseArguments_Run_activity_or_model_available_in_the_project_, v => runActivity = v - }, - { - "p|project=", delegate(string projectPath) { projectFilePath = projectPath; } - }, - { - "w|wait-for-process=", delegate(string pid) { waitForProcessId = int.Parse(pid); } } - }; - p.Parse(arguments); + catch {} + } + } } } \ No newline at end of file Index: Application/Application.Ringtoets/Application.Ringtoets.csproj =================================================================== diff -u -r81e0e43107de0fa0b4291778ec2365a3e9c15eb9 -rbd7193e87115fb658d306e07483c99dad0e59c14 --- Application/Application.Ringtoets/Application.Ringtoets.csproj (.../Application.Ringtoets.csproj) (revision 81e0e43107de0fa0b4291778ec2365a3e9c15eb9) +++ Application/Application.Ringtoets/Application.Ringtoets.csproj (.../Application.Ringtoets.csproj) (revision bd7193e87115fb658d306e07483c99dad0e59c14) @@ -83,10 +83,6 @@ ..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll True - - ..\..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll - True - Index: Application/Application.Ringtoets/packages.config =================================================================== diff -u -r81e0e43107de0fa0b4291778ec2365a3e9c15eb9 -rbd7193e87115fb658d306e07483c99dad0e59c14 --- Application/Application.Ringtoets/packages.config (.../packages.config) (revision 81e0e43107de0fa0b4291778ec2365a3e9c15eb9) +++ Application/Application.Ringtoets/packages.config (.../packages.config) (revision bd7193e87115fb658d306e07483c99dad0e59c14) @@ -2,5 +2,4 @@ - Index: Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -rbd7193e87115fb658d306e07483c99dad0e59c14 --- Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision bd7193e87115fb658d306e07483c99dad0e59c14) @@ -16,9 +16,7 @@ using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; -using System.Windows.Media; using System.Windows.Media.Imaging; -using Core.Common.Base; using Core.Common.Controls; using Core.Common.Controls.Swf; using Core.Common.Gui.Forms.MessageWindow; Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -rbd7193e87115fb658d306e07483c99dad0e59c14 --- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision bd7193e87115fb658d306e07483c99dad0e59c14) @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; -using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Windows.Forms; Index: packages/NDesk.Options.0.2.1/NDesk.Options.0.2.1.nupkg =================================================================== diff -u -r81e0e43107de0fa0b4291778ec2365a3e9c15eb9 -rbd7193e87115fb658d306e07483c99dad0e59c14 Binary files differ Index: packages/NDesk.Options.0.2.1/lib/NDesk.Options.dll =================================================================== diff -u -r81e0e43107de0fa0b4291778ec2365a3e9c15eb9 -rbd7193e87115fb658d306e07483c99dad0e59c14 Binary files differ