comparison FrmMainWindow.cs @ 8:20c5fd0bb79d

Fixes #5 - Stop missing translations being fatal * Catch TranslationLoadExceptions thrown when initialising translations and display the message to the user Also: * Random GUI cleanup that MonoDevelop wanted to do * Add exception type name to last-ditch "log what killed us" exception handling so that we can more easily identify the exception thrown
author IBBoard <dev@ibboard.co.uk>
date Thu, 05 Mar 2009 20:37:25 +0000
parents cfc7683e73f9
children c687bbe901f8
comparison
equal deleted inserted replaced
7:58961ff391d4 8:20c5fd0bb79d
61 Application.Run(); 61 Application.Run();
62 LogManager.GetLogger(typeof(FrmMainWindow)).Debug("Application ended"); 62 LogManager.GetLogger(typeof(FrmMainWindow)).Debug("Application ended");
63 } 63 }
64 catch(Exception ex) 64 catch(Exception ex)
65 { 65 {
66 LogManager.GetLogger(typeof(FrmMainWindow)).Fatal(ex.Message + Environment.NewLine + ex.StackTrace); 66 LogManager.GetLogger(typeof(FrmMainWindow)).Fatal("("+ex.GetType().Name+") "+ex.Message + Environment.NewLine + ex.StackTrace);
67 } 67 }
68 } 68 }
69 69
70 public FrmMainWindow() : this(new string[0]) 70 public FrmMainWindow() : this(new string[0])
71 { 71 {
101 mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderCategoryTreeObjectName)); 101 mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderCategoryTreeObjectName));
102 treeUnits.Model = new TreeStore(typeof(WarFoundryObject)); 102 treeUnits.Model = new TreeStore(typeof(WarFoundryObject));
103 logger.Debug("Loading preferences"); 103 logger.Debug("Loading preferences");
104 Preferences = new Preferences("WarFoundryGTK"); 104 Preferences = new Preferences("WarFoundryGTK");
105 logger.Debug("Loading translations"); 105 logger.Debug("Loading translations");
106 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); 106
107 try
108 {
109 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString());
110 }
111 catch (TranslationLoadException ex)
112 {
113 logger.Error(ex);
114 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, ex.Message);
115 dialog.Title = "Translation loading failed";
116 dialog.Run();
117 dialog.Destroy();
118 }
119
107 logger.Debug("Initialising"); 120 logger.Debug("Initialising");
108 commandStack = new CommandStack(); 121 commandStack = new CommandStack();
109 commandStack.CommandStackUpdated+=new MethodInvoker(commandStack_CommandStackUpdated); 122 commandStack.CommandStackUpdated+=new MethodInvoker(commandStack_CommandStackUpdated);
110 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(OnGameSystemChanged); 123 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(OnGameSystemChanged);
111 WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(OnArmyChanged); 124 WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(OnArmyChanged);