/// <summary> /// Load the race images. /// </summary> /// <returns>Returns true if the race icons were successfuly loaded.</returns> public static bool Restore() { if (Data.IconList.Count < 1) { try { using (Config conf = new Config()) { var graphicFolder = FileSearcher.GetGraphicsPath(); // load the icons DirectoryInfo info = new DirectoryInfo(Path.Combine(graphicFolder, "Race")); foreach (FileInfo fi in info.GetFiles()) { Bitmap i = new Bitmap(Path.Combine(fi.DirectoryName, fi.Name)); RaceIcon icon = new RaceIcon(fi.Name, i); Data.IconList.Add(icon); } } } catch { Report.Error("RaceIcon: Restore() - Failed to load race icons."); return(false); } } return(true); }
/// <summary> /// Load: initializing constructor to read in an empire report from an XmlNode (from a saved file). /// </summary> /// <param name="node">An XmlNode representing an Empire report.</param> public EmpireIntel(XmlNode node) { while (node != null) { try { switch (node.Name.ToLower()) { case "empireintel": node = node.FirstChild; continue; case "racename": RaceName = node.FirstChild.Value; break; case "id": Id = ushort.Parse(node.FirstChild.Value, System.Globalization.NumberStyles.HexNumber); break; case "relation": Relation = (PlayerRelation)Enum.Parse(typeof(PlayerRelation), node.FirstChild.Value); break; case "raceicon": Icon = new RaceIcon(node); break; case "enemydesigns": XmlNode subNode = node.FirstChild; while (subNode != null) { ShipDesign design = new ShipDesign(subNode); Designs.Add(design.Key, design); subNode = subNode.NextSibling; } break; } } catch (Exception e) { Report.FatalError(e.Message + "\n Details: \n" + e); } node = node.NextSibling; } }
/// <summary> /// Default Constructor. /// </summary> /// <param name="empire"></param> public EmpireIntel(EmpireData empire) { Id = empire.Id; RaceName = empire.Race.Name; Icon = empire.Race.Icon; }
/// <summary> /// Return a clone of this object. /// </summary> public object Clone() { RaceIcon clone = new RaceIcon(Source, Image); return(clone as object); }