comparison FrmMainWindow.cs @ 15:85db2c9a1546

Fixes #95: Can't re-open GTK# tabs * Make Unit for UnitDisplayWidget visible as a property * Hook in to Destroyed event of UnitDisplayWidget to remove it from the map of tabs
author IBBoard <dev@ibboard.co.uk>
date Sat, 27 Jun 2009 20:13:21 +0000
parents abbf8a3ac431
children 7653fab9d70e
comparison
equal deleted inserted replaced
14:abbf8a3ac431 15:85db2c9a1546
128 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded); 128 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded);
129 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved); 129 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved);
130 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged); 130 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged);
131 FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement); 131 FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement);
132 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged); 132 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged);
133 logger.Debug("Initialising complete - trying to load default army or system");
134 133
135 //FIXME: Temporary hack to add paths and factories 134 //FIXME: Temporary hack to add paths and factories
136 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data")); 135 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data"));
137 IWarFoundryFactory factory = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(WarFoundryXmlFactory)); 136 IWarFoundryFactory factory = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(WarFoundryXmlFactory));
138 137
145 144
146 if (factory!=null && factory is RollcallFactory) 145 if (factory!=null && factory is RollcallFactory)
147 { 146 {
148 WarFoundryLoader.GetDefault().RegisterNonNativeFactory((INonNativeWarFoundryFactory)factory); 147 WarFoundryLoader.GetDefault().RegisterNonNativeFactory((INonNativeWarFoundryFactory)factory);
149 } 148 }
149
150 logger.Debug("Initialising complete - seeing if we can load default army or system");
150 151
151 if (args.Length == 1) 152 if (args.Length == 1)
152 { 153 {
153 logger.Debug("Attempting to load from file"); 154 logger.Debug("Attempting to load from file");
154 FileInfo file = new FileInfo(args[0]); 155 FileInfo file = new FileInfo(args[0]);
916 else 917 else
917 { 918 {
918 widget = new UnitDisplayWidget(unit, CommandStack); 919 widget = new UnitDisplayWidget(unit, CommandStack);
919 logger.Debug("Adding page for "+unit.Name); 920 logger.Debug("Adding page for "+unit.Name);
920 unitToWidgetMap[unit] = widget; 921 unitToWidgetMap[unit] = widget;
922 widget.Destroyed+= new EventHandler(UnitWidgetDestroyed);
921 int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name); 923 int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name);
922 logger.Debug("Page added at index "+pageNum); 924 logger.Debug("Page added at index "+pageNum);
923 unitsNotebook.ShowAll(); 925 unitsNotebook.ShowAll();
924 unitsNotebook.Page = pageNum; 926 unitsNotebook.Page = pageNum;
925 } 927 }
926 } 928 }
927 } 929 }
930
931 private void UnitWidgetDestroyed(object sender, EventArgs e)
932 {
933 if (sender is UnitDisplayWidget)
934 {
935 unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit);
936 }
937 }
928 } 938 }
929 } 939 }