public LayerManager()
 {
     InitializeComponent();
     SetUiStrings();
     master = this;
 }
Example #2
0
        private void ShowLayersWindow()
        {
            if (layerManager == null)
            {
                layerManager = new LayerManager();
                layerManager.Owner = this;
            }

            Rectangle rectContext = contextPanel.Bounds;
            Rectangle rectCurrentTab = currentTab.Bounds;

            Point pnt = PointToScreen(new Point(0, (ClientRectangle.Bottom - contextPanel.Height)));
            Point pntTab = rectCurrentTab.Location;

            if (!Properties.Settings.Default.TranparentWindows)
            {
                pntTab = PointToScreen(pntTab);
            }
            layerManager.Location = new Point(pnt.X, pntTab.Y + rectCurrentTab.Height + 1);
            layerManager.Height = pnt.Y - layerManager.Top;
            layerManager.Show();
        }
 private void LayerManager_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing)
     {
         Earth3d.MainWindow.ShowLayersWindows = false;
     }
     master = null;
 }
Example #4
0
        public void UpdateSlideStates()
        {
            bool slideChanging = false;


            if (!ProjectorServer)
            {
                TimeSpan slideElapsedTime = SpaceTimeController.MetaNow - slideStartTime;

                if ((slideElapsedTime > tour.CurrentTourStop.Duration && playing) || (slideElapsedTime.TotalSeconds > PreRollTime && PreRoll))
                {
                    NextSlide();
                    slideChanging = true;
                }
                slideElapsedTime = SpaceTimeController.MetaNow - slideStartTime;

                tour.CurrentTourStop.TweenPosition = Math.Min(1, (float)(slideElapsedTime.TotalMilliseconds / tour.CurrentTourStop.Duration.TotalMilliseconds));
            }
            else
            {
                try
                {
                    if (tour.CurrentTourStop != null)
                    {
                        if (lastSlideIndex != LayerManager.CurrentSlideID)
                        {
                            slideChanging             = true;
                            lastSlideIndex            = LayerManager.CurrentSlideID;
                            tour.CurrentTourstopIndex = LayerManager.CurrentSlideID;
                            if (tour.CurrentTourStop.MasterSlide)
                            {
                                currentMasterSlide = null;
                            }
                            else
                            {
                                currentMasterSlide = tour.GetMasterSlideForIndex(tour.CurrentTourstopIndex);
                            }
                            LayerManager.SetVisibleLayerList(tour.CurrentTourStop.Layers);
                        }
                        tour.CurrentTourStop.TweenPosition = LayerManager.SlideTweenPosition;
                    }
                }
                catch
                {
                }
                onTarget = true;
            }


            tour.CurrentTourStop.FaderOpacity = 0;

            if (tour.CurrentTourStop != null)
            {
                Tile.fastLoad = false;
                double elapsedSeconds = tour.CurrentTourStop.TweenPosition * tour.CurrentTourStop.Duration.TotalSeconds;
                if (slideChanging)
                {
                    Earth3d.MainWindow.CrossFadeFrame = false;
                }

                switch (tour.CurrentTourStop.Transition)
                {
                case TransitionType.Slew:
                    tour.CurrentTourStop.FaderOpacity = 0;
                    Earth3d.MainWindow.CrossFadeFrame = false;
                    break;

                case TransitionType.CrossCut:
                {
                    if (slideChanging)
                    {
                        Tile.fastLoad          = true;
                        Tile.fastLoadAutoReset = false;
                    }
                    if (elapsedSeconds < (elapsedSeconds - tour.CurrentTourStop.TransitionHoldTime))
                    {
                        Earth3d.MainWindow.CrossFadeFrame = true;
                        tour.CurrentTourStop.FaderOpacity = 1;
                    }
                    else
                    {
                        tour.CurrentTourStop.FaderOpacity = 0;
                        Earth3d.MainWindow.CrossFadeFrame = false;
                    }
                }
                break;

                case TransitionType.CrossFade:
                {
                    Earth3d.MainWindow.CrossFadeFrame = true;
                    double opacity = Math.Max(0, 1 - Math.Min(1, (elapsedSeconds - tour.CurrentTourStop.TransitionHoldTime) / tour.CurrentTourStop.TransitionTime));
                    tour.CurrentTourStop.FaderOpacity = (float)opacity;
                    if (slideChanging)
                    {
                        Tile.fastLoad          = true;
                        Tile.fastLoadAutoReset = false;
                    }
                }
                break;

                case TransitionType.FadeOutIn:
                case TransitionType.FadeIn:
                {
                    Earth3d.MainWindow.CrossFadeFrame = false;
                    double opacity = Math.Max(0, 1 - Math.Min(1, (elapsedSeconds - tour.CurrentTourStop.TransitionHoldTime) / tour.CurrentTourStop.TransitionTime));
                    tour.CurrentTourStop.FaderOpacity = (float)opacity;
                }
                break;

                case TransitionType.FadeOut:
                    Earth3d.MainWindow.CrossFadeFrame = false;
                    break;

                default:
                    break;
                }

                if (!tour.CurrentTourStop.IsLinked && tour.CurrentTourstopIndex < (tour.TourStops.Count - 1))
                {
                    TransitionType nextTrans     = tour.TourStops[tour.CurrentTourstopIndex + 1].Transition;
                    double         nextTransTime = tour.TourStops[tour.CurrentTourstopIndex + 1].TransitionOutTime;


                    switch (nextTrans)
                    {
                    case TransitionType.FadeOut:
                    case TransitionType.FadeOutIn:
                    {
                        if (tour.CurrentTourStop.FaderOpacity == 0)
                        {
                            Earth3d.MainWindow.CrossFadeFrame = false;
                            double opacity = Math.Max(0, 1 - Math.Min(1, (tour.CurrentTourStop.Duration.TotalSeconds - elapsedSeconds) / nextTransTime));
                            tour.CurrentTourStop.FaderOpacity = (float)opacity;
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Example #5
0
        public void Render(Earth3d window)
        {
            window.SetupMatricesOverlays();
            window.RenderContext11.DepthStencilMode = DepthStencilMode.Off;


            if (tour == null || tour.CurrentTourStop == null)
            {
                return;
            }

            if (ProjectorServer)
            {
                overlayBlend.State = true;
            }

            if (!onTarget && !ProjectorServer)
            {
                slideStartTime = SpaceTimeController.MetaNow;
                if (Earth3d.MainWindow.OnTarget(Tour.CurrentTourStop.Target))
                {
                    onTarget                 = true;
                    overlayBlend.State       = !Tour.CurrentTourStop.FadeInOverlays;
                    overlayBlend.TargetState = true;

                    if (!PreRoll)
                    {
                        if (tour.CurrentTourStop.MusicTrack != null)
                        {
                            tour.CurrentTourStop.MusicTrack.Play();
                        }

                        if (tour.CurrentTourStop.VoiceTrack != null)
                        {
                            tour.CurrentTourStop.VoiceTrack.Play();
                        }

                        foreach (Overlay overlay in tour.CurrentTourStop.Overlays)
                        {
                            overlay.Play();
                        }
                    }

                    LayerManager.SetVisibleLayerList(tour.CurrentTourStop.Layers);


                    if (tour.CurrentTourStop.KeyFramed)
                    {
                        tour.CurrentTourStop.KeyFrameMover.CurrentDateTime = tour.CurrentTourStop.StartTime;
                        tour.CurrentTourStop.KeyFrameMover.CurrentPosition = tour.CurrentTourStop.Target.CamParams;
                        tour.CurrentTourStop.KeyFrameMover.MoveTime        = (double)(tour.CurrentTourStop.Duration.TotalMilliseconds / 1000.0);
                        Earth3d.MainWindow.Mover = tour.CurrentTourStop.KeyFrameMover;
                    }
                    else if (tour.CurrentTourStop.EndTarget != null && tour.CurrentTourStop.EndTarget.ZoomLevel != -1)
                    {
                        if (tour.CurrentTourStop.Target.Type == ImageSetType.SolarSystem)
                        {
                            tour.CurrentTourStop.Target.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.StartTime));
                            tour.CurrentTourStop.EndTarget.UpdatePlanetLocation(SpaceTimeController.UtcToJulian(tour.CurrentTourStop.EndTime));
                        }


                        Earth3d.MainWindow.Mover = new ViewMoverKenBurnsStyle(tour.CurrentTourStop.Target.CamParams, tour.CurrentTourStop.EndTarget.CamParams, tour.CurrentTourStop.Duration.TotalMilliseconds / 1000.0, tour.CurrentTourStop.StartTime, tour.CurrentTourStop.EndTime, tour.CurrentTourStop.InterpolationType);
                    }

                    Settings.TourSettings           = tour.CurrentTourStop;
                    SpaceTimeController.Now         = tour.CurrentTourStop.StartTime;
                    SpaceTimeController.SyncToClock = false;
                }
            }

            if (currentMasterSlide != null)
            {
                foreach (Overlay overlay in currentMasterSlide.Overlays)
                {
                    overlay.TweenFactor = 1f;

                    overlay.Draw3D(window.RenderContext11, 1.0f, false);
                }
            }



            if (onTarget || ProjectorServer)
            {
                foreach (Overlay overlay in tour.CurrentTourStop.Overlays)
                {
                    if (!Tour.CurrentTourStop.KeyFramed || (overlay.Animate && overlay.AnimationTarget == null))
                    {
                        overlay.TweenFactor = (float)CameraParameters.EaseCurve(tour.CurrentTourStop.TweenPosition, overlay.InterpolationType == InterpolationType.Default ? tour.CurrentTourStop.InterpolationType : overlay.InterpolationType);
                    }
                    overlay.Draw3D(window.RenderContext11, overlayBlend.Opacity, false);
                }
            }
        }
Example #6
0
        public void MergeTourStopsFromXml(string filename)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);


            XmlNode root = doc["Tour"];


            bool 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)
                {
                    ReferenceFrame newFrame = new ReferenceFrame();
                    newFrame.InitializeFromXml(frame);
                    if (!LayerManager.AllMaps.ContainsKey(newFrame.Name))
                    {
                        LayerMap 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)
                {
                    Layer  newLayer = Layer.FromXml(layer, true);
                    string fileName = WorkingDirectory + string.Format("{0}.txt", newLayer.ID.ToString());

                    newLayer.LoadData(fileName);
                    LayerManager.Add(newLayer, false);
                }
                LayerManager.LoadTree();
            }
        }
Example #7
0
        public static TourDocument FromXml(string filename)
        {
            TourDocument newTour = new TourDocument();

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

            doc.Load(filename);


            XmlNode root = doc["Tour"];


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

            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.ToString();
            newTour.level           = (UserLevel)Enum.Parse(typeof(UserLevel), root.Attributes["UserLevel"].Value.ToString());
            newTour.type            = (Classification)Enum.Parse(typeof(Classification), root.Attributes["Classification"].Value.ToString());
            newTour.taxonomy        = root.Attributes["Taxonomy"].Value.ToString();

            bool 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)
                {
                    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.Add(newFrame.Name, map);
                    }
                }
                LayerManager.ConnectAllChildren();
                LayerManager.LoadTree();
            }

            XmlNode Layers = root["Layers"];

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

                    // 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"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.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);
        }
Example #8
0
        public static LayerContainer FromXml(string filename, string parentFrame, bool referenceFrameRightClick)
        {
            LayerContainer newDoc = new LayerContainer();

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

            doc.Load(filename);

            XmlNode root = doc["LayerContainer"];

            newDoc.id = root.Attributes["ID"].Value.ToString();

            XmlNode Layers = root["Layers"];

            bool loadAtNewParent = false;

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

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

                        if (!LayerManager.AllMaps.ContainsKey(newFrame.Name))
                        {
                            LayerMap 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)
                {
                    Layer  newLayer = Layer.FromXml(layer, true);
                    string fileName = newDoc.WorkingDirectory + string.Format("{0}.txt", newLayer.ID.ToString());


                    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"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.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);
        }