public override void InitializeFromXml(XmlNode node) { XmlNode imageSetNode = Util.SelectSingleNode(node, "ImageSet"); imageSet = Imageset.FromXMLNode(imageSetNode); if (node.Attributes.GetNamedItem("Extension") != null) { extension = node.Attributes.GetNamedItem("Extension").Value; } if (node.Attributes.GetNamedItem("ScaleType") != null) { lastScale = (ScaleTypes)Enums.Parse("ScaleTypes", node.Attributes.GetNamedItem("ScaleType").Value); } if (node.Attributes.GetNamedItem("MinValue") != null) { min = double.Parse(node.Attributes.GetNamedItem("MinValue").Value); } if (node.Attributes.GetNamedItem("MaxValue") != null) { max = double.Parse(node.Attributes.GetNamedItem("MaxValue").Value); } if (node.Attributes.GetNamedItem("OverrideDefault") != null) { overrideDefaultLayer = bool.Parse(node.Attributes.GetNamedItem("OverrideDefault").Value); } }
public override void InitializeFromXml(XmlNode node) { XmlNode imageSetNode = Util.SelectSingleNode(node, "ImageSet"); imageSet = Imageset.FromXMLNode(imageSetNode); if (node.Attributes.GetNamedItem("Extension") != null) { extension = node.Attributes.GetNamedItem("Extension").Value; } if (node.Attributes.GetNamedItem("ScaleType") != null) { ImageSet.FitsProperties.ScaleType = (ScaleTypes)Enums.Parse("ScaleTypes", node.Attributes.GetNamedItem("ScaleType").Value); } if (node.Attributes.GetNamedItem("MinValue") != null) { ImageSet.FitsProperties.MinVal = double.Parse(node.Attributes.GetNamedItem("MinValue").Value); ImageSet.FitsProperties.LowerCut = node.Attributes.GetNamedItem("LowerCut") != null ? double.Parse(node.Attributes.GetNamedItem("LowerCut").Value) : ImageSet.FitsProperties.MinVal; } if (node.Attributes.GetNamedItem("MaxValue") != null) { ImageSet.FitsProperties.MaxVal = double.Parse(node.Attributes.GetNamedItem("MaxValue").Value); ImageSet.FitsProperties.UpperCut = node.Attributes.GetNamedItem("UpperCut") != null ? double.Parse(node.Attributes.GetNamedItem("UpperCut").Value) : ImageSet.FitsProperties.MaxVal; } if (node.Attributes.GetNamedItem("ColorMapperName") != null) { ImageSet.FitsProperties.ColorMapName = node.Attributes.GetNamedItem("ColorMapperName").Value; } if (node.Attributes.GetNamedItem("OverrideDefault") != null) { overrideDefaultLayer = bool.Parse(node.Attributes.GetNamedItem("OverrideDefault").Value); } }
internal static Place FromXml(XmlNode place) { Place newPlace = new Place(); newPlace.name = place.Attributes.GetNamedItem("Name").Value; if (place.Attributes.GetNamedItem("MSRComponentId") != null && place.Attributes.GetNamedItem("Permission") != null && place.Attributes.GetNamedItem("Url") != null) { //communities item newPlace.Url = place.Attributes.GetNamedItem("Url").Value; newPlace.ThumbnailUrl = place.Attributes.GetNamedItem("Thumbnail").Value; return(newPlace); } if (place.Attributes.GetNamedItem("DataSetType") != null) { newPlace.type = (ImageSetType)Enums.Parse("ImageSetType", place.Attributes.GetNamedItem("DataSetType").Value); } if (newPlace.Type == ImageSetType.Sky) { newPlace.camParams.RA = double.Parse(place.Attributes.GetNamedItem("RA").Value); newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value); } else { newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value); newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value); } if (place.Attributes.GetNamedItem("Constellation") != null) { newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value; } if (place.Attributes.GetNamedItem("Classification") != null) { newPlace.classification = (Classification)Enums.Parse("Classification", place.Attributes.GetNamedItem("Classification").Value); } if (place.Attributes.GetNamedItem("Magnitude") != null) { newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value); } if (place.Attributes.GetNamedItem("AngularSize") != null) { newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value); } if (place.Attributes.GetNamedItem("ZoomLevel") != null) { newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value); } if (place.Attributes.GetNamedItem("Rotation") != null) { newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value); } if (place.Attributes.GetNamedItem("Annotation") != null) { newPlace.annotation = place.Attributes.GetNamedItem("Annotation").Value; } if (place.Attributes.GetNamedItem("Angle") != null) { newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value); } if (place.Attributes.GetNamedItem("Opacity") != null) { newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value); } else { newPlace.camParams.Opacity = 100; } newPlace.Target = SolarSystemObjects.Undefined; if (place.Attributes.GetNamedItem("Target") != null) { newPlace.Target = (SolarSystemObjects)Enums.Parse("SolarSystemObjects", place.Attributes.GetNamedItem("Target").Value); } if (place.Attributes.GetNamedItem("ViewTarget") != null) { newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value); } if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null) { newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value; } XmlNode descriptionNode = Util.SelectSingleNode(place, "Description"); if (descriptionNode != null) { newPlace.HtmlDescription = descriptionNode.Value; } XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet"); if (backgroundImageSet != null) { XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet, "ImageSet"); newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet); } XmlNode study = Util.SelectSingleNode(place, "ForegroundImageSet"); if (study != null) { XmlNode imageSet = Util.SelectSingleNode(study, "ImageSet"); newPlace.studyImageset = Imageset.FromXMLNode(imageSet); } study = Util.SelectSingleNode(place, "ImageSet"); if (study != null) { newPlace.studyImageset = Imageset.FromXMLNode(study); } return(newPlace); }
//public static Folder LoadFromXML(XmlNode node) //{ // Folder temp = new Folder(); // temp.ParseXML(node); // return temp; //} private void ParseXML(XmlNode node) { if (node.Attributes.GetNamedItem("Name") != null) { nameField = node.Attributes.GetNamedItem("Name").Value; } else { nameField = ""; } if (node.Attributes.GetNamedItem("Url") != null) { urlField = node.Attributes.GetNamedItem("Url").Value; } if (node.Attributes.GetNamedItem("Thumbnail") != null) { thumbnailUrlField = node.Attributes.GetNamedItem("Thumbnail").Value; } // load Children foreach (XmlNode child in node.ChildNodes) { switch (child.Name) { case "Folder": Folder temp = new Folder(); temp.Parent = this; //if (Parent != null && IsProxy) //{ // temp.Parent = Parent.Parent; //} temp.ParseXML(child); folders.Add(temp); break; case "Place": places.Add(Place.FromXml(child)); break; case "ImageSet": Imagesets.Add(Imageset.FromXMLNode(child)); break; case "Tour": Tours.Add(Tour.FromXml(child)); break; } } //bool Browseable { get; set; } //System.Collections.Generic.List<Folder> Folders { get; set; } //FolderGroup Group { get; set; } //System.Collections.Generic.List<Imageset> Imagesets { get; set; } //long MSRCommunityId { get; set; } //long MSRComponentId { get; set; } //string Name { get; set; } //long Permission { get; set; } //System.Collections.Generic.List<Place> Places { get; set; } //bool ReadOnly { get; set; } //string RefreshInterval { get; set; } //FolderRefreshType RefreshType { get; set; } //bool RefreshTypeSpecified { get; set; } //bool Searchable { get; set; } //string SubType { get; set; } //string ThumbnailUrl { get; set; } //System.Collections.Generic.List<Tour> Tours { get; set; } //FolderType Type { get; set; } //string Url { get; set; } }
//internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName) //{ // xmlWriter.WriteStartElement(elementName); // xmlWriter.WriteAttributeString("Name", name); // xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString()); // if (this.Type == ImageSetType.Sky) // { // xmlWriter.WriteAttributeString("RA", camParams.RA.ToString()); // xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString()); // } // else // { // xmlWriter.WriteAttributeString("Lat", Lat.ToString()); // xmlWriter.WriteAttributeString("Lng", Lng.ToString()); // } // xmlWriter.WriteAttributeString("Constellation", constellation); // xmlWriter.WriteAttributeString("Classification", Classification.ToString()); // xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString()); // xmlWriter.WriteAttributeString("Distance", distnace.ToString()); // xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString()); // xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString()); // xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString()); // xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString()); // xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString()); // xmlWriter.WriteAttributeString("Target", Target.ToString()); // xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString()); // xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame); // xmlWriter.WriteStartElement("Description"); // xmlWriter.WriteCData(HtmlDescription); // xmlWriter.WriteEndElement(); // if (backgroundImageSet != null) // { // xmlWriter.WriteStartElement("BackgroundImageSet"); // ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, ""); // xmlWriter.WriteEndElement(); // } // if (studyImageset != null) // { // ImageSetHelper.SaveToXml(xmlWriter, studyImageset, ""); // } // xmlWriter.WriteEndElement(); //} internal static Place FromXml(XmlNode place) { Place newPlace = new Place(); newPlace.name = place.Attributes.GetNamedItem("Name").Value; newPlace.Type = (ImageSetType)Enum.Parse(typeof(ImageSetType), place.Attributes.GetNamedItem("DataSetType").Value); if (newPlace.Type == ImageSetType.Sky) { newPlace.camParams.RA = double.Parse(place.Attributes.GetNamedItem("RA").Value); newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value); } else { newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value); newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value); } newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value; //todo change to switch/case newPlace.Classification = (Classification)Enum.Parse(typeof(Classification), place.Attributes.GetNamedItem("Classification").Value); newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value); if (place.Attributes.GetNamedItem("Magnitude") != null) { newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value); } newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value); newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value); newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value); newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value); if (place.Attributes.GetNamedItem("Opacity") != null) { newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value); } else { newPlace.camParams.Opacity = 100; } if (place.Attributes.GetNamedItem("Target") != null) { newPlace.Target = (SolarSystemObjects)Enum.Parse(typeof(SolarSystemObjects), place.Attributes.GetNamedItem("Target").Value); } if (place.Attributes.GetNamedItem("ViewTarget") != null) { newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value); } //if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null) //{ // newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value; //} XmlNode descriptionNode = Util.SelectSingleNode(place, "Description"); if (descriptionNode != null) { newPlace.HtmlDescription = descriptionNode.Value; } XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet"); if (backgroundImageSet != null) { XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet, "ImageSet"); newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet); } XmlNode study = Util.SelectSingleNode(place, "ImageSet"); if (study != null) { newPlace.studyImageset = Imageset.FromXMLNode(study); } return(newPlace); }
//internal void SaveToXml(System.Xml.XmlTextWriter xmlWriter, string elementName) //{ // xmlWriter.WriteStartElement(elementName); // xmlWriter.WriteAttributeString("Name", name); // xmlWriter.WriteAttributeString("DataSetType", this.Type.ToString()); // if (this.Type == ImageSetType.Sky) // { // xmlWriter.WriteAttributeString("RA", camParams.RA.ToString()); // xmlWriter.WriteAttributeString("Dec", camParams.Dec.ToString()); // } // else // { // xmlWriter.WriteAttributeString("Lat", Lat.ToString()); // xmlWriter.WriteAttributeString("Lng", Lng.ToString()); // } // xmlWriter.WriteAttributeString("Constellation", constellation); // xmlWriter.WriteAttributeString("Classification", Classification.ToString()); // xmlWriter.WriteAttributeString("Magnitude", magnitude.ToString()); // xmlWriter.WriteAttributeString("Distance", distnace.ToString()); // xmlWriter.WriteAttributeString("AngularSize", AngularSize.ToString()); // xmlWriter.WriteAttributeString("ZoomLevel", ZoomLevel.ToString()); // xmlWriter.WriteAttributeString("Rotation", camParams.Rotation.ToString()); // xmlWriter.WriteAttributeString("Angle", camParams.Angle.ToString()); // xmlWriter.WriteAttributeString("Opacity", camParams.Opacity.ToString()); // xmlWriter.WriteAttributeString("Target", Target.ToString()); // xmlWriter.WriteAttributeString("ViewTarget", camParams.ViewTarget.ToString()); // xmlWriter.WriteAttributeString("TargetReferenceFrame", camParams.TargetReferenceFrame); // xmlWriter.WriteStartElement("Description"); // xmlWriter.WriteCData(HtmlDescription); // xmlWriter.WriteEndElement(); // if (backgroundImageSet != null) // { // xmlWriter.WriteStartElement("BackgroundImageSet"); // ImageSetHelper.SaveToXml(xmlWriter, backgroundImageSet, ""); // xmlWriter.WriteEndElement(); // } // if (studyImageset != null) // { // ImageSetHelper.SaveToXml(xmlWriter, studyImageset, ""); // } // xmlWriter.WriteEndElement(); //} internal static Place FromXml(XmlNode place) { Place newPlace = new Place(); newPlace.name = place.Attributes.GetNamedItem("Name").Value; if (place.Attributes.GetNamedItem("DataSetType") != null) { switch (place.Attributes.GetNamedItem("DataSetType").Value.ToLowerCase()) { case "earth": newPlace.type = ImageSetType.Earth; break; case "planet": newPlace.type = ImageSetType.Planet; break; case "sky": newPlace.type = ImageSetType.Sky; break; case "panorama": newPlace.type = ImageSetType.Panorama; break; case "solarsystem": newPlace.type = ImageSetType.SolarSystem; break; } } if (newPlace.Type == ImageSetType.Sky) { newPlace.camParams.RA = double.Parse(place.Attributes.GetNamedItem("RA").Value); newPlace.camParams.Dec = double.Parse(place.Attributes.GetNamedItem("Dec").Value); } else { newPlace.Lat = double.Parse(place.Attributes.GetNamedItem("Lat").Value); newPlace.Lng = double.Parse(place.Attributes.GetNamedItem("Lng").Value); } if (place.Attributes.GetNamedItem("Constellation") != null) { newPlace.constellation = place.Attributes.GetNamedItem("Constellation").Value; } //todo change to switch/case if (place.Attributes.GetNamedItem("Classification") != null) { switch (place.Attributes.GetNamedItem("Classification").Value) { case "Star": newPlace.classification = Classification.Star; break; case "Supernova": newPlace.classification = Classification.Supernova; break; case "BlackHole": newPlace.classification = Classification.BlackHole; break; case "NeutronStar": newPlace.classification = Classification.NeutronStar; break; case "DoubleStar": newPlace.classification = Classification.DoubleStar; break; case "MultipleStars": newPlace.classification = Classification.MultipleStars; break; case "Asterism": newPlace.classification = Classification.Asterism; break; case "Constellation": newPlace.classification = Classification.Constellation; break; case "OpenCluster": newPlace.classification = Classification.OpenCluster; break; case "GlobularCluster": newPlace.classification = Classification.GlobularCluster; break; case "NebulousCluster": newPlace.classification = Classification.NebulousCluster; break; case "Nebula": newPlace.classification = Classification.Nebula; break; case "EmissionNebula": newPlace.classification = Classification.EmissionNebula; break; case "PlanetaryNebula": newPlace.classification = Classification.PlanetaryNebula; break; case "ReflectionNebula": newPlace.classification = Classification.ReflectionNebula; break; case "DarkNebula": newPlace.classification = Classification.DarkNebula; break; case "GiantMolecularCloud": newPlace.classification = Classification.GiantMolecularCloud; break; case "SupernovaRemnant": newPlace.classification = Classification.SupernovaRemnant; break; case "InterstellarDust": newPlace.classification = Classification.InterstellarDust; break; case "Quasar": newPlace.classification = Classification.Quasar; break; case "Galaxy": newPlace.classification = Classification.Galaxy; break; case "SpiralGalaxy": newPlace.classification = Classification.SpiralGalaxy; break; case "IrregularGalaxy": newPlace.classification = Classification.IrregularGalaxy; break; case "EllipticalGalaxy": newPlace.classification = Classification.EllipticalGalaxy; break; case "Knot": newPlace.classification = Classification.Knot; break; case "PlateDefect": newPlace.classification = Classification.PlateDefect; break; case "ClusterOfGalaxies": newPlace.classification = Classification.ClusterOfGalaxies; break; case "OtherNGC": newPlace.classification = Classification.OtherNGC; break; case "Unidentified": newPlace.classification = Classification.Unidentified; break; case "SolarSystem": newPlace.classification = Classification.SolarSystem; break; case "Unfiltered": newPlace.classification = Classification.Unfiltered; break; case "Stellar": newPlace.classification = Classification.Stellar; break; case "StellarGroupings": newPlace.classification = Classification.StellarGroupings; break; case "Nebulae": newPlace.classification = Classification.Nebulae; break; case "Galactic": newPlace.classification = Classification.Galactic; break; case "Other": newPlace.classification = Classification.Other; break; default: break; } } if (place.Attributes.GetNamedItem("Magnitude") != null) { newPlace.magnitude = double.Parse(place.Attributes.GetNamedItem("Magnitude").Value); } if (place.Attributes.GetNamedItem("AngularSize") != null) { newPlace.AngularSize = double.Parse(place.Attributes.GetNamedItem("AngularSize").Value); } if (place.Attributes.GetNamedItem("ZoomLevel") != null) { newPlace.ZoomLevel = double.Parse(place.Attributes.GetNamedItem("ZoomLevel").Value); } if (place.Attributes.GetNamedItem("Rotation") != null) { newPlace.camParams.Rotation = double.Parse(place.Attributes.GetNamedItem("Rotation").Value); } if (place.Attributes.GetNamedItem("Angle") != null) { newPlace.camParams.Angle = double.Parse(place.Attributes.GetNamedItem("Angle").Value); } if (place.Attributes.GetNamedItem("Opacity") != null) { newPlace.camParams.Opacity = Single.Parse(place.Attributes.GetNamedItem("Opacity").Value); } else { newPlace.camParams.Opacity = 100; } newPlace.Target = SolarSystemObjects.Undefined; if (place.Attributes.GetNamedItem("Target") != null) { switch (place.Attributes.GetNamedItem("Target").Value) { case "Sun": newPlace.Target = SolarSystemObjects.Sun; break; case "Mercury": newPlace.Target = SolarSystemObjects.Mercury; break; case "Venus": newPlace.Target = SolarSystemObjects.Venus; break; case "Mars": newPlace.Target = SolarSystemObjects.Mars; break; case "Jupiter": newPlace.Target = SolarSystemObjects.Jupiter; break; case "Saturn": newPlace.Target = SolarSystemObjects.Saturn; break; case "Uranus": newPlace.Target = SolarSystemObjects.Uranus; break; case "Neptune": newPlace.Target = SolarSystemObjects.Neptune; break; case "Pluto": newPlace.Target = SolarSystemObjects.Pluto; break; case "Moon": newPlace.Target = SolarSystemObjects.Moon; break; case "Io": newPlace.Target = SolarSystemObjects.Io; break; case "Europa": newPlace.Target = SolarSystemObjects.Europa; break; case "Ganymede": newPlace.Target = SolarSystemObjects.Ganymede; break; case "Callisto": newPlace.Target = SolarSystemObjects.Callisto; break; case "IoShadow": newPlace.Target = SolarSystemObjects.IoShadow; break; case "EuropaShadow": newPlace.Target = SolarSystemObjects.EuropaShadow; break; case "GanymedeShadow": newPlace.Target = SolarSystemObjects.GanymedeShadow; break; case "CallistoShadow": newPlace.Target = SolarSystemObjects.CallistoShadow; break; case "SunEclipsed": newPlace.Target = SolarSystemObjects.SunEclipsed; break; case "Earth": newPlace.Target = SolarSystemObjects.Earth; break; case "Custom": newPlace.Target = SolarSystemObjects.Custom; break; case "Undefined": newPlace.Target = SolarSystemObjects.Undefined; break; default: break; } } if (place.Attributes.GetNamedItem("ViewTarget") != null) { newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes.GetNamedItem("ViewTarget").Value); } //if (place.Attributes.GetNamedItem("TargetReferenceFrame") != null) //{ // newPlace.camParams.TargetReferenceFrame = place.Attributes.GetNamedItem("TargetReferenceFrame").Value; //} XmlNode descriptionNode = Util.SelectSingleNode(place, "Description"); if (descriptionNode != null) { newPlace.HtmlDescription = descriptionNode.Value; } XmlNode backgroundImageSet = Util.SelectSingleNode(place, "BackgroundImageSet"); if (backgroundImageSet != null) { XmlNode imageSet = Util.SelectSingleNode(backgroundImageSet, "ImageSet"); newPlace.backgroundImageSet = Imageset.FromXMLNode(imageSet); } XmlNode study = Util.SelectSingleNode(place, "ForegroundImageSet"); if (study != null) { XmlNode imageSet = Util.SelectSingleNode(study, "ImageSet"); newPlace.studyImageset = Imageset.FromXMLNode(imageSet); } study = Util.SelectSingleNode(place, "ImageSet"); if (study != null) { newPlace.studyImageset = Imageset.FromXMLNode(study); } return(newPlace); }