Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
comparison FrmMainWindow.cs @ 5:65279b85446f
Re #1 - LGPL license all code
* Add LGPL header to all files
* Add COPYING.LGPL and COPYING.GPL with content of license
Also
* Moved all classes from IBBoard.WarFoundry to IBBoard.WarFoundry.GTK
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:52:18 +0000 |
parents | 1bb28f84d567 |
children | cfc7683e73f9 |
comparison
equal
deleted
inserted
replaced
4:8208a0fde4c2 | 5:65279b85446f |
---|---|
1 // FrmMainWindow.cs | 1 // This file (FrmMainWindow.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2009 IBBoard. |
2 // | 2 // |
3 // Copyright (C) 2007 IBBoard | 3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
4 // | |
5 // This library is free software; you can redistribute it and/or | |
6 // modify it under the terms of the GNU Lesser General Public | |
7 // License version 2.1 of the License as published by the Free | |
8 // Software Foundation. | |
9 // | |
10 // This library is distributed in the hope that it will be useful, | |
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 // Lesser General Public License for more details. | |
14 // | |
15 // You should have received a copy of the GNU Lesser General Public | |
16 // License along with this library; if not, write to the Free Software | |
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 // | |
19 // | |
20 | 4 |
21 using System; | 5 using System; |
22 using System.IO; | 6 using System.IO; |
23 using System.Collections.Generic; | 7 using System.Collections.Generic; |
24 using System.Configuration; | 8 using System.Configuration; |
40 using IBBoard.WarFoundry.Widgets; | 24 using IBBoard.WarFoundry.Widgets; |
41 using IBBoard.WarFoundry.Plugin.Rollcall; | 25 using IBBoard.WarFoundry.Plugin.Rollcall; |
42 using IBBoard.Xml; | 26 using IBBoard.Xml; |
43 using log4net; | 27 using log4net; |
44 | 28 |
45 namespace IBBoard.WarFoundry | 29 namespace IBBoard.WarFoundry.GTK |
46 { | 30 { |
47 public partial class FrmMainWindow: Gtk.Window | 31 public partial class FrmMainWindow: Gtk.Window |
48 { | 32 { |
49 private static readonly string AppTitle = "WarFoundry"; | 33 private static readonly string AppTitle = "WarFoundry"; |
50 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6; | 34 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6; |
51 | 35 |
52 private Preferences preferences; | 36 private Preferences preferences; |
53 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow)); | 37 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow)); |
54 | 38 |
55 private CommandStack commandStack; | 39 private CommandStack commandStack; |
56 private Type factoryType = typeof(WarFoundryXmlFactory); | |
57 private Dictionary<ToolButton, Category> categoryMap = new Dictionary<ToolButton, Category>(); | 40 private Dictionary<ToolButton, Category> categoryMap = new Dictionary<ToolButton, Category>(); |
58 private Dictionary<IBBoard.WarFoundry.API.Objects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<IBBoard.WarFoundry.API.Objects.Unit,UnitDisplayWidget>(); | 41 private Dictionary<IBBoard.WarFoundry.API.Objects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<IBBoard.WarFoundry.API.Objects.Unit,UnitDisplayWidget>(); |
59 | 42 |
60 private ObjectAddDelegate UnitAddedMethod; | 43 private ObjectAddDelegate UnitAddedMethod; |
61 private ObjectRemoveDelegate UnitRemovedMethod; | 44 private ObjectRemoveDelegate UnitRemovedMethod; |
156 logger.Debug("Attempting to load from file"); | 139 logger.Debug("Attempting to load from file"); |
157 FileInfo file = new FileInfo(args[0]); | 140 FileInfo file = new FileInfo(args[0]); |
158 | 141 |
159 try | 142 try |
160 { | 143 { |
161 //TODO: Try to load files | 144 ICollection<IWarFoundryObject> objects = WarFoundryLoader.GetDefault().LoadFile(file); |
162 /*if (file.Extension.Equals("."+Factory.GetArmyFileExtension())) | 145 |
163 { | 146 if (objects.Count == 1) |
164 WarFoundryCore.CurrentArmy = Factory.CreateArmyFromFile(file); | 147 { |
165 logger.InfoFormat("Loaded army from {0}", file.FullName); | 148 List<IWarFoundryObject> objectList = new List<IWarFoundryObject>(); |
166 } | 149 objectList.AddRange(objects); |
167 else if (file.Extension.Equals("."+Factory.GetSystemFileExtension())) | 150 IWarFoundryObject loadedObject = objectList[0]; |
168 { | 151 |
169 WarFoundryCore.CurrentGameSystem = Factory.CreateGameSystemFromFile(file); | 152 if (loadedObject is Army) |
170 logger.InfoFormat("Loaded game system from {0}", file.FullName); | 153 { |
171 }*/ | 154 WarFoundryCore.CurrentArmy = (Army)loadedObject; |
155 logger.InfoFormat("Loaded army from {0}", file.FullName); | |
156 } | |
157 else if (loadedObject is GameSystem) | |
158 { | |
159 WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject; | |
160 logger.InfoFormat("Loaded game system from {0}", file.FullName); | |
161 } | |
162 } | |
172 } | 163 } |
173 catch (InvalidFileException ex) | 164 catch (InvalidFileException ex) |
174 { | 165 { |
175 //TODO: show error dialog | 166 //TODO: show error dialog |
176 logger.Error(ex); | 167 logger.Error(ex); |