} /* Current history point */ /// <summary> /// Project constructor. /// </summary> /// <param name="LoadBasins">Reload basins. Deprecated but whatever</param> public Project() { History = new List <Basin>(); CategorySystems = new List <CategorySystem>(); OpenBasins = new List <Basin>(); SelectedBasin = new Basin(); }
public void InitBasin(Basin Bs, bool SelectNow = false) { #if DANO // ATTN: You can write anything you want if it's not covered by the currently defined ifdefs Bs.SeasonHemisphere = Hemisphere; Bs.SeasonType = Type; #endif // load function goes here // Create a background layer Layer BgLayer = new Layer(); BgLayer.Name = "Background"; if (SelectNow) { Bs.IsOpen = true; Bs.IsSelected = true; } Bs.Layers.Add(BgLayer); Bs.SelectLayerWithName(BgLayer.Name); #if PRISCILLA MainWindow MnWindow = (MainWindow)Application.Current.MainWindow; #endif OpenBasins.Add(Bs); SelectedBasin = Bs; }
/// <summary> /// Add the basin with Name and usertag UserTag. Also select it if SelectNOw = true. /// </summary> /// <param name="Name">The name of the basin to add.</param> /// <param name="UserTag">The name of the season to add (V3.0 Only)</param> /// <param name="SelectNow">Select this basin now</param> public void AddBasin(string Name, string UserTag, bool SelectNow = false) { // This is still terrible, but it's just temporary Basin Bs = GetBasinWithName(Name); Bs.LoadImage(Bs.ImagePath); Bs.UserTag = UserTag; InitBasin(Bs); }
/// <summary> /// Add the basin with Name. Also select it if SelectNow = true. /// </summary> /// <param name="Name">The name of the basin we wish to load.</param> /// <param name="SelectNow">Select the basin upon loading.</param> public void AddBasin(string Name, bool SelectNow = false) { // This is still terrible, but it's just temporary Basin Bs = GetBasinWithName(Name); if (Bs == null) { Error.Throw("Fatal Error", $"Attempted to add an invalid basin with name {Name}", ErrorSeverity.FatalError, 181); } Bs.LoadImage(Bs.ImagePath); InitBasin(Bs); }
/// <summary> /// Initialise a basin after project initialisation /// </summary> /// <param name="Bs"></param> private void InitBasin(Basin Bs) { #if DANO // ATTN: You can write anything you want if it's not covered by the currently defined ifdefs Bs.SeasonHemisphere = Hemisphere; Bs.SeasonType = Type; #endif // load function goes here // Create a background layer Layer BgLayer = new Layer(); BgLayer.Name = "Background"; Bs.Layers.Add(BgLayer); Bs.SelectLayerWithName(BgLayer.Name); OpenBasins.Add(Bs); SelectedBasin = Bs; }
public void AddBasin(Basin Bs, bool SelectNow = false) { InitBasin(Bs); }
/// <summary> /// 2020-11-27 /// /// Iris: replace with deserialisation /// </summary> public static void LoadBasins() { try { InitBasinList(); XmlDocument XmlDocument = new XmlDocument(); XmlDocument.Load(@"Data\Basins.xml"); // maybe change? XmlNode XmlRootNode = XmlDocument.FirstChild; while (XmlRootNode.Name != "Basins") { if (XmlRootNode.NextSibling == null) { Error.Throw("Fatal Error!", "Basins.xml is corrupted or malformed. The Track Maker will now exit.", ErrorSeverity.FatalError, 1); } XmlRootNode = XmlRootNode.NextSibling; //figure out what happens if the basin node doesn't exist. } XmlNodeList XmlNodes = XmlRootNode.ChildNodes; //abduct the kids of the basins node foreach (XmlNode XmlNode in XmlNodes) { Basin Basin = new Basin(); // create a new basin. if (XmlNode.Name.Contains('#')) { continue; } if (XmlNode.Name != "Basin") { // change this? Error.Throw("Fatal Error!", "Attempted to load non-basin node, discarding basin!", ErrorSeverity.Error, 2); return; } XmlAttributeCollection XmlAttributes = XmlNode.Attributes; foreach (XmlAttribute XmlAttribute in XmlAttributes) { switch (XmlAttribute.Name) // go through all the attributes { case "Abbreviation": case "Acronym": case "BasinCode": Basin.Abbreviation = XmlAttribute.Value; continue; case "bgimage": // basin image path case "Bgimage": case "bgImage": case "BgImage": Basin.ImagePath = XmlAttribute.Value; //set the basin image path to the value continue; // yeah case "coordstopleft": case "Coordstopleft": case "coordsTopleft": case "coordsTopLeft": case "CoordsTopLeft": // Conversion Basin.CoordsLower = Coordinate.FromString(XmlAttribute.InnerText, CoordinateFormat.TrackMaker); continue; case "coordsbottomright": case "Coordsbottomright": case "CoordsBottomright": case "coordsBottomRight": case "CoordsBottomRight": // Conversion Basin.CoordsHigher = Coordinate.FromString(XmlAttribute.InnerText, CoordinateFormat.TrackMaker); continue; case "name": // basin name case "Name": Basin.Name = XmlAttribute.Value; continue; } } if (Basin.Name == null) { Error.Throw("Fatal Error!", "Fatal Error: Cannot load basin with no name!", ErrorSeverity.FatalError, 240); } if (Basin.Abbreviation == null) { Basin.Abbreviation = "NA"; } Debug.Assert(Basin.Name != null && Basin.Abbreviation != null); Logging.Log($"Successfully loaded basin {Basin.Name} with image {Basin.ImagePath}"); OpenBasins.Add(Basin); } } catch (XmlException err) { //todo create fatalerror method #if DEBUG Error.Throw("Fatal Error!", $"Basins.xml is corrupt or invalid!\n\n{err}", ErrorSeverity.FatalError, 203); #else Error.Throw("Fatal Error!", "Basins.xml is corrupt or invalid!", ErrorSeverity.FatalError, 203); #endif Environment.Exit(203); } }
public void Remove(Basin BasinObject) => Basins.Remove(BasinObject);
public void Add(Basin BasinObject) => Basins.Add(BasinObject);