public static LayerContainer FromFile(string filename, bool forEdit, string parentFrame, bool referenceFrameRightClick) { FileCabinet cab = new FileCabinet(filename, BaseWorkingDirectory); cab.Extract(); LayerContainer newDoc = LayerContainer.FromXml(cab.MasterFile, parentFrame, referenceFrameRightClick); if (forEdit) { newDoc.SaveFileName = filename; } return(newDoc); }
void saveMenu_Click(object sender, EventArgs e) { Layer layer = (Layer)layerTree.SelectedNode.Tag; SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Filter = Language.GetLocalizedText(993, "WorldWide Telescope Layer File(*.wwtl)") + "|*.wwtl"; saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); saveDialog.AddExtension = true; saveDialog.DefaultExt = ".wwtl"; saveDialog.FileName = layer.Name + ".wwtl"; if (saveDialog.ShowDialog() == DialogResult.OK) { // Todo add dialog for dynamic content options. LayerContainer layers = new LayerContainer(); layers.SoloGuid = layer.ID; layers.SaveToFile(saveDialog.FileName); layers.Dispose(); GC.SuppressFinalize(layers); } }
void publishMenu_Click(object sender, EventArgs e) { if (Earth3d.IsLoggedIn) { Layer target = (Layer)layerTree.SelectedNode.Tag; string name = target.Name + ".wwtl"; string filename = Path.GetTempFileName(); LayerContainer layers = new LayerContainer(); layers.SoloGuid = target.ID; layers.SaveToFile(filename); layers.Dispose(); GC.SuppressFinalize(layers); EOCalls.InvokePublishFile(filename, name); File.Delete(filename); Earth3d.RefreshCommunity(); } }
void SaveLayers_Click(object sender, EventArgs e) { var target = (LayerMap)layerTree.SelectedNode.Tag; var saveDialog = new SaveFileDialog(); saveDialog.Filter = Language.GetLocalizedText(992, "WorldWide Telescope Layer File") + "(*.wwtl)|*.wwtl"; saveDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); saveDialog.AddExtension = true; saveDialog.DefaultExt = ".wwtl"; saveDialog.FileName = target.Name + ".wwtl"; if (saveDialog.ShowDialog() == DialogResult.OK) { // Todo add dialog for dynamic content options. var layers = new LayerContainer(); layers.TopLevel = target.Name; layers.SaveToFile(saveDialog.FileName); layers.Dispose(); GC.SuppressFinalize(layers); } }
void publishLayers_Click(object sender, EventArgs e) { if (Earth3d.IsLoggedIn) { var target = (LayerMap)layerTree.SelectedNode.Tag; var name = target.Name + ".wwtl"; var filename = Path.GetTempFileName(); var layers = new LayerContainer(); layers.TopLevel = target.Name; layers.SaveToFile(filename); layers.Dispose(); GC.SuppressFinalize(layers); EOCalls.InvokePublishFile(filename, name); File.Delete(filename); Earth3d.RefreshCommunity(); } }
private static void SaveLayerSyncFile() { LayerContainer layers = new LayerContainer(); layers.SaveToFile(Properties.Settings.Default.CahceDirectory + "\\layerSync.layers"); layers.Dispose(); GC.SuppressFinalize(layers); }
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; }
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); }