public override void InitializeFromXml(System.Xml.XmlNode node)
        {
            XmlNode imageSetNode = node["ImageSet"];

            ImageSetHelper ish = ImageSetHelper.FromXMLNode(imageSetNode);

            if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
            {
                imageSet = Earth3d.ReplacementImageSets[ish.Url];
            }
            else
            {
                imageSet = ish;
            }

            if (node.Attributes["Extension"] != null)
            {
                extension = node.Attributes["Extension"].Value;
            }

            if (node.Attributes["ScaleType"] != null)
            {
                lastScale = (ScaleTypes)Enum.Parse(typeof(ScaleTypes), node.Attributes["ScaleType"].Value);
            }

            if (node.Attributes["MinValue"] != null)
            {
                min = double.Parse(node.Attributes["MinValue"].Value);
            }

            if (node.Attributes["MaxValue"] != null)
            {
                max = double.Parse(node.Attributes["MaxValue"].Value);
            }

            if (node.Attributes["OverrideDefault"] != null)
            {
                overrideDefaultLayer = bool.Parse(node.Attributes["OverrideDefault"].Value);
            }
        }
Exemple #2
0
        internal static TourPlace FromXml(XmlNode place)
        {
            TourPlace newPlace = new TourPlace();

            newPlace.name = place.Attributes["Name"].Value;
            newPlace.Type = (ImageSetType)Enum.Parse(typeof(ImageSetType), place.Attributes["DataSetType"].Value);
            if (newPlace.Type == ImageSetType.Sky)
            {
                newPlace.camParams.RA  = Convert.ToDouble(place.Attributes["RA"].Value);
                newPlace.camParams.Dec = Convert.ToDouble(place.Attributes["Dec"].Value);
            }
            else
            {
                newPlace.Lat = Convert.ToDouble(place.Attributes["Lat"].Value);
                newPlace.Lng = Convert.ToDouble(place.Attributes["Lng"].Value);
            }

            newPlace.constellation  = place.Attributes["Constellation"].Value;
            newPlace.Classification = (Classification)Enum.Parse(typeof(Classification), place.Attributes["Classification"].Value);
            newPlace.magnitude      = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            if (place.Attributes["Magnitude"] != null)
            {
                newPlace.magnitude = Convert.ToDouble(place.Attributes["Magnitude"].Value);
            }
            newPlace.AngularSize        = Convert.ToDouble(place.Attributes["AngularSize"].Value);
            newPlace.ZoomLevel          = Convert.ToDouble(place.Attributes["ZoomLevel"].Value);
            newPlace.camParams.Rotation = Convert.ToDouble(place.Attributes["Rotation"].Value);
            newPlace.camParams.Angle    = Convert.ToDouble(place.Attributes["Angle"].Value);
            if (place.Attributes["Opacity"] != null)
            {
                newPlace.camParams.Opacity = Convert.ToSingle(place.Attributes["Opacity"].Value);
            }
            else
            {
                newPlace.camParams.Opacity = 100;
            }

            if (place.Attributes["Target"] != null)
            {
                newPlace.Target = (SolarSystemObjects)Enum.Parse(typeof(SolarSystemObjects), place.Attributes["Target"].Value);
            }

            if (place.Attributes["ViewTarget"] != null)
            {
                newPlace.camParams.ViewTarget = Vector3d.Parse(place.Attributes["ViewTarget"].Value);
            }

            if (place.Attributes["TargetReferenceFrame"] != null)
            {
                newPlace.camParams.TargetReferenceFrame = place.Attributes["TargetReferenceFrame"].Value;
            }

            if (place.Attributes["DomeAlt"] != null)
            {
                newPlace.camParams.DomeAlt = Convert.ToDouble(place.Attributes["DomeAlt"].Value);
            }

            if (place.Attributes["DomeAz"] != null)
            {
                newPlace.camParams.DomeAz = Convert.ToDouble(place.Attributes["DomeAz"].Value);
            }

            XmlNode descriptionNode = place["Description"];

            if (descriptionNode != null)
            {
                newPlace.HtmlDescription = descriptionNode.Value;
            }

            XmlNode backgroundImageSet = place["BackgroundImageSet"];

            if (backgroundImageSet != null)
            {
                XmlNode imageSet = backgroundImageSet["ImageSet"];

                ImageSetHelper ish = ImageSetHelper.FromXMLNode(imageSet);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.backgroundImageSet = Earth3d.ReplacementImageSets[ish.Url];
                }
                else
                {
                    newPlace.backgroundImageSet = ish;
                }
            }

            XmlNode study = place["ImageSet"];

            if (study != null)
            {
                ImageSetHelper ish = ImageSetHelper.FromXMLNode(study);

                if (!String.IsNullOrEmpty(ish.Url) && Earth3d.ReplacementImageSets.ContainsKey(ish.Url))
                {
                    newPlace.studyImageset = Earth3d.ReplacementImageSets[ish.Url];
                }
                else
                {
                    newPlace.studyImageset = ish;
                }
            }
            return(newPlace);
        }
Exemple #3
0
        public ArrayList GetPlaceList()
        {
            if (dataList == null || CheckExpiration())
            {
                dataList = new System.Collections.ArrayList();
                if (dataSetType == DataSetType.Place)
                {
                    DataSetManager.DownloadFile(url, Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt", false, true);


                    TourPlace    place;
                    StreamReader sr = new StreamReader(Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".txt");
                    string       line;
                    while (sr.Peek() >= 0)
                    {
                        line = sr.ReadLine();

                        place = new TourPlace(line, sky);
                        dataList.Add(place);
                    }
                    sr.Close();
                }
                else if (dataSetType == DataSetType.Imageset)
                {
                    string filename = Properties.Settings.Default.CahceDirectory + @"data\places\" + name + ".xml";

                    DataSetManager.DownloadFile(url, filename, false, true);



                    XmlDocument doc = new XmlDocument();
                    doc.Load(filename);

                    if (!Directory.Exists(Properties.Settings.Default.CahceDirectory + @"thumbnails\"))
                    {
                        Directory.CreateDirectory(Properties.Settings.Default.CahceDirectory + @"thumbnails\");
                    }

                    XmlNode imageSets = doc["ImageSets"];
                    if (imageSets == null)
                    {
                        imageSets = doc["Folder"];
                    }

                    foreach (XmlNode imageset in imageSets.ChildNodes)
                    {
                        ImageSetHelper newImageset = ImageSetHelper.FromXMLNode(imageset);
                        if (newImageset != null)
                        {
                            TourPlace newPlace = new TourPlace(newImageset.Name, (newImageset.CenterY), (newImageset.CenterX) / 15, Classification.Unidentified, "Err", ImageSetType.Sky, newImageset.BaseTileDegrees * 10);
                            newPlace.StudyImageset = newImageset;

                            newPlace.ThumbNail = UiTools.LoadThumbnailFromWeb(newImageset.ThumbnailUrl);
                            dataList.Add(newPlace);
                            if (!String.IsNullOrEmpty(newImageset.AltUrl) && !Earth3d.ReplacementImageSets.ContainsKey(newImageset.AltUrl))
                            {
                                Earth3d.ReplacementImageSets.Add(newImageset.AltUrl, newImageset);
                            }
                        }
                    }
                }
            }
            return(dataList);
        }