private void ImportAuthorImage_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = Language.GetLocalizedText(486, "Image Files") + "(*.BMP;*.JPG;*.PNG;*.TIF)|*.BMP;*.JPG;*.PNG;*.TIF;*.TIFF|All files (*.*)|*.*"; if (openFile.ShowDialog() == DialogResult.OK) { Bitmap bmpTemp = null; try { bmpTemp = Thumbnailer.MakeThumbnail(UiTools.LoadBitmap(openFile.FileName), 72, 96); } catch { bmpTemp = null; } if (bmpTemp != null) { this.authorImagePicturebox.Image = bmpTemp; ValidateDataComplete(); } } }
static public Bitmap LoadThumbnailFromWeb(string url, string filename) { try { DataSetManager.DownloadFile(CacheProxy.GetCacheUrl(url), Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename, true, true); return(UiTools.LoadBitmap(Properties.Settings.Default.CahceDirectory + @"thumbnails\" + filename)); } catch { return(null); } }
public override Bitmap GetBitmap() { return(UiTools.LoadBitmap(filename)); }
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); }