/// <summary> /// 加载图层集合 /// </summary> /// <param name="layerPaths">图层路径集合</param> /// <param name="map">地图对象</param> public void LoadLayers(List <string> layerPaths, MapStruct mapInfoCollection, AxMapObjects2.AxMap mapControl) { BaseHandler.MapManager oMapManager = new BaseHandler.MapManager(); ProjectSerialization oProjectSerilization = new ProjectSerialization(); foreach (string sLayerPath in layerPaths) { string sFileExtent = System.IO.Path.GetExtension(sLayerPath); LayerTypeConstants oLayerType = oMapManager.GetLayerTypeByFileExtent(sFileExtent); if (oLayerType == LayerTypeConstants.moMapLayer) { MapLayer oMapLayer = oMapManager.GetSingleVectorLayer(sLayerPath); oMapLayer.Tag = "0-0"; mapControl.Layers.Add(oMapLayer); MapLayerInfoStruct oMapLayerStruct = oProjectSerilization.LoadLayerInfos(oMapLayer, sLayerPath, -1, -1); mapInfoCollection.Layers.Insert(0, oMapLayerStruct); } else if (oLayerType == LayerTypeConstants.moImageLayer) { ImageLayer oImageLayer = oMapManager.GetSingleImageLayer(sLayerPath); oImageLayer.Tag = "0-0"; mapControl.Layers.Add(oImageLayer); ImageLayerInfoStruct oImageLayerStruct = oProjectSerilization.LoadLayerInfos(oImageLayer, sLayerPath, -1, -1); mapInfoCollection.Layers.Insert(0, oImageLayerStruct); } } }
public void SerializeAndDeserializeProject2() { var project = TestProjects.CreateBasicProject2(); var strProject = ProjectSerialization.SerializeProject(project); var project2 = ProjectSerialization.LoadFromString(strProject); }
private void LoadMapProject(string projectFileName) { ProjectSerialization oProjectSerilization = new ProjectSerialization(); GlobeVariables.MainMapControl.Layers.Clear(); GlobeVariables.MapInfosCollection = oProjectSerilization.LoadProjectByMapInfos(projectFileName, GlobeVariables.MainMapControl); GlobeVariables.MainMapControl.RefreshRect(GlobeVariables.MainMapControl.Extent); frmLegend.Instance.LoadLayersToLegend(GlobeVariables.MainMapControl); frmNavigation.Instance.LoadLayersToNavigation(GlobeVariables.MainMapControl); }
private void mnuSaveAsProject_Click(object sender, EventArgs e) { SaveFileDialog oSaveFileDialog = new SaveFileDialog(); oSaveFileDialog.Filter = "GVMS Project File(*.gvp) | *.gvp"; if (oSaveFileDialog.ShowDialog() == DialogResult.OK) { ProjectSerialization oProjectSerialization = new ProjectSerialization(); oProjectSerialization.SaveMapInfosToProject(GlobeVariables.MapControl, oSaveFileDialog.FileName, GlobeVariables.MapInfosCollection); this._projectFileName = oSaveFileDialog.FileName; this._isSaved = true; this.Text = "地图配置 " + this._projectFileName; } }
public bool SaveProject(string filePath) { try { ProjectSerialization.SaveToFile(CurrentProject, CurrentProjectPath); CurrentProjectPath = filePath; } catch { return(false); } return(true); }
public Project DeserializeProject(string resourceName) { string strProject; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { strProject = reader.ReadToEnd(); } var project = ProjectSerialization.LoadFromString(strProject); return(project); }
public void DeserializeAndSerializeProject(string resourceName) { string strProject; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { strProject = reader.ReadToEnd(); } var project = ProjectSerialization.LoadFromString(strProject); var strProject2 = ProjectSerialization.SerializeProject(project); Assert.Equal(strProject, strProject2); }
private void mnuOpenProject_Click(object sender, EventArgs e) { OpenFileDialog oOpenFileDialog = new OpenFileDialog(); oOpenFileDialog.Filter = "GVMS Project File(*.gvp) | *.gvp"; if (oOpenFileDialog.ShowDialog() == DialogResult.OK) { ProjectSerialization oProjectSerilization = new ProjectSerialization(); GlobeVariables.MapControl.Layers.Clear(); GlobeVariables.MapInfosCollection = oProjectSerilization.LoadProjectByMapInfos(oOpenFileDialog.FileName, GlobeVariables.MapControl); GlobeVariables.MapControl.RefreshRect(GlobeVariables.MapControl.Extent); GlobeVariables.MapLegend.LoadLegend(); this._projectFileName = oOpenFileDialog.FileName; this._isSaved = true; this.Text = "地图配置 " + this._projectFileName; } }
public bool OpenProject(string filePath) { if (!File.Exists(filePath)) { return(false); } try { CurrentProject = ProjectSerialization.LoadFromFile(filePath); CurrentProjectPath = filePath; } catch { return(false); } return(true); }
private async static Task RunProject(string path) { if (!File.Exists(path)) { Console.WriteLine($"Project file not found: {path}"); return; } Console.WriteLine($"Loading {path}..."); var project = ProjectSerialization.LoadFromFile(path); var runner = new ProjectRunner(); Console.WriteLine($"Running {path}..."); await runner.Run(project); Console.WriteLine($"Finished running {path}"); Console.WriteLine(); }
/// <summary> /// ����ͼ�㼯�� /// </summary> /// <param name="layerPaths">ͼ��·������</param> /// <param name="map">��ͼ����</param> public void LoadLayers(List<string> layerPaths,MapStruct mapInfoCollection, AxMapObjects2.AxMap mapControl) { BaseHandler.MapManager oMapManager = new BaseHandler.MapManager(); ProjectSerialization oProjectSerilization = new ProjectSerialization(); foreach (string sLayerPath in layerPaths) { string sFileExtent = System.IO.Path.GetExtension(sLayerPath); LayerTypeConstants oLayerType = oMapManager.GetLayerTypeByFileExtent(sFileExtent); if (oLayerType == LayerTypeConstants.moMapLayer) { MapLayer oMapLayer = oMapManager.GetSingleVectorLayer(sLayerPath); oMapLayer.Tag = "0-0"; mapControl.Layers.Add(oMapLayer); MapLayerInfoStruct oMapLayerStruct = oProjectSerilization.LoadLayerInfos(oMapLayer, sLayerPath, -1, -1); mapInfoCollection.Layers.Insert(0,oMapLayerStruct); } else if (oLayerType == LayerTypeConstants.moImageLayer) { ImageLayer oImageLayer = oMapManager.GetSingleImageLayer(sLayerPath); oImageLayer.Tag = "0-0"; mapControl.Layers.Add(oImageLayer); ImageLayerInfoStruct oImageLayerStruct = oProjectSerilization.LoadLayerInfos(oImageLayer, sLayerPath, -1, -1); mapInfoCollection.Layers.Insert(0,oImageLayerStruct); } } }
private void mnuSaveProject_Click(object sender, EventArgs e) { ProjectSerialization oProjectSerialization = new ProjectSerialization(); if (!this._isSaved) { SaveFileDialog oSaveFileDialog = new SaveFileDialog(); oSaveFileDialog.Filter = "GVMS Project File(*.gvp) | *.gvp"; if (oSaveFileDialog.ShowDialog() == DialogResult.OK) { oProjectSerialization.SaveMapInfosToProject(GlobeVariables.MapControl, oSaveFileDialog.FileName, GlobeVariables.MapInfosCollection); this._projectFileName = oSaveFileDialog.FileName; this._isSaved = true; this.Text = "地图配置 " + this._projectFileName; } } else { oProjectSerialization.SaveMapInfosToProject(GlobeVariables.MapControl, this._projectFileName, GlobeVariables.MapInfosCollection); this.Text = "地图配置 " + this._projectFileName; } }
public void SerializeProject2() { var project = TestProjects.CreateBasicProject2(); var strProject = ProjectSerialization.SerializeProject(project); }