public static void AddFolderToSearch(Folder parent, bool sky) { foreach (var child in parent.Children) { if (child is IImageSet) { var childImageset = child as IImageSet; if (Earth3d.ProjectorServer) { Earth3d.AddImageSetToTable(childImageset.GetHash(), childImageset); } } if (child is IPlace) { var place = child as IPlace; if (place.StudyImageset != null) { if (Earth3d.ProjectorServer) { Earth3d.AddImageSetToTable(place.StudyImageset.GetHash(), place.StudyImageset); } } if (place.BackgroundImageSet != null) { if (Earth3d.ProjectorServer) { Earth3d.AddImageSetToTable(place.BackgroundImageSet.GetHash(), place.BackgroundImageSet); } } if (place.StudyImageset != null && (place.StudyImageset.Projection == ProjectionType.Toast || place.StudyImageset.Projection == ProjectionType.Equirectangular)) { continue; } AddPlaceToContextSearch(place); } if (child is Folder) { AddFolderToSearch(child as Folder, sky); } } }
private void LoadImageStack(Folder newFolder, bool showFirstAsBackground) { firstImageLoaded = showFirstAsBackground; AddClidrenToStack(newFolder, showFirstAsBackground); Stack.UpdateList(); }
bool SaveFolderAs(Folder folder) { var input = new SimpleInput(Language.GetLocalizedText(227, "Save Folder As"), Language.GetLocalizedText(228, "New Name"), folder.Name, 32); var retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(CollectionFileName(input.ResultText))) { var f = FindCollection(input.ResultText); if (f != null) { MessageBox.Show(Language.GetLocalizedText(229, "Collection file name already exists, type a different name."), Language.GetLocalizedText(230, Language.GetLocalizedText(232, "Create New Collection"))); retry = true; } else { var validfileName = @"^[A-Za-z0-9_ ]*$"; if (input.ResultText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || !UiTools.ValidateString(input.ResultText, validfileName)) { MessageBox.Show(Language.GetLocalizedText(231, "A name can not contain any of the following characters:") + " \\ / : * ? \" < > |", Language.GetLocalizedText(232, "Create New Collection")); retry = true; } else { var oldName = folder.Name; folder.Name = input.ResultText; folder.SaveToFile(CollectionFileName(folder.Name)); myCollections.AddChildFolder(Folder.LoadFromFile(CollectionFileName(folder.Name), false)); folder.Name = oldName; retry = false; return true; } } } else { MessageBox.Show(Language.GetLocalizedText(233, "Name already exists, type a different name."), Language.GetLocalizedText(232, "Create New Collection")); retry = true; } } else { return false; } } while (retry); return false; }
public static void SetCommunitySearch(Folder searchFolder, bool clear) { if (clear) { constellationObjects["Community"].Clear(); } constellationObjects["Community"].AddRange(searchFolder.Items); }
public void Refresh() { Folder temp = Folder.LoadFromUrl(Earth3d.MainWindow.PrepareUrl(urlField), VersionDependent); if (temp != null) { proxyFolder = temp; } }
void AddChildern(Folder folder) { foreach (var o1 in folder.Children) { if (o1 is Folder) { AddChildern(o1 as Folder); } else { contextResults.Add(o1); } } }
private void DrawKinectUI() { int index = 0; int itemStride = 600; if (kinectUi == null && !kinectInit) { kinectInit = true; try { kinectUi = Folder.LoadFromUrl("http://www.worldwidetelescope.org/wwtweb/catalog.aspx?w=kinect", false); } catch { } } if (kinectUi != null && menu) { int currentId = Math.Abs((int)((kinectListOffsetTarget - itemStride / 2) / itemStride)); Place currentPlace = null; Place earthPlace = null; double gap = ((int)((kinectListOffsetTarget - itemStride / 2) / itemStride) * itemStride) - kinectListOffsetTarget; if (Math.Abs(gap) > .5 && !contact) { kinectListOffsetTarget += Math.Min(10, Math.Abs(gap)) * Math.Sign(gap); } foreach (object item in kinectUi.Children) { Place place = item as Place; if (place != null && place.Classification == Classification.SolarSystem) { int id = Planets.GetPlanetIDFromName(place.Name); if (place.Name == "Solar Eclipse 2017") { id = 18; } if (place.Name == "Earth") { earthPlace = place; } if (id > -1) { if (index == currentId) { currentPlace = place; } Texture11 tex = Planets.PlanetTextures[id]; if (tex != null) { if (id > 9 && id < 18) { Sprite2d.Draw2D( RenderContext11, tex, new SizeF(512, 512), new PointF(.5f, .5f), 0, new PointF( (RenderContext11.ViewPort.Width / 2) + (index * itemStride + (int)kinectListOffsetTarget), RenderContext11.ViewPort.Height / 2 ), Color.White ); } else if (id > 0)// && id != 18) { Sprite2d.Draw2D( RenderContext11, tex, new SizeF(512, 512), new PointF(.5f, .5f), 0, new PointF( (RenderContext11.ViewPort.Width / 2) + (index * itemStride + (int)kinectListOffsetTarget), RenderContext11.ViewPort.Height / 2 ), Color.White ); } else { Sprite2d.Draw2D( RenderContext11, tex, new SizeF(1024, 1024), new PointF(.5f, .5f), 0, new PointF( (RenderContext11.ViewPort.Width / 2) + (index * itemStride + (int)kinectListOffsetTarget), RenderContext11.ViewPort.Height / 2 ), Color.White ); } } index++; } } } if (showNextObject) { if (currentPlace != null) { if (currentPlace.Name == "Solar Eclipse 2017") { kinectEclipseMode = true; SpaceTimeController.Now = new DateTime(2017, 08, 21, 16, 00, 00); SpaceTimeController.TimeRate = 200; SpaceTimeController.SyncToClock = true; GotoTarget(earthPlace, false, false, true); } else { kinectEclipseMode = false; GotoTarget(currentPlace, false, false, true); } } showNextObject = false; menu = false; } } }
private void extractThumb(Folder folder) { foreach (object child in folder.Children) { if (child is Folder) { Folder ims = child as Folder; IThumbnail imt = child as IThumbnail; if (ims != null && imt != null) { if (!string.IsNullOrEmpty(ims.Thumbnail) && ims.Thumbnail.Contains("wwt.nasa")) { string filename = ims.Thumbnail.Substring(ims.Thumbnail.LastIndexOf("/") + 1); if (!File.Exists("c:\\marsthumbs\\" + filename)) { Bitmap bmp = imt.ThumbNail; bmp.Save("c:\\marsthumbs\\" + filename); bmp.Dispose(); } } } extractThumb(child as Folder); } if (child is IImageSet) { IImageSet ims = child as IImageSet; IThumbnail imt = child as IThumbnail; if (ims != null && imt != null) { if (ims.ThumbnailUrl.Contains("wwt.nasa")) { string filename = ims.ThumbnailUrl.Substring(ims.ThumbnailUrl.LastIndexOf("/") + 1); if (!File.Exists("c:\\marsthumbs\\" + filename)) { Bitmap bmp = imt.ThumbNail; bmp.Save("c:\\marsthumbs\\" + filename); bmp.Dispose(); } } } } if (child is IPlace) { IPlace ims = child as IPlace; IThumbnail imt = child as IThumbnail; if (ims != null && imt != null) { if (!string.IsNullOrEmpty(ims.Thumbnail) && ims.Thumbnail.Contains("wwt.nasa")) { string filename = ims.Thumbnail.Substring(ims.Thumbnail.LastIndexOf("/") + 1); Bitmap bmp = imt.ThumbNail; bmp.Save("c:\\marsthumbs\\" + filename); bmp.Dispose(); } } } } }
public static void AddFolderToursToSearch(Folder folder) { if (folder.Tour != null) { foreach (var tour in folder.Tour) { if (!deduplicatedTourList.ContainsKey(tour.ID)) { deduplicatedTourList.Add(tour.ID, tour); } } } if (Tours.Folder1 != null) { foreach (var childFolder in folder.Folder1) { AddFolderToursToSearch(childFolder); } } }
private void ShowReadOnlyCollectionContextMenu(Folder folder) { contextMenu = new ContextMenuStrip(); if (Earth3d.MainWindow.ImageStackVisible) { var addToStack = new ToolStripMenuItem(Language.GetLocalizedText(1001, "Add Children to Image stack")); addToStack.Click += addToStack_Click; addToStack.Tag = folder; contextMenu.Items.Add(addToStack); } }
private void ShowOpenFolderMenu(Folder folder) { if (contextMenu != null) { contextMenu.Dispose(); } contextMenu = new ContextMenuStrip(); var closeMenu = new ToolStripMenuItem(Language.GetLocalizedText(212, "Close")); var copyMenu = new ToolStripMenuItem(Language.GetLocalizedText(226, "Copy To My Collections")); closeMenu.Click += closeMenu_Click; copyMenu.Click += copyMenu_Click; closeMenu.Tag = folder; copyMenu.Tag = folder; contextMenu.Items.Add(closeMenu); contextMenu.Items.Add(copyMenu); contextMenu.Show(Cursor.Position); }
private void ShowMyCollectionsContextMenu(Folder folder) { if (folder == myCollections) { return; } contextMenu = new ContextMenuStrip(); var addToStack = new ToolStripMenuItem( Language.GetLocalizedText(1001, "Add Children to Image stack")); var deleteMenu = new ToolStripMenuItem(Language.GetLocalizedText(224, Language.GetLocalizedText(224, "Delete Folder"))); var renameMenu = new ToolStripMenuItem(Language.GetLocalizedText(225, "Rename")); addToStack.Click += addToStack_Click; deleteMenu.Click += deleteMenu_Click; renameMenu.Click += renameMenu_Click; addToStack.Tag = folder; deleteMenu.Tag = folder; renameMenu.Tag = folder; if (Earth3d.MainWindow.ImageStackVisible) { contextMenu.Items.Add(addToStack); } contextMenu.Items.Add(deleteMenu); //if (folder.MSRCommunityId > 0) //{ // contextMenu.Items.Add(editMenu); //} //else { contextMenu.Items.Add(renameMenu); } contextMenu.Show(Cursor.Position); }
private void ShowFolderMenu(Folder folder) { if (contextMenu != null) { contextMenu.Dispose(); } if (folder.ReadOnly) { ShowReadOnlyCollectionContextMenu(folder); } else { ShowMyCollectionsContextMenu(folder); } }
private void ShowCloudCommunitiesFolderContextMenu(Folder folder) { contextMenu = new ContextMenuStrip(); var showFolder = new ToolStripMenuItem(Language.GetLocalizedText(995, "Show on Community Web Site")); var editFolder = new ToolStripMenuItem(Language.GetLocalizedText(996, "Edit on Community Web Site")); var deleteFolder = new ToolStripMenuItem(Language.GetLocalizedText(997, "Delete from Community Web Site")); var removeFolder = new ToolStripMenuItem(Language.GetLocalizedText(998, "Remove Subscription of this Community")); showFolder.Click += showFolder_Click; editFolder.Click += editFolder_Click; deleteFolder.Click += deleteFolder_Click; removeFolder.Click += removeFolder_Click; showFolder.Tag = folder; editFolder.Tag = folder; deleteFolder.Tag = folder; removeFolder.Tag = folder; if (folder.MSRCommunityId > 0) { contextMenu.Items.Add(showFolder); } if ((folder.Permission & 8) == 8) { contextMenu.Items.Add(editFolder); contextMenu.Items.Add(deleteFolder); } if (breadcrumbs.Count == 1 && !folder.ReadOnly) { contextMenu.Items.Add(removeFolder); } if (contextMenu.Items.Count > 0) { contextMenu.Show(Cursor.Position); } }
public void AddClidrenToStack(Folder folder, bool showFirstAsBackground) { foreach (object o in folder.Children) { if (o is Folder) { AddClidrenToStack((Folder)o, false); } else { if (o is Place) { if (showFirstAsBackground && firstImageLoaded) { SetCurrentBackgroundForStack((Place)o); } else { AddPlaceToStack((Place)o, false); } } else if (o is IImageSet) { IImageSet imageSet = (IImageSet)o; TourPlace tp = new TourPlace(imageSet.Name, imageSet.CenterX, imageSet.CenterY, Classification.Unidentified, "", imageSet.DataSetType, 360); if (showFirstAsBackground && firstImageLoaded) { SetCurrentBackgroundForStack(tp); } else { AddPlaceToStack(tp, false); } } } } }
private void AddCommunity(Folder newFolder) { string filename = CommuinitiesDirectory + Math.Abs(newFolder.Url.GetHashCode32()).ToString() + ".wtml"; if (!Directory.Exists(CommuinitiesDirectory)) { Directory.CreateDirectory(CommuinitiesDirectory); } if (File.Exists(filename)) { UiTools.ShowMessageBox(Language.GetLocalizedText(110, "The file opened is a community registration file and this community is already registered.")); communitiesPane.LoadCommunities(); menuTabs.SetSelectedIndex((int)ApplicationMode.Explore, false); this.Refresh(); menuTabs.SetSelectedIndex((int)ApplicationMode.Community, false); return; } if (UiTools.ShowMessageBox(Language.GetLocalizedText(111, "The file opened is a community registration file. Would you like to add this to your communities list?"), Language.GetLocalizedText(3, "Microsoft WorldWide Telescope"), MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } newFolder.SaveToFile(filename); communitiesPane.LoadCommunities(); menuTabs.SetSelectedIndex((int)ApplicationMode.Explore, false); this.Refresh(); menuTabs.SetSelectedIndex((int)ApplicationMode.Community, false); }
public void LoadToursDeffered() { Cursor.Current = Cursors.WaitCursor; try { var filename = Properties.Settings.Default.CahceDirectory + @"data\tours.wtml"; DataSetManager.DownloadFile("http://www.worldwidetelescope.org/wwtweb/gettours.aspx", filename, false, false); Tours = Folder.LoadFromFile(filename, false); Tours.Name = Language.GetLocalizedText(492, "Tours"); Folder loadFolder = null; loadFolder = Tours; // invoke the load MethodInvoker LoadIt = delegate { LoadRootFoder(loadFolder); BrowseList.EmptyAddText = Language.GetLocalizedText(162, "No Results"); }; try { Invoke(LoadIt); } catch { } AddToursToSearch(); } catch { MethodInvoker Error = delegate { BrowseList.EmptyAddText = Language.GetLocalizedText(162, "No Results"); UiTools.ShowMessageBox(Language.GetLocalizedText(220, "Could not connect to the WorldWide Telescope Server to download tours, and there was no available cached tour list. Please check your network or proxy settings and make sure you have a network connection.")); }; try { Invoke(Error); } catch { } } Cursor.Current = Cursors.Default; }
private bool SetBackgroundByName(Folder folder, string name) { foreach (object o in folder.Children) { if (o is IPlace) { IPlace place = (IPlace)o; if (place.Name.ToLower().Contains(name.ToLower())) { if (place.BackgroundImageSet != null && place.BackgroundImageSet.DataSetType != Earth3d.MainWindow.CurrentImageSet.DataSetType) { continue; } if (place.Classification == Classification.SolarSystem && Earth3d.MainWindow.CurrentImageSet.DataSetType == ImageSetType.SolarSystem) { CurrentImageSet = new ImageSetHelper(ImageSetType.SolarSystem, BandPass.Visible); } IImageSet imageSet = null; if (place.StudyImageset != null) { imageSet = place.StudyImageset; } if (place.BackgroundImageSet != null) { imageSet = place.BackgroundImageSet; } if (imageSet != null) { this.CurrentImageSet = imageSet; } GotoTarget(place, false, false, true); return true; } } } return false; }
public Folder NewCollection() { var input = new SimpleInput(Language.GetLocalizedText(232, "Create New Collection"), Language.GetLocalizedText(238, "Name"), "", 32); var retry = false; do { if (input.ShowDialog() == DialogResult.OK) { if (!File.Exists(CollectionFileName(input.ResultText))) { var f = FindCollection(input.ResultText); if (f != null) { MessageBox.Show(Language.GetLocalizedText(229, "Collection file name already exists, type a different name."), Language.GetLocalizedText(232, "Create New Collection")); retry = true; } else { var validfileName = @"^[A-Za-z0-9_ ]*$"; if (input.ResultText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || !UiTools.ValidateString(input.ResultText, validfileName)) { MessageBox.Show(Language.GetLocalizedText(231, "A name can not contain any of the following characters:") + " \\ / : * ? \" < > |", Language.GetLocalizedText(232, "Create New Collection")); retry = true; } else { var newCollection = new Folder(); newCollection.Name = input.ResultText; newCollection.ThumbNail = Resources.Folder; newCollection.LoadedFilename = CollectionFileName(input.ResultText); newCollection.ReadOnly = false; MyCollections.AddChildFolder(newCollection); retry = false; return newCollection; } } } else { MessageBox.Show(Language.GetLocalizedText(233, "Name already exists, type a different name."), Language.GetLocalizedText(232, "Create New Collection")); retry = true; } } else { return null; } } while (retry); return null; }
private void LoadExploreRoot() { string url = Properties.Settings.Default.ExploreRootUrl; string filename = string.Format(@"{0}data\exploreRoot_{1}.wtml", Properties.Settings.Default.CahceDirectory, Math.Abs(url.GetHashCode32())); DataSetManager.DownloadFile(url, filename, false, true); explorerRoot = Folder.LoadFromFile(filename, true); }
public void ShowCollection(Folder collection) { while (breadcrumbs.Count > 1) { breadcrumbs.Pop(); } var top = breadcrumbs.Pop(); breadcrumbs.Clear(); LoadFolder(top); LoadFolder(OpenCollections); LoadFolder(collection); }
public void AddChildFolder(Folder child) { folders.Add(child); dirty = true; }
internal void LoadCommunities() { myCommunities = null; LoadRootFoder(MyCommunities); }
public void RemoveChild(Folder child) { folders.Remove(child); dirty = true; }
private static Tour FindChildTour(Folder folder, string guid) { if (folder.Tour != null) { foreach (var tour in folder.Tour) { if (tour.Id == guid.ToLower().Trim()) { return tour; } } } if (Tours.Folder1 != null) { foreach (var childFolder in folder.Folder1) { var tour = FindChildTour(childFolder, guid); if (tour != null) { return tour; } } } return null; }
private void BrowseList_AddNewItem(object sender, object e) { var parent = breadcrumbs.Peek(); if (parent.Name == Language.GetLocalizedText(236, "My Collections")) { var folder = NewCollection(); if (folder != null) { LoadFolder(folder); } } else { if (parent is Folder) { var owner = (Folder)parent; var input = new SimpleInput(Language.GetLocalizedText(239, "Create New Folder"), Language.GetLocalizedText(238, "Name"), "", 32); var retry = false; do { if (input.ShowDialog() == DialogResult.OK) { var validfileName = @"^[A-Za-z0-9_ ]*$"; if (input.ResultText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || !UiTools.ValidateString(input.ResultText, validfileName)) { MessageBox.Show(Language.GetLocalizedText(231, "A name can not contain any of the following characters:") + " \\ / : * ? \" < > |", Language.GetLocalizedText(232, "Create New Collection")); retry = true; } else { var newCollection = new Folder(); newCollection.Name = input.ResultText; newCollection.ThumbNail = Resources.Folder; newCollection.LoadedFilename = CollectionFileName(input.ResultText); newCollection.ReadOnly = false; owner.AddChildFolder(newCollection); LoadFolder(newCollection); retry = false; } } } while (retry); } } }
public void LoadCollection(Folder collection) { OpenCollections.AddChildFolder(collection); while (breadcrumbs.Count > 1) { breadcrumbs.Pop(); } IThumbnail top = breadcrumbs.Pop(); breadcrumbs.Clear(); LoadFolder(top); LoadFolder(OpenCollections); LoadFolder(collection); }