public static void Add(Layer layer, bool updateTree) { if (!LayerList.ContainsKey(layer.ID)) { if (AllMaps.ContainsKey(layer.ReferenceFrame)) { LayerList[layer.ID] = layer; AllMaps[layer.ReferenceFrame].Layers.Add(layer); version++; if (updateTree) { LoadTree(); } } } }
public void FromXml(XmlDocument doc) { XmlNode root = Util.SelectSingleNode(doc, "Tour"); id = root.Attributes.GetNamedItem("ID").Value.ToString(); Title = root.Attributes.GetNamedItem("Title").Value.ToString(); Author = root.Attributes.GetNamedItem("Author").Value.ToString(); if (root.Attributes.GetNamedItem("Descirption") != null) { Description = root.Attributes.GetNamedItem("Descirption").Value; } if (root.Attributes.GetNamedItem("AuthorEmail") != null) { authorEmail = root.Attributes.GetNamedItem("AuthorEmail").Value; } if (root.Attributes.GetNamedItem("Keywords") != null) { Keywords = root.Attributes.GetNamedItem("Keywords").Value; } if (root.Attributes.GetNamedItem("OrganizationName") != null) { OrgName = root.Attributes.GetNamedItem("OrganizationName").Value; } organizationUrl = root.Attributes.GetNamedItem("OrganizationUrl").Value; switch (root.Attributes.GetNamedItem("UserLevel").Value) { case "Beginner": level = UserLevel.Beginner; break; case "Intermediate": level = UserLevel.Intermediate; break; case "Advanced": level = UserLevel.Advanced; break; case "Educator": level = UserLevel.Educator; break; case "Professional": level = UserLevel.Professional; break; default: break; } switch (root.Attributes.GetNamedItem("Classification").Value) { case "Star": type = Classification.Star; break; case "Supernova": type = Classification.Supernova; break; case "BlackHole": type = Classification.BlackHole; break; case "NeutronStar": type = Classification.NeutronStar; break; case "DoubleStar": type = Classification.DoubleStar; break; case "MultipleStars": type = Classification.MultipleStars; break; case "Asterism": type = Classification.Asterism; break; case "Constellation": type = Classification.Constellation; break; case "OpenCluster": type = Classification.OpenCluster; break; case "GlobularCluster": type = Classification.GlobularCluster; break; case "NebulousCluster": type = Classification.NebulousCluster; break; case "Nebula": type = Classification.Nebula; break; case "EmissionNebula": type = Classification.EmissionNebula; break; case "PlanetaryNebula": type = Classification.PlanetaryNebula; break; case "ReflectionNebula": type = Classification.ReflectionNebula; break; case "DarkNebula": type = Classification.DarkNebula; break; case "GiantMolecularCloud": type = Classification.GiantMolecularCloud; break; case "SupernovaRemnant": type = Classification.SupernovaRemnant; break; case "InterstellarDust": type = Classification.InterstellarDust; break; case "Quasar": type = Classification.Quasar; break; case "Galaxy": type = Classification.Galaxy; break; case "SpiralGalaxy": type = Classification.SpiralGalaxy; break; case "IrregularGalaxy": type = Classification.IrregularGalaxy; break; case "EllipticalGalaxy": type = Classification.EllipticalGalaxy; break; case "Knot": type = Classification.Knot; break; case "PlateDefect": type = Classification.PlateDefect; break; case "ClusterOfGalaxies": type = Classification.ClusterOfGalaxies; break; case "OtherNGC": type = Classification.OtherNGC; break; case "Unidentified": type = Classification.Unidentified; break; case "SolarSystem": type = Classification.SolarSystem; break; case "Unfiltered": type = Classification.Unfiltered; break; case "Stellar": type = Classification.Stellar; break; case "StellarGroupings": type = Classification.StellarGroupings; break; case "Nebulae": type = Classification.Nebulae; break; case "Galactic": type = Classification.Galactic; break; case "Other": type = Classification.Other; break; default: break; } taxonomy = root.Attributes.GetNamedItem("Taxonomy").Value.ToString(); XmlNode TourStops = Util.SelectSingleNode(root, "TourStops"); foreach (XmlNode tourStop in TourStops.ChildNodes) { if (tourStop.Name == "TourStop") { AddTourStop(TourStop.FromXml(this, tourStop)); } } XmlNode Frames = Util.SelectSingleNode(root, "ReferenceFrames"); if (Frames != null) { foreach (XmlNode frame in Frames.ChildNodes) { if (frame.Name == "ReferenceFrame") { ReferenceFrame newFrame = new ReferenceFrame(); newFrame.InitializeFromXml(frame); if (!LayerManager.AllMaps.ContainsKey(newFrame.Name)) { LayerMap map = new LayerMap(newFrame.Name, ReferenceFrames.Custom); map.Frame = newFrame; map.LoadedFromTour = true; LayerManager.AllMaps[newFrame.Name] = map; } } } LayerManager.ConnectAllChildren(); LayerManager.LoadTree(); } XmlNode Layers = Util.SelectSingleNode(root, "Layers"); if (Layers != null) { foreach (XmlNode layer in Layers.ChildNodes) { if (layer.Name == "Layer") { Layer newLayer = new Layer().FromXml(layer,true);//.Layer.FromXml(layer, true); if (newLayer != null) { string fileName = string.Format("{0}.txt", newLayer.ID.ToString()); if (LayerManager.LayerList.ContainsKey(newLayer.ID)) // && newLayer.ID != ISSLayer.ISSGuid) { //if (!CollisionChecked) //{ // if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) // { // OverWrite = true; // } // else // { // OverWrite = false; // } // CollisionChecked = true; //} //if (OverWrite) //{ LayerManager.DeleteLayerByID(newLayer.ID, true, false); //} } try { newLayer.LoadedFromTour = true; newLayer.LoadData(GetFileStream(fileName)); LayerManager.Add(newLayer, false); } catch { } } } } LayerManager.LoadTree(); } //todo author //if (File.Exists(WorkingDirectory + "Author.png")) //{ // authorImage = UiTools.LoadBitmap(WorkingDirectory + "Author.png"); //} tourDirty = 0; }