// Merged layers from Tour Player Alternate universe into the real layer manager layers list
        public static void MergeToursLayers()
        {
            tourLayers = false;
            bool OverWrite = false;
            bool CollisionChecked = false;

            foreach (LayerMap map in allMapsTours.Values)
            {
                if (!allMaps.ContainsKey(map.Name))
                {
                    LayerMap newMap = new LayerMap(map.Name, ReferenceFrames.Custom);
                    newMap.Frame = map.Frame;
                    newMap.LoadedFromTour = true;
                    LayerManager.AllMaps.Add(newMap.Name, newMap);
                }
            }
            ConnectAllChildren();

            foreach (Layer layer in layerListTours.Values)
            {
                if (LayerList.ContainsKey(layer.ID))
                {
                    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(layer.ID, true, false);
                    }
                }

                if (!LayerList.ContainsKey(layer.ID))
                {
                    if (AllMaps.ContainsKey(layer.ReferenceFrame))
                    {
                        LayerList.Add(layer.ID, layer);

                        AllMaps[layer.ReferenceFrame].Layers.Add(layer);
                    }
                }
                else
                {
                    layer.CleanUp();
                }
            }

            layerListTours.Clear();
            allMapsTours.Clear();
            layerMapsTours.Clear();
            LoadTree();
        }
        public static void PurgeLayerMapDeep(LayerMap target, bool topLevel)
        {
            foreach (Layer layer in target.Layers)
            {
                LayerManager.DeleteLayerByID(layer.ID, false, false);
            }

            target.Layers.Clear();

            foreach (LayerMap map in target.ChildMaps.Values)
            {
                PurgeLayerMapDeep(map, false);
            }

            target.ChildMaps.Clear();
            if (topLevel)
            {
                if (!String.IsNullOrEmpty(target.Frame.Parent))
                {
                    if (AllMaps.ContainsKey(target.Frame.Parent))
                    {
                        AllMaps[target.Frame.Parent].ChildMaps.Remove(target.Name);
                    }
                }
                else
                {
                    if (LayerMaps.ContainsKey(target.Name))
                    {
                        LayerMaps.Remove(target.Name);
                    }
                }
            }
            AllMaps.Remove(target.Name);
            version++;
        }
 public void AddChild(LayerMap child)
 {
     child.Parent = this;
     ChildMaps.Add(child.Name, child);
 }
        public static void InitLayers()
        {
            ClearLayers();
            //StockSkyOverlay.StockOverlays.Clear();

            LayerMap iss = null;
            LayerMap ol = null;
            LayerMap l1 = null;
            LayerMap l2 = null;
            if (!TourLayers)
            {
                string[] isstle = new string[0];
                try
                {
                    //This is downloaded now on startup
                    string url = "http://www.worldwidetelescope.org/wwtweb/isstle.aspx";
                    string filename = string.Format(@"{0}data\isstle.txt", Properties.Settings.Default.CahceDirectory);
                    DataSetManager.DownloadFile(url, filename, false, false);

                    isstle = File.ReadAllLines(filename);
                }
                catch
                {
                }

                iss = new LayerMap("ISS", ReferenceFrames.Custom);
                iss.Frame.Epoch = SpaceTimeController.TwoLineDateToJulian("10184.51609218");
                iss.Frame.SemiMajorAxis = 6728829.41;
                iss.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
                iss.Frame.Inclination = 51.6442;
                iss.Frame.LongitudeOfAscendingNode = 147.0262;
                iss.Frame.Eccentricity = .0009909;
                iss.Frame.MeanAnomolyAtEpoch = 325.5563;
                iss.Frame.MeanDailyMotion = 360 * 15.72172655;
                iss.Frame.ArgumentOfPeriapsis = 286.4623;
                iss.Frame.Scale = 1;
                iss.Frame.SemiMajorAxisUnits = AltUnits.Meters;
                iss.Frame.MeanRadius = 130;
                iss.Frame.Oblateness = 0;
                iss.Frame.ShowOrbitPath = false;
                if (isstle.Length > 1)
                {
                    try
                    {
                        iss.Frame.FromTLE(isstle[0], isstle[1], 398600441800000);
                    }
                    catch
                    {
                    }
                }
                iss.Enabled = true;
            }
            ol = new LayerMap("Observing Location", ReferenceFrames.Custom);
            ol.Frame.ReferenceFrameType = ReferenceFrameTypes.FixedSherical;
            ol.Frame.ObservingLocation = true;
            ol.Frame.Lat = SpaceTimeController.Location.Lat;
            ol.Frame.Lng = SpaceTimeController.Location.Lng;
            ol.Frame.Altitude = SpaceTimeController.Altitude;
            ol.Frame.SystemGenerated = true;

            l1 = new LayerMap("Sun-Earth L1 Point", ReferenceFrames.Custom);
            l1.Frame.ReferenceFrameType = ReferenceFrameTypes.Synodic;
            l1.Frame.Translation = new Vector3d(-1.5e6, 0.0, 0.0);
            l1.Enabled = false;
            l1.Frame.SystemGenerated = true;

            l2 = new LayerMap("Sun-Earth L2 Point", ReferenceFrames.Custom);
            l2.Frame.ReferenceFrameType = ReferenceFrameTypes.Synodic;
            l2.Frame.Translation = new Vector3d(1.5e6, 0.0, 0.0);
            l2.Enabled = false;
            l2.Frame.SystemGenerated = true;

            LayerMaps.Add("Sun", new LayerMap("Sun", ReferenceFrames.Sun));
            LayerMaps["Sun"].AddChild(new LayerMap("Mercury", ReferenceFrames.Mercury));
            LayerMaps["Sun"].AddChild(new LayerMap("Venus", ReferenceFrames.Venus));
            LayerMaps["Sun"].AddChild(new LayerMap("Earth", ReferenceFrames.Earth));
            LayerMaps["Sun"].ChildMaps["Earth"].Layers.Add(new SkyOverlays(SkyOverlaysType.Earth));
            LayerMaps["Sun"].ChildMaps["Earth"].AddChild(new LayerMap("Moon", ReferenceFrames.Moon));

            if (!TourLayers)
            {
                 LayerMaps["Sun"].ChildMaps["Earth"].AddChild(iss);
            }
            LayerMaps["Sun"].ChildMaps["Earth"].AddChild(ol);
            LayerMaps["Sun"].ChildMaps["Earth"].AddChild(l1);
            LayerMaps["Sun"].ChildMaps["Earth"].AddChild(l2);

            LayerMaps["Sun"].AddChild(new LayerMap("Mars", ReferenceFrames.Mars));
            LayerMaps["Sun"].AddChild(new LayerMap("Jupiter", ReferenceFrames.Jupiter));
            LayerMaps["Sun"].ChildMaps["Jupiter"].AddChild(new LayerMap("Io", ReferenceFrames.Io));
            LayerMaps["Sun"].ChildMaps["Jupiter"].AddChild(new LayerMap("Europa", ReferenceFrames.Europa));
            LayerMaps["Sun"].ChildMaps["Jupiter"].AddChild(new LayerMap("Ganymede", ReferenceFrames.Ganymede));
            LayerMaps["Sun"].ChildMaps["Jupiter"].AddChild(new LayerMap("Callisto", ReferenceFrames.Callisto));
            LayerMaps["Sun"].AddChild(new LayerMap("Saturn", ReferenceFrames.Saturn));
            LayerMaps["Sun"].AddChild(new LayerMap("Uranus", ReferenceFrames.Uranus));
            LayerMaps["Sun"].AddChild(new LayerMap("Neptune", ReferenceFrames.Neptune));
            LayerMaps["Sun"].AddChild(new LayerMap("Pluto", ReferenceFrames.Pluto));

            AddMoons();

            LayerMaps.Add("Sky", new LayerMap("Sky", ReferenceFrames.Sky));

            LayerMaps["Sky"].Layers.Add(new SkyOverlays(SkyOverlaysType.Sky));
            LayerMaps["Sky"].Layers.Add(new SkyOverlays(SkyOverlaysType.Sky2d));
            LayerMaps["Sky"].Layers.Add(new SkyOverlays(SkyOverlaysType.SolarSystem));
            LayerMaps["Sky"].Open = true;
            LayerMaps["Sun"].Open = true;

            LayerMaps.Add("Sandbox", new LayerMap("Sandbox", ReferenceFrames.Sandbox));

            LayerMaps.Add("Dome", new LayerMap("Dome", ReferenceFrames.Identity));
            LayerMaps["Dome"].Layers.Add(new SkyOverlays(SkyOverlaysType.Dome));
            LayerMaps["Dome"].Open = true;

            AllMaps.Clear();

            AddAllMaps(LayerMaps, null);
            if (!TourLayers)
            {
                AddIss();
            }
            version++;
            LoadTree();
        }
        private void MakeLayerGroup(string name)
        {
            LayerMap target = (LayerMap)layerTree.SelectedNode.Tag;
            ReferenceFrame frame = new ReferenceFrame();
            frame.Name = name;
            frame.Reference = ReferenceFrames.Identity;
            LayerMap newMap = new LayerMap(frame.Name, ReferenceFrames.Identity);
            newMap.Frame = frame;
            newMap.Frame.SystemGenerated = false;
            target.AddChild(newMap);

            newMap.Frame.Parent = target.Name;
            AllMaps.Add(frame.Name, newMap);
            version++;
        }
        void newMenu_Click(object sender, EventArgs e)
        {
            LayerMap target = (LayerMap)layerTree.SelectedNode.Tag;
            ReferenceFrame frame = new ReferenceFrame();
            frame.SystemGenerated = false;
            if (FrameWizard.ShowWizard(frame) == DialogResult.OK)
            {
                LayerMap newMap = new LayerMap(frame.Name, ReferenceFrames.Custom);
                if (!AllMaps.ContainsKey(frame.Name))
                {
                    newMap.Frame = frame;

                    target.AddChild(newMap);
                    newMap.Frame.Parent = target.Name;
                    AllMaps.Add(frame.Name, newMap);
                    version++;
                    LoadTreeLocal();
                }
            }
        }
        private void ImportTLEFile(string filename)
        {
            string name = filename.Substring(filename.LastIndexOf("\\") + 1);
            name = name.Substring(0, name.LastIndexOf("."));

            MakeLayerGroup(name);

            string[] data = File.ReadAllLines(filename);

            for (int i = 0; i < data.Length; i += 3)
            {
                LayerMap orbit = new LayerMap(data[i].Trim(), ReferenceFrames.Custom);
                orbit.Frame.Oblateness = 0;
                orbit.Frame.ShowOrbitPath = true;
                orbit.Frame.ShowAsPoint = true;
                orbit.Frame.Epoch = SpaceTimeController.TwoLineDateToJulian("10184.51609218");
                orbit.Frame.SemiMajorAxis = 6728829.41;
                orbit.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
                orbit.Frame.Inclination = 51.6442;
                orbit.Frame.LongitudeOfAscendingNode = 147.0262;
                orbit.Frame.Eccentricity = .0009909;
                orbit.Frame.MeanAnomolyAtEpoch = 325.5563;
                orbit.Frame.MeanDailyMotion = 360 * 15.72172655;
                orbit.Frame.ArgumentOfPeriapsis = 286.4623;
                orbit.Frame.Scale = 1;
                orbit.Frame.SemiMajorAxisUnits = AltUnits.Meters;
                orbit.Frame.MeanRadius = 10;
                orbit.Frame.Oblateness = 0;
                orbit.Frame.FromTLE(data[i + 1], data[i + 2], 398600441800000);
                if (!AllMaps[name].ChildMaps.ContainsKey(data[i].Trim()))
                {
                    AllMaps[name].AddChild(orbit);
                }
            }
            version++;
        }
        public static bool CreateReferenceFrame(string name, string parent, string xml)
        {
            if (!AllMaps.ContainsKey(name) && AllMaps.ContainsKey(parent))
            {
                LayerMap target = AllMaps[parent];
                ReferenceFrame frame = new ReferenceFrame();
                frame.Name = name;

                if (!string.IsNullOrEmpty(xml))
                {
                    if (!frame.SetProps(xml))
                    {
                        return false;
                    }
                }

                LayerMap newMap = new LayerMap(frame.Name, ReferenceFrames.Custom);
                newMap.Frame = frame;
                target.AddChild(newMap);
                newMap.Frame.Parent = target.Name;
                AllMaps.Add(frame.Name, newMap);

                version++;
                LoadTree();
                return true;
            }
            return false;
        }
        private static void AddMoons()
        {
            string filename = Properties.Settings.Default.CahceDirectory + "\\data\\moons.txt";
            DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?Q=moons", filename, false, true);

            string[] data = File.ReadAllLines(filename);

            bool first = true;
            foreach (string line in data)
            {
                if (first)
                {
                    first = false;
                    continue;
                }
                string[] parts = line.Split(new char[] { '\t' });
                string planet = parts[0];
                LayerMap frame = new LayerMap(parts[2], ReferenceFrames.Custom);
                frame.Frame.SystemGenerated = true;
                frame.Frame.Epoch = double.Parse(parts[1]);
                frame.Frame.SemiMajorAxis = double.Parse(parts[3]) * 1000;
                frame.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
                frame.Frame.Inclination = double.Parse(parts[7]);
                frame.Frame.LongitudeOfAscendingNode = double.Parse(parts[8]);
                frame.Frame.Eccentricity = double.Parse(parts[4]);
                frame.Frame.MeanAnomolyAtEpoch = double.Parse(parts[6]);
                frame.Frame.MeanDailyMotion = double.Parse(parts[9]);
                frame.Frame.ArgumentOfPeriapsis = double.Parse(parts[5]);
                frame.Frame.Scale = 1;
                frame.Frame.SemiMajorAxisUnits = AltUnits.Meters;
                frame.Frame.MeanRadius = double.Parse(parts[16]) * 1000;
                frame.Frame.RotationalPeriod = double.Parse(parts[17]);
                frame.Frame.ShowAsPoint = false;
                frame.Frame.ShowOrbitPath = true;
                frame.Frame.RepresentativeColor = Color.LightBlue;
                frame.Frame.Oblateness = 0;

                LayerMaps["Sun"].ChildMaps[planet].AddChild(frame);
            }
        }
        string GetMpc(string id)
        {
            WebClient client = new WebClient();

            string data = client.DownloadString("http://www.minorplanetcenter.net/db_search/show_object?object_id=" + id);

            int startform = data.IndexOf("show-orbit-button");

            int lastForm = data.IndexOf("/form", startform);

            string formpart = data.Substring(startform, lastForm - startform);

            string name = id;

            LayerMap orbit = new LayerMap(name.Trim(), ReferenceFrames.Custom);
            orbit.Frame.Oblateness = 0;
            orbit.Frame.ShowOrbitPath = true;
            orbit.Frame.ShowAsPoint = true;

            orbit.Frame.Epoch = SpaceTimeController.UtcToJulian(DateTime.Parse(GetValueByID(formpart, "epoch").Substring(0,10)));
            orbit.Frame.SemiMajorAxis = double.Parse(GetValueByID(formpart, "a")) * UiTools.KilometersPerAu * 1000;
            orbit.Frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
            orbit.Frame.Inclination = double.Parse(GetValueByID(formpart, "incl"));
            orbit.Frame.LongitudeOfAscendingNode = double.Parse(GetValueByID(formpart, "node"));
            orbit.Frame.Eccentricity = double.Parse(GetValueByID(formpart, "e"));
            orbit.Frame.MeanAnomolyAtEpoch = double.Parse(GetValueByID(formpart, "m"));
            orbit.Frame.MeanDailyMotion = CAAElliptical.MeanMotionFromSemiMajorAxis(double.Parse(GetValueByID(formpart, "a")));
            orbit.Frame.ArgumentOfPeriapsis = double.Parse(GetValueByID(formpart, "peri"));
            orbit.Frame.Scale = 1;
            orbit.Frame.SemiMajorAxisUnits = AltUnits.Meters;
            orbit.Frame.MeanRadius = 10;
            orbit.Frame.Oblateness = 0;

            if (!AllMaps["Sun"].ChildMaps.ContainsKey(name.Trim()))
            {
                AllMaps["Sun"].AddChild(orbit);
            }

            AllMaps.Add(orbit.Name, orbit);

            orbit.Frame.Parent = "Sun";

            LoadTree();

            return null;
        }
 internal static bool CreateLayerGroup(string name, string referenceFrame)
 {
     LayerMap parent = AllMaps[referenceFrame];
     if (parent == null)
     {
         return false;
     }
     try
     {
         ReferenceFrame frame = new ReferenceFrame();
         frame.Name = name;
         frame.Reference = ReferenceFrames.Identity;
         LayerMap newMap = new LayerMap(frame.Name, ReferenceFrames.Identity);
         newMap.Frame = frame;
         newMap.Frame.SystemGenerated = false;
         parent.AddChild(newMap);
         newMap.Frame.Parent = parent.Name;
         AllMaps.Add(frame.Name, newMap);
         LoadTree();
         version++;
         return true;
     }
     catch
     {
         return false;
     }
 }
        public void AddMaps(LayerMap map, List<Guid> list)
        {
            foreach(var layer in map.Layers)
            {
                list.Add(layer.ID);
            }

            foreach(var child in map.ChildMaps.Values)
            {
                AddMaps(child,list);
            }
        }
        public static LayerContainer FromXml(string filename, string parentFrame, bool referenceFrameRightClick)
        {
            var newDoc = new LayerContainer();
            newDoc.filename = filename;
            var doc = new XmlDocument();
            doc.Load(filename);

            XmlNode root = doc["LayerContainer"];
            newDoc.id = root.Attributes["ID"].Value;

            XmlNode Layers = root["Layers"];

            var loadAtNewParent = false;
            if (!referenceFrameRightClick || Layers.ChildNodes.Count != 1)
            {
                XmlNode Frames = root["ReferenceFrames"];

                if (Frames != null)
                {
                    foreach (XmlNode frame in Frames)
                    {
                        var newFrame = new ReferenceFrame();
                        newFrame.InitializeFromXml(frame);

                        if (!LayerManager.AllMaps.ContainsKey(newFrame.Name))
                        {
                            var map = new LayerMap(newFrame.Name, ReferenceFrames.Custom);
                            map.Frame = newFrame;
                            LayerManager.AllMaps.Add(newFrame.Name, map);
                        }
                    }
                    LayerManager.ConnectAllChildren();
                    LayerManager.LoadTree();
                }
            }
            else
            {
                loadAtNewParent = true;
            }

            if (Layers != null)
            {
                foreach (XmlNode layer in Layers)
                {
                    var newLayer = Layer.FromXml(layer, true);
                    var fileName = newDoc.WorkingDirectory + string.Format("{0}.txt", newLayer.ID);

                    if (LayerManager.LayerList.ContainsKey(newLayer.ID) && newLayer.ID != ISSLayer.ISSGuid)
                    {
                        if (!newDoc.CollisionChecked)
                        {
                            if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                newDoc.OverWrite = true;
                            }
                            else
                            {
                                newDoc.OverWrite = false;

                            }
                            newDoc.CollisionChecked = true;
                        }

                        if (newDoc.OverWrite)
                        {
                            LayerManager.DeleteLayerByID(newLayer.ID, true, false);
                        }
                    }

                    newLayer.LoadData(fileName);

                    if (loadAtNewParent)
                    {
                        newLayer.ReferenceFrame = parentFrame;
                    }

                    LayerManager.Add(newLayer, false);
                    newDoc.LastLoadedLayer = newLayer;

                }
                LayerManager.LoadTree();
            }

            newDoc.tourDirty = 0;
            return newDoc;
        }
