Пример #1
0
        public static Place FromIPlace(IPlace place)
        {
            Place newPlace = new Place();

            if (place.BackgroundImageSet != null)
            {
                newPlace.backgroundImageSetField          = new PlaceBackgroundImageSet();
                newPlace.backgroundImageSetField.ImageSet = ImageSet.FromIImage(place.BackgroundImageSet);
            }
            if (place.StudyImageset != null)
            {
                newPlace.foregroundImageSetField          = new PlaceForegroundImageSet();
                newPlace.foregroundImageSetField.ImageSet = ImageSet.FromIImage(place.StudyImageset);
            }
            newPlace.CamParams = place.CamParams;

            string names = "";
            string delim = "";

            foreach (string name in place.Names)
            {
                names += delim;
                names += name;
                delim  = ";";
            }
            newPlace.Name           = names;
            newPlace.Classification = place.Classification;
            newPlace.classificationFieldSpecified = true;
            newPlace.Type          = place.Type;
            newPlace.Constellation = place.Constellation;
            newPlace.Magnitude     = place.Magnitude;
            newPlace.Distance      = place.Distance;
            newPlace.AngularSize   = place.ZoomLevel;
            newPlace.anglularSizeFieldSpecified = true;
            newPlace.Url       = place.Url;
            newPlace.Thumbnail = place.Thumbnail;
            newPlace.Target    = place.Target;
            newPlace.Tag       = place.Tag;
            if (place.Type == ImageSetType.Sky)
            {
                newPlace.raFieldSpecified  = true;
                newPlace.decFieldSpecified = true;
            }
            else
            {
                newPlace.latFieldSpecified = true;
                newPlace.lngFieldSpecified = true;
            }
            return(newPlace);
        }
Пример #2
0
 internal void UpdateList()
 {
     stackList.Clear();
     if (Earth3d.MainWindow.CurrentImageSet != null)
     {
         stackList.Add((IThumbnail)ImageSet.FromIImage(Earth3d.MainWindow.CurrentImageSet));
     }
     foreach (ImageSet set in Earth3d.MainWindow.ImageStackList)
     {
         stackList.Add((IThumbnail)ImageSet.FromIImage(set));
     }
     if (Earth3d.MainWindow.StudyImageset != null)
     {
         stackList.Add((IThumbnail)ImageSet.FromIImage(Earth3d.MainWindow.StudyImageset));
     }
 }
Пример #3
0
        static public ImageSet FromIImage(IImageSet imageset)
        {
            if (imageset == null)
            {
                return(null);
            }
            ImageSet  newset      = new ImageSet();
            IImageSet newImageset = newset;

            newImageset.BandPass        = imageset.BandPass;
            newImageset.BaseLevel       = imageset.BaseLevel;
            newImageset.BaseTileDegrees = imageset.BaseTileDegrees;
            newImageset.BottomsUp       = imageset.BottomsUp;
            newImageset.CenterX         = imageset.CenterX;
            newImageset.CenterY         = imageset.CenterY;
            newImageset.CreditsText     = imageset.CreditsText;
            newImageset.CreditsUrl      = imageset.CreditsUrl;
            newImageset.DataSetType     = imageset.DataSetType;
            newImageset.DefaultSet      = imageset.DefaultSet;
            newImageset.ElevationModel  = imageset.ElevationModel;
            newImageset.Extension       = imageset.Extension;
            newImageset.Generic         = imageset.Generic;
            newImageset.ImageSetID      = imageset.ImageSetID;
            newImageset.Levels          = imageset.Levels;
            newImageset.Matrix          = imageset.Matrix;
            newImageset.Mercator        = imageset.Mercator;
            newImageset.Name            = imageset.Name;
            newImageset.OffsetX         = imageset.OffsetX;
            newImageset.OffsetY         = imageset.OffsetY;
            newImageset.Projection      = imageset.Projection;
            newImageset.QuadTreeTileMap = imageset.QuadTreeTileMap;
            newImageset.Rotation        = imageset.Rotation;
            newImageset.Sparse          = imageset.Sparse;
            newImageset.ThumbnailUrl    = imageset.ThumbnailUrl;
            newImageset.Url             = imageset.Url;
            newImageset.WidthFactor     = imageset.WidthFactor;
            newImageset.WcsImage        = imageset.WcsImage;
            newImageset.MeanRadius      = imageset.MeanRadius;
            newImageset.ReferenceFrame  = imageset.ReferenceFrame;
            newImageset.DemUrl          = imageset.DemUrl;
            return(newset);
        }
