public MapStruct LoadProjectByMapInfos(string projectFileName, AxMapObjects2.AxMap mapControl) { ProjectSerialization oProjectSerialization = new ProjectSerialization(); MapStruct oMapStruct = oProjectSerialization.DeserializeProject(projectFileName); List <ILayerStruct> oLayers = oMapStruct.Layers; MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass(); foreach (ILayerStruct oLayer in oLayers) { if (oLayer is MapLayerInfoStruct) { MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass(); oConn.Database = System.IO.Path.GetDirectoryName(oLayer.FileName); if (oConn.Connect()) { oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.DataSetName); this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render); this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol); oMapLayer.Name = oLayer.AliasName; oMapLayer.Visible = oLayer.Visible; oMapLayer.Tag = string.Format("{0}-{1}", oLayer.MinLevel, oLayer.MaxLevel); mapControl.Layers.Add(oMapLayer); oConn.Disconnect(); } } else if (oLayer is ImageLayerInfoStruct) { //not implement //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass(); //oImageLayer.Name = oLayer.Name; } } MapObjects2.Rectangle oViewExtent = new MapObjects2.RectangleClass(); oViewExtent.Left = oMapStruct.BBox.MinX; oViewExtent.Top = oMapStruct.BBox.MinY; oViewExtent.Right = oMapStruct.BBox.MaxX; oViewExtent.Bottom = oMapStruct.BBox.MaxY; mapControl.Extent = oViewExtent; //mapControl.CoordinateSystem = oMapStruct.CoordinateSystem; return(oMapStruct); }
public void LoadProjectByMapInfos(MapStruct mapInfos, AxMapObjects2.AxMap mapControl) { List <ILayerStruct> oLayers = mapInfos.Layers; MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass(); oConn.Database = mapInfos.GeoDataSetPath; oConn.Connect(); foreach (ILayerStruct oLayer in oLayers) { if (oLayer is MapLayerInfoStruct && oConn.Connected) { MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass(); oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name); this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render); this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol); mapControl.Layers.Add(oMapLayer); } else if (oLayer is ImageLayerInfoStruct) { //not implement //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass(); //oImageLayer.Name = oLayer.Name; } } if (oConn.Connected) { oConn.Disconnect(); } mapControl.Extent.Top = mapInfos.BBox.MinX; mapControl.Extent.Left = mapInfos.BBox.MinY; mapControl.Extent.Bottom = mapInfos.BBox.MaxX; mapControl.Extent.Right = mapInfos.BBox.MaxY; mapControl.CoordinateSystem = mapInfos.CoordinateSystem; }
public void LoadProjectByMapInfos(MapStruct mapInfos,AxMapObjects2.AxMap mapControl) { List<ILayerStruct> oLayers = mapInfos.Layers; MapObjects2.DataConnection oConn = new MapObjects2.DataConnectionClass(); oConn.Database = mapInfos.GeoDataSetPath; oConn.Connect(); foreach (ILayerStruct oLayer in oLayers) { if (oLayer is MapLayerInfoStruct && oConn.Connected) { MapObjects2.MapLayer oMapLayer = new MapObjects2.MapLayerClass(); oMapLayer.GeoDataset = oConn.FindGeoDataset(oLayer.Name); this.SetLayerRender(oMapLayer, (oLayer as MapLayerInfoStruct).Render); this.ConvertSymbol((oLayer as MapLayerInfoStruct).Symbol, oMapLayer.Symbol); mapControl.Layers.Add(oMapLayer); } else if (oLayer is ImageLayerInfoStruct) { //not implement //MapObjects2.ImageLayer oImageLayer = new MapObjects2.ImageLayerClass(); //oImageLayer.Name = oLayer.Name; } } if(oConn.Connected) oConn.Disconnect(); mapControl.Extent.Top = mapInfos.BBox.MinX; mapControl.Extent.Left = mapInfos.BBox.MinY; mapControl.Extent.Bottom = mapInfos.BBox.MaxX; mapControl.Extent.Right = mapInfos.BBox.MaxY; mapControl.CoordinateSystem = mapInfos.CoordinateSystem; }