示例#14
0
        public static TourDocument FromXml(string filename)
        {
            var newTour = new TourDocument();
            newTour.filename = filename;
            var doc = new XmlDocument();
            doc.Load(filename);

            XmlNode root = doc["Tour"];

            newTour.id = root.Attributes["ID"].Value;
            newTour.Title = root.Attributes["Title"].Value;
            newTour.Author = root.Attributes["Author"].Value;

            if (root.Attributes["Descirption"] != null)
            {
                newTour.Description = root.Attributes["Descirption"].Value;
            }

            if (root.Attributes["Description"] != null)
            {
                newTour.Description = root.Attributes["Description"].Value;
            }

            if (root.Attributes["AuthorEmail"] != null)
            {
                newTour.authorEmail = root.Attributes["AuthorEmail"].Value;
            }

            if (root.Attributes["Keywords"] != null)
            {
                newTour.Keywords = root.Attributes["Keywords"].Value;
            }

            if (root.Attributes["OrganizationName"] != null)
            {
                newTour.OrgName = root.Attributes["OrganizationName"].Value;
            }

            if (root.Attributes["DomeMode"] != null)
            {
                newTour.DomeMode = bool.Parse(root.Attributes["DomeMode"].Value);
            }

            newTour.organizationUrl = root.Attributes["OrganizationUrl"].Value;
            newTour.level = (UserLevel)Enum.Parse(typeof(UserLevel), root.Attributes["UserLevel"].Value);
            newTour.type = (Classification)Enum.Parse(typeof(Classification), root.Attributes["Classification"].Value);
            newTour.taxonomy = root.Attributes["Taxonomy"].Value;

            var timeLineTour = false;
            if (root.Attributes["TimeLineTour"] != null)
            {
                timeLineTour = bool.Parse(root.Attributes["TimeLineTour"].Value);
            }

            XmlNode TourStops = null;

            if (timeLineTour)
            {
                TourStops = root["TimeLineTourStops"];
            }
            else
            {
                TourStops = root["TourStops"];
            }

            foreach (XmlNode tourStop in TourStops)
            {
                newTour.AddTourStop(TourStop.FromXml(newTour, tourStop));
            }

            XmlNode Frames = root["ReferenceFrames"];

            if (Frames != null)
            {
                foreach (XmlNode frame in Frames)
                {
                    var newFrame = new ReferenceFrame();
                    newFrame.InitializeFromXml(frame);
                    if (!LayerManager.AllMaps.ContainsKey(newFrame.Name))
                    {
                        var map = new LayerMap(newFrame.Name, ReferenceFrames.Custom);
                        map.Frame = newFrame;
                        map.LoadedFromTour = true;
                        LayerManager.AllMaps.Add(newFrame.Name, map);
                    }
                }
                LayerManager.ConnectAllChildren();
                LayerManager.LoadTree();
            }

            XmlNode Layers = root["Layers"];

            if (Layers != null)
            {
                foreach (XmlNode layer in Layers)
                {
                    var newLayer = Layer.FromXml(layer, true);
                    var fileName = newTour.WorkingDirectory + string.Format("{0}.txt", newLayer.ID);

                    // Overwite ISS layer if in a tour using the authored ISS details
                    if (LayerManager.LayerList.ContainsKey(newLayer.ID) && newLayer.ID == ISSLayer.ISSGuid)
                    {
                        LayerManager.DeleteLayerByID(newLayer.ID, true, false);
                    }

                    // Ask about merging other layers.
                    if (LayerManager.LayerList.ContainsKey(newLayer.ID) && newLayer.ID != ISSLayer.ISSGuid)
                    {
                        if (!newTour.CollisionChecked)
                        {
                            if (UiTools.ShowMessageBox(Language.GetLocalizedText(958, "There are layers with the same name. Overwrite existing layers?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                newTour.OverWrite = true;
                            }
                            else
                            {
                                newTour.OverWrite = false;

                            }
                            newTour.CollisionChecked = true;
                        }

                        if (newTour.OverWrite)
                        {
                            LayerManager.DeleteLayerByID(newLayer.ID, true, false);
                        }
                    }

                    try
                    {
                        newLayer.LoadedFromTour = true;
                        newLayer.LoadData(fileName);
                        LayerManager.Add(newLayer, false);
                    }
                    catch
                    {
                    }
                }
                LayerManager.LoadTree();
            }

            if (File.Exists(newTour.WorkingDirectory + "Author.png"))
            {
                newTour.authorImage = UiTools.LoadBitmap(newTour.WorkingDirectory + "Author.png");
            }

            newTour.tourDirty = 0;
            return newTour;
        }
示例#15
0
        public void MergeTourStopsFromXml(string filename)
        {
            var doc = new XmlDocument();
            doc.Load(filename);

            XmlNode root = doc["Tour"];

            var timeLineTour = false;
            if (root.Attributes["TimeLineTour"] != null)
            {
                timeLineTour = bool.Parse(root.Attributes["TimeLineTour"].Value);
            }

            XmlNode TourStops = null;

            if (timeLineTour)
            {
                TourStops = root["TimeLineTourStops"];
            }
            else
            {
                TourStops = root["TourStops"];
            }

            foreach (XmlNode tourStop in TourStops)
            {
                currentTourstopIndex++;
                InsertTourStop(TourStop.FromXml(this, tourStop));
            }

            XmlNode Frames = root["ReferenceFrames"];

            if (Frames != null)
            {
                foreach (XmlNode frame in Frames)
                {
                    var newFrame = new ReferenceFrame();
                    newFrame.InitializeFromXml(frame);
                    if (!LayerManager.AllMaps.ContainsKey(newFrame.Name))
                    {
                        var map = new LayerMap(newFrame.Name, ReferenceFrames.Custom);
                        map.Frame = newFrame;
                        LayerManager.AllMaps.Add(newFrame.Name, map);
                    }
                }
                LayerManager.ConnectAllChildren();
                LayerManager.LoadTree();
            }

            XmlNode Layers = root["Layers"];

            if (Layers != null)
            {
                foreach (XmlNode layer in Layers)
                {
                    var newLayer = Layer.FromXml(layer, true);
                    var fileName = WorkingDirectory + string.Format("{0}.txt", newLayer.ID);

                    newLayer.LoadData(fileName);
                    LayerManager.Add(newLayer, false);

                }
                LayerManager.LoadTree();
            }
        }