Пример #4
0
        public static void AddUpdObjectToCommunity(long CommunityId, long?ComponentId, object target, bool isUpdate)
        {
            CloudCommunityComponentsAPI.apiCommunityComponents api =
                new CloudCommunityComponentsAPI.apiCommunityComponents();
            string name = "", thumbnail = "", authorThumbnail = "";

            if (target is Tour)
            {
                Tour tour = (Tour)target;
                name      = tour.Name;
                thumbnail = tour.ThumbnailUrl;
                if (string.IsNullOrEmpty(thumbnail) || File.Exists(thumbnail))
                {
                    thumbnail = CallUploader(ImageToByteArray(tour.ThumbNail), tour.Name, "image/jpeg", true);
                }
                authorThumbnail = tour.AuthorImageUrl;
                if ((string.IsNullOrEmpty(authorThumbnail) || File.Exists(authorThumbnail)) && tour.AuthorImage != null)
                {
                    authorThumbnail = CallUploader(ImageToByteArray(tour.AuthorImage), tour.Author, "image/jpeg", true);
                }
            }
            else
            {
                if (target is IPlace)
                {
                    IPlace iplace = (IPlace)target;
                    name      = iplace.Name;
                    thumbnail = iplace.Thumbnail;
                    if (string.IsNullOrEmpty(thumbnail) || File.Exists(thumbnail))
                    {
                        thumbnail = CallUploader(ImageToByteArray(iplace.ThumbNail), iplace.Name, "image/jpeg", true);
                    }
                }
                else
                {
                    if (target is ImageSet)
                    {
                        ImageSet imageset = (ImageSet)target;
                        name      = imageset.Name;
                        thumbnail = imageset.ThumbnailUrl;
                        if (string.IsNullOrEmpty(thumbnail) || File.Exists(thumbnail))
                        {
                            thumbnail = CallUploader(ImageToByteArray(imageset.ThumbNail), imageset.Name, "image/jpeg", true);
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format(Language.GetLocalizedText(-1, "Error: {0} not supported in client upload at the moment..."), target.GetType()));
                        return;
                    }
                }
            }
            XmlDocument   doc       = new XmlDocument();
            XmlSerializer xml       = new XmlSerializer(target.GetType());
            MemoryStream  memStream = new MemoryStream();

            xml.Serialize(memStream, target);
            memStream.Seek(0, SeekOrigin.Begin);
            doc.Load(memStream);
            foreach (XmlNode x in doc.DocumentElement.Attributes)
            {
                bool isImage = (target is IPlace && ((IPlace)target).IsImage) ||
                               x.Name == "Thumbnail" ||
                               x.Name == "ThumbnailUrl";
                switch (x.Name)
                {
                case "Thumbnail":
                case "Url":
                case "TourUrl":
                    if (File.Exists(x.InnerText))
                    {
                        string contentType = FileContentType(x.InnerText);
                        if (contentType != null)
                        {
                            x.InnerText = CallUploader(x.InnerText, x.Name, contentType, isImage);
                        }
                    }
                    break;

                case "ThumbnailUrl":
                    x.InnerText = thumbnail;
                    break;

                case "AuthorImageUrl":
                    x.InnerText = authorThumbnail;
                    break;
                }
            }
            if (isUpdate)
            {
                api.Update(GetTokenFromId(), CommunityId, ComponentId.Value, name, thumbnail,
                           doc.DocumentElement.OuterXml, true, null, null);
            }
            else
            {
                api.Create(GetTokenFromId(), CommunityId,
                           CloudCommunityComponentsAPI.WWTComponentTypes.WWTSimpleComponent,
                           ComponentId, name, thumbnail, doc.DocumentElement.OuterXml, null);
            }
            CloudCommunities.SetAvoidCache(CommunityId, ComponentId);
        }
Пример #5
0
 public static ImageSet FromIImage(IImageSet imageset)
 {
     if (imageset == null)
     {
         return null;
     }
     ImageSet newset = new ImageSet();
     IImageSet newImageset = newset;
     newImageset.BandPass = imageset.BandPass;
     newImageset.BaseLevel = imageset.BaseLevel;
     newImageset.BaseTileDegrees = imageset.BaseTileDegrees;
     newImageset.BottomsUp = imageset.BottomsUp;
     newImageset.CenterX = imageset.CenterX;
     newImageset.CenterY = imageset.CenterY;
     newImageset.CreditsText = imageset.CreditsText;
     newImageset.CreditsUrl = imageset.CreditsUrl;
     newImageset.DataSetType = imageset.DataSetType;
     newImageset.DefaultSet = imageset.DefaultSet;
     newImageset.ElevationModel = imageset.ElevationModel;
     newImageset.Extension = imageset.Extension;
     newImageset.Generic = imageset.Generic;
     newImageset.ImageSetID = imageset.ImageSetID;
     newImageset.Levels = imageset.Levels;
     newImageset.Matrix = imageset.Matrix;
     newImageset.Mercator = imageset.Mercator;
     newImageset.Name = imageset.Name;
     newImageset.OffsetX = imageset.OffsetX;
     newImageset.OffsetY = imageset.OffsetY;
     newImageset.Projection = imageset.Projection;
     newImageset.QuadTreeTileMap = imageset.QuadTreeTileMap;
     newImageset.Rotation = imageset.Rotation;
     newImageset.Sparse = imageset.Sparse;
     newImageset.ThumbnailUrl = imageset.ThumbnailUrl;
     newImageset.Url = imageset.Url;
     newImageset.WidthFactor = imageset.WidthFactor;
     newImageset.WcsImage = imageset.WcsImage;
     newImageset.MeanRadius = imageset.MeanRadius;
     newImageset.ReferenceFrame = imageset.ReferenceFrame;
     newImageset.DemUrl = imageset.DemUrl;
     return newset;
 }
Пример #6
0
        public void RemoveChild(ImageSet child)
        {
            imagesets.Remove(child);

            dirty = true;
        }
Пример #7
0
        public void RemoveChild(ImageSet child)
        {
            imagesets.Remove(child);

            dirty = true;
        }