diff FrmMain.cs @ 63:4db2c1086a85

Re #173: Add WinForms UI for showing debugging messages * Add starts of an implementation by subscribing to event and logging out for now (matches GTK# version in r273) * Add file logger
author IBBoard <dev@ibboard.co.uk>
date Mon, 21 Sep 2009 19:31:24 +0000
parents 0e7c257ca8d6
children c4181adba7df
line wrap: on
line diff
--- a/FrmMain.cs	Sat Sep 19 19:44:45 2009 +0000
+++ b/FrmMain.cs	Mon Sep 21 19:31:24 2009 +0000
@@ -91,6 +91,24 @@
 		private MenuItem miExportArmyAsBasicHTML;
 		private System.Windows.Forms.Panel pnlRight;
 
+		/// <summary>
+		/// The main entry point for the application.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{
+			try
+			{
+				Application.EnableVisualStyles();
+				Application.Run(new FrmMain(args));
+			}
+			catch (Exception ex)
+			{
+				LogManager.GetLogger(typeof(FrmMain)).Fatal(ex);
+				MessageBox.Show(null, "A major, unexpected and fatal error ocurred while starting the application: \r\n\r\n" + ex.Message + "\r\n\r\n" + ex.StackTrace, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+			}
+		}
+
 		public FrmMain(string[] args)
 		{
 			this.Closing+=new CancelEventHandler(FrmMain_Closing);
@@ -150,6 +168,7 @@
             // hack to load default files
             WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir));
             WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
+			WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
 			WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
 		}
 
@@ -522,21 +541,11 @@
 		}
 		#endregion
 
-		/// <summary>
-		/// The main entry point for the application.
-		/// </summary>
-		[STAThread]
-		static void Main(string[] args) 
+		private void FileLoadingFinished(List<FileLoadFailure> failures)
 		{
-			try
+			foreach (FileLoadFailure failure in failures)
 			{
-				Application.EnableVisualStyles();
-				Application.Run(new FrmMain(args));
-			}
-			catch(Exception ex)
-			{
-				   LogManager.GetLogger(typeof(FrmMain)).Fatal(ex);
-				MessageBox.Show(null, "A major, unexpected and fatal error ocurred while starting the application: \r\n\r\n"+ex.Message+"\r\n\r\n"+ex.StackTrace, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+				logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
 			}
 		}