Index: Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r7e20649afed3f6e23febb57c28bfc32fa75fedc6 --- Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision 7e20649afed3f6e23febb57c28bfc32fa75fedc6) @@ -50,6 +50,7 @@ using MessageBox = System.Windows.MessageBox; #if INCLUDE_DEMOPROJECT using Demo.Ringtoets.GUIs; + #endif namespace Application.Ringtoets @@ -69,6 +70,7 @@ private static RingtoetsGui gui; private static int waitForProcessId = -1; + private static string fileToOpen = String.Empty; private static Mutex singleInstanceMutex; @@ -78,13 +80,14 @@ log.Info(Core.Common.Base.Properties.Resources.App_App_Ringtoets_Copyright); - log.Info(Core.Common.Gui.Properties.Resources.App_App_Starting_Ringtoets); + log.Info(Core.Common.Gui.Properties.Resources.App_Starting_Ringtoets); } - public static void RunRingtoets(string file) + /// + /// Runs the main Ringtoets application. + /// + public static void RunRingtoets() { - log.Info(Core.Common.Gui.Properties.Resources.App_RunRingtoets_Starting_Ringtoets_Gui); - var loaderDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (loaderDirectory != null) { @@ -102,7 +105,7 @@ // handle exception from all threads except UI AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException; - gui.Run(file); + gui.Run(fileToOpen); // Ringtoets started, clean-up all possible memory GC.Collect(); @@ -121,7 +124,6 @@ private void App_Startup(object sender, StartupEventArgs e) { ParseArguments(e.Args); - var file = GetFileArgument(e.Args); WaitForPreviousInstanceToExit(); if (ShutdownIfNotFirstInstance()) @@ -166,27 +168,24 @@ } }; - RunRingtoets(file); + RunRingtoets(); mainWindow.Show(); } - private string GetFileArgument(string[] args) + private static bool ParseFileArgument(string potentialPath) { - string potentialPath = null; - if(args.Length > 0) + if (potentialPath.Length > 0) { - potentialPath = args.Last(); try { FileUtils.ValidateFilePath(potentialPath); + fileToOpen = potentialPath; + return true; } - catch (ArgumentException) - { - potentialPath = null; - } + catch (ArgumentException) {} } - return potentialPath; + return false; } /// @@ -368,6 +367,11 @@ break; } } + + if (ParseFileArgument(arg)) + { + break; + } } }