public DialogAddDetachment(Boolean isFixedFaction, ModelClasses.Faction mainFaction, ModelClasses.Factions allFactions, ModelClasses.Detachments allDetachments, Int32 numberOfDetachments) { InitializeComponent(); this.isFixedFaction = isFixedFaction; if (this.isFixedFaction) { this.mainFaction = mainFaction; } this.allFactions = allFactions; this.allDetachments = allDetachments; this.numberOfDetachments = numberOfDetachments; }
private void LoadExistingDetachments() { FileStream fs = null; try { XmlSerializer serializer = new XmlSerializer(typeof(ModelClasses.Detachments)); fs = new FileStream(detachmentsFile, FileMode.Open); existingDetachments = (ModelClasses.Detachments)serializer.Deserialize(fs); fs.Close(); } catch (Exception excp) { if (fs != null) { fs.Dispose(); } } }
private void LoadImportDetachments() { FileStream fsDetachment = null; importedDetachments = new ModelClasses.Detachments(); importedDetachments.Clear(); try { XmlSerializer detachmentSerializer = new XmlSerializer(typeof(ModelClasses.Detachments)); fsDetachment = new FileStream(importedDetachmentsFile, FileMode.Open); importedDetachments = (ModelClasses.Detachments)detachmentSerializer.Deserialize(fsDetachment); fsDetachment.Close(); } catch (Exception excp) { if (fsDetachment != null) { fsDetachment.Dispose(); } } }
private void LoadTemplates() { FileStream fsBattleRole = null; FileStream fsDetachment = null; try { XmlSerializer battleRoleSerializer = new XmlSerializer(typeof(ModelClasses.BattleRoles)); fsBattleRole = new FileStream(battleRolesFile, FileMode.Open); battleRoleTemplates = (ModelClasses.BattleRoles)battleRoleSerializer.Deserialize(fsBattleRole); fsBattleRole.Close(); } catch (Exception excp) { Debug.WriteLine("Issues loading the Detachment-Template: " + excp.Message); if (fsBattleRole != null) { fsBattleRole.Dispose(); } } try { XmlSerializer detachmentSerializer = new XmlSerializer(typeof(ModelClasses.Detachments)); fsDetachment = new FileStream(detachmentsFile, FileMode.Open); detachmentTemplates = (ModelClasses.Detachments)detachmentSerializer.Deserialize(fsDetachment); fsDetachment.Close(); } catch (Exception excp) { if (fsDetachment != null) { fsDetachment.Dispose(); } } RefreshView(); }