Esempio n. 1
0
        public void SerializeProject(MapStruct map, string saveFileName)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter oFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            System.IO.FileStream oFileStream = new System.IO.FileStream(saveFileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
            oFormatter.Serialize(oFileStream, map);
        }
Esempio n. 2
0
        public MapStruct DeserializeProject(string projectFileName)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter oFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            MapStruct oMap = new MapStruct();

            using (System.IO.FileStream oFileStream = new System.IO.FileStream(projectFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                oMap = oFormatter.Deserialize(oFileStream) as MapStruct;
            }

            return oMap;
        }
Esempio n. 3
0
        public MapStruct DeserializeProject(string projectFileName)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter oFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            MapStruct oMap = new MapStruct();

            using (System.IO.FileStream oFileStream = new System.IO.FileStream(projectFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                oMap = oFormatter.Deserialize(oFileStream) as MapStruct;
            }

            return(oMap);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        public MapStruct SaveMapInfosToProject(AxMapObjects2.AxMap mapControl, string geoDataSetPath)
        {
            MapStruct oMapStruct = new MapStruct();

            oMapStruct.BBox.MinX   = mapControl.Extent.Top;
            oMapStruct.BBox.MinY   = mapControl.Extent.Left;
            oMapStruct.BBox.MaxX   = mapControl.Extent.Bottom;
            oMapStruct.BBox.MaxY   = mapControl.Extent.Right;
            oMapStruct.BBox.Width  = mapControl.Extent.Width;
            oMapStruct.BBox.Height = mapControl.Extent.Height;

            oMapStruct.CoordinateSystem = mapControl.CoordinateSystem;
            oMapStruct.GeoDataSetPath   = geoDataSetPath;

            short iLayersCount = mapControl.Layers.Count;

            for (short i = 0; i < iLayersCount; i++)
            {
                object oLayer = mapControl.Layers.Item(i);

                if (oLayer is MapObjects2.MapLayer)
                {
                    MapObjects2.MapLayer oMapLayer       = oLayer as MapObjects2.MapLayer;
                    MapLayerInfoStruct   oMapLayerStruct = new MapLayerInfoStruct();

                    oMapLayerStruct.LayerType = (short)oMapLayer.LayerType;
                    oMapLayerStruct.Name      = oMapLayer.Name;
                    oMapLayerStruct.ShapeType = (short)oMapLayer.shapeType;

                    oMapLayerStruct.Render = this.ExportLayerRender(oMapLayer);
                    this.DeconvertSymbol(oMapLayer.Symbol, oMapLayerStruct.Symbol);
                }
                else if (oLayer is MapObjects2.ImageLayer)
                {
                    throw new NotImplementedException();
                }
            }

            return(oMapStruct);
        }
Esempio n. 6
0
        public void SerializeProject(MapStruct map,string saveFileName)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter oFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            System.IO.FileStream oFileStream = new System.IO.FileStream(saveFileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
            oFormatter.Serialize(oFileStream, map);
        }
Esempio n. 7
0
        public MapStruct SaveMapInfosToProject(AxMapObjects2.AxMap mapControl,string geoDataSetPath)
        {
            MapStruct oMapStruct = new MapStruct();

            oMapStruct.BBox.MinX = mapControl.Extent.Top;
            oMapStruct.BBox.MinY = mapControl.Extent.Left;
            oMapStruct.BBox.MaxX = mapControl.Extent.Bottom;
            oMapStruct.BBox.MaxY = mapControl.Extent.Right;
            oMapStruct.BBox.Width = mapControl.Extent.Width;
            oMapStruct.BBox.Height = mapControl.Extent.Height;

            oMapStruct.CoordinateSystem = mapControl.CoordinateSystem;
            oMapStruct.GeoDataSetPath = geoDataSetPath;

            short iLayersCount = mapControl.Layers.Count;
            for (short i = 0; i < iLayersCount; i++)
            {
                object oLayer = mapControl.Layers.Item(i);

                if (oLayer is MapObjects2.MapLayer)
                {
                    MapObjects2.MapLayer oMapLayer = oLayer as MapObjects2.MapLayer;
                    MapLayerInfoStruct oMapLayerStruct = new MapLayerInfoStruct();

                    oMapLayerStruct.LayerType = (short)oMapLayer.LayerType;
                    oMapLayerStruct.Name = oMapLayer.Name;
                    oMapLayerStruct.ShapeType = (short)oMapLayer.shapeType;

                    oMapLayerStruct.Render = this.ExportLayerRender(oMapLayer);
                    this.DeconvertSymbol(oMapLayer.Symbol, oMapLayerStruct.Symbol);
                }
                else if (oLayer is MapObjects2.ImageLayer)
                {
                    throw new NotImplementedException();
                }
            }

            return oMapStruct;
        }
Esempio n. 8
0
        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;
        }