Example #1
0
        public frmLayerProperties(AxMapObjects2.AxMap mapControl, object layer)
        {
            InitializeComponent();

            this._mapControl = mapControl;

            if (layer == null)
                throw new Exception("layer is null,please set a valid layer.");

            if (layer is MapObjects2.ImageLayer)
                this._imageLayer = layer as MapObjects2.ImageLayer;
            else if (layer is MapObjects2.MapLayer)
                this._mapLayer = layer as MapObjects2.MapLayer;

            if (this._mapLayer != null)
            {
                int iColumnsCount = this._mapLayer.Records.TableDesc.FieldCount;
                string sFieldName = string.Empty;
                this._fieldsList.Clear();
                this._numFieldsList.Clear();

                for (short i = 0; i < iColumnsCount; i++)
                {
                    sFieldName = this._mapLayer.Records.TableDesc.get_FieldName(i);
                    MapObjects2.Field oField = this._mapLayer.Records.Fields.Item(sFieldName);
                    this._fieldsList.Add(oField.Name);

                    if (oField.Type == MapObjects2.FieldTypeConstants.moDouble || oField.Type == MapObjects2.FieldTypeConstants.moLong)
                        this._numFieldsList.Add(oField.Name);
                }
            }
        }
Example #2
0
 /// <summary>
 /// di tu ceng = eyemap
 /// </summary>
 private void InitializeEyeMap()
 {
     MapObjects2.DataConnection mapCon   = new MapObjects2.DataConnectionClass();
     MapObjects2.MapLayer       EyeLayer = null;
     try
     {
         mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
         for (int i = 0; i < mapLayer.m_layers.Length; i++)
         {
             if (mapLayer.m_layers[i].typeName == "地图层")
             {
                 EyeLayer              = new MapObjects2.MapLayerClass();
                 EyeLayer.GeoDataset   = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                 EyeLayer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 EyeLayer.Symbol.Size  = 1;
                 if (EyeLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                 {
                     EyeLayer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                 }
                 mapEye.Layers.Add(EyeLayer);
                 mapEye.Refresh();
             }
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
         ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
     }
 }
Example #3
0
        private IRenderStruct ExportLayerRender(MapObjects2.MapLayer layer)
        {
            object oLayerRender = layer.Renderer;

            if (oLayerRender == null)
            {
                return(null);
            }

            if (oLayerRender is MapObjects2.ValueMapRenderer)
            {
                return(this.ExportValueRender(layer.Renderer as MapObjects2.ValueMapRenderer));
            }
            else if (oLayerRender is MapObjects2.ClassBreaksRenderer)
            {
                return(this.ExportClassBreakRender(layer.Renderer as MapObjects2.ClassBreaksRenderer));
            }
            else if (oLayerRender is MapObjects2.LabelRenderer)
            {
                return(this.ExportLabelRender(layer.Renderer as MapObjects2.LabelRenderer));
            }
            else if (oLayerRender is MapObjects2.GroupRenderer)
            {
                return(this.ExportGroupRender(layer.Renderer as MapObjects2.GroupRenderer));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        public MapLayerInfoStruct LoadLayerInfos(MapObjects2.MapLayer layer, string fileName, double minScale, double maxScale)
        {
            MapLayerInfoStruct oMapLayerStruct = new MapLayerInfoStruct();

            oMapLayerStruct.Name      = layer.Name;
            oMapLayerStruct.FileName  = fileName;
            oMapLayerStruct.ShapeType = (short)layer.shapeType;
            oMapLayerStruct.MinLevel  = minScale;
            oMapLayerStruct.MaxLevel  = maxScale;

            this.DeconvertSymbol(layer.Symbol, oMapLayerStruct.Symbol);
            oMapLayerStruct.Render = this.ExportLayerRender(layer);

            return(oMapLayerStruct);
        }
Example #5
0
        private void LoadDataToGridView(MapObjects2.MapLayer layer)
        {
            Utilities.LayerProperty oLayerProperty = new MapConfigure.Utilities.LayerProperty();

            try
            {
                this.lblLayerDescription.Text = string.Format("ͼ²ãÃû³Æ £º {0}", layer.Name);

                System.Data.DataTable dtlayerAttributes = oLayerProperty.GetAttributesByLayer(layer);
                this.dgvViewAttributes.DataSource = dtlayerAttributes;
            }
            finally
            {
                oLayerProperty = null;
            }
        }
Example #6
0
        public MapLayerInfoStruct LoadLayerInfos(MapObjects2.MapLayer layer, string fileName, double minScale, double maxScale)
        {
            MapLayerInfoStruct oMapLayerStruct = new MapLayerInfoStruct();

            oMapLayerStruct.AliasName   = layer.Name;
            oMapLayerStruct.DataSetName = System.IO.Path.GetFileNameWithoutExtension(fileName);
            oMapLayerStruct.FileName    = fileName;
            oMapLayerStruct.ShapeType   = (short)layer.shapeType;
            oMapLayerStruct.MinLevel    = minScale;
            oMapLayerStruct.MaxLevel    = maxScale;

            this.DeconvertSymbol(layer.Symbol, oMapLayerStruct.Symbol);
            oMapLayerStruct.Render = this.ExportLayerRender(layer);

            return(oMapLayerStruct);
        }
Example #7
0
        public void SaveMapInfosToProject(AxMapObjects2.AxMap mapControl, string saveFileName, MapStruct currentMapInfos)
        {
            MapStruct oMapStruct = new MapStruct();

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

            // oMapStruct.CoordinateSystem = mapControl.CoordinateSystem;

            short iLayersCount = mapControl.Layers.Count;

            for (short i = (short)(iLayersCount - 1); i >= 0; i--)
            {
                object oLayer = mapControl.Layers.Item(i);

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

                    oMapLayerStruct.FileName    = currentMapInfos.FindLayer(oMapLayer.Name).FileName;
                    oMapLayerStruct.LayerType   = (short)oMapLayer.LayerType;
                    oMapLayerStruct.AliasName   = oMapLayer.Name;
                    oMapLayerStruct.DataSetName = System.IO.Path.GetFileNameWithoutExtension(oMapLayerStruct.FileName);
                    oMapLayerStruct.ShapeType   = (short)oMapLayer.shapeType;
                    oMapLayerStruct.Visible     = oMapLayer.Visible;
                    oMapLayerStruct.MinLevel    = int.Parse(oMapLayer.Tag.Split('-')[0]);
                    oMapLayerStruct.MaxLevel    = int.Parse(oMapLayer.Tag.Split('-')[1]);

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

            this.SerializeProject(oMapStruct, saveFileName);
        }
Example #8
0
 private void SetLayerRender(MapObjects2.MapLayer layer, IRenderStruct render)
 {
     if (render.LayerRenderType == RenderType.ValueRender)
     {
         layer.Renderer = this.GetValueRender(render as ValueRenderStruct);
     }
     else if (render.LayerRenderType == RenderType.ClassBreakRender)
     {
         layer.Renderer = this.GetClassBreakRender(render as ClassBreakRenderStruct);
     }
     else if (render.LayerRenderType == RenderType.LabelRender)
     {
         layer.Renderer = this.GetLabelRender(render as LabelRenderStruct);
     }
     else if (render.LayerRenderType == RenderType.GroupRender)
     {
         layer.Renderer = this.GetGroupRender(render as GroupRenderStruct);
     }
 }
Example #9
0
        public frmLayerProperties(AxMapObjects2.AxMap mapControl, object layer)
        {
            InitializeComponent();

            this._mapControl = mapControl;

            if (layer == null)
            {
                throw new Exception("layer is null,please set a valid layer.");
            }

            if (layer is MapObjects2.ImageLayer)
            {
                this._imageLayer = layer as MapObjects2.ImageLayer;
            }
            else if (layer is MapObjects2.MapLayer)
            {
                this._mapLayer = layer as MapObjects2.MapLayer;
            }


            if (this._mapLayer != null)
            {
                int    iColumnsCount = this._mapLayer.Records.TableDesc.FieldCount;
                string sFieldName    = string.Empty;
                this._fieldsList.Clear();
                this._numFieldsList.Clear();

                for (short i = 0; i < iColumnsCount; i++)
                {
                    sFieldName = this._mapLayer.Records.TableDesc.get_FieldName(i);
                    MapObjects2.Field oField = this._mapLayer.Records.Fields.Item(sFieldName);
                    this._fieldsList.Add(oField.Name);

                    if (oField.Type == MapObjects2.FieldTypeConstants.moDouble || oField.Type == MapObjects2.FieldTypeConstants.moLong)
                    {
                        this._numFieldsList.Add(oField.Name);
                    }
                }
            }
        }
Example #10
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);
        }
Example #11
0
        public System.Data.DataTable GetAttributesByLayer(MapObjects2.MapLayer layer)
        {
            if (layer == null)
            {
                return(null);
            }

            short     iColumnsCount    = 0;
            string    sFieldName       = null;
            DataTable dtLayerAttribute = new DataTable();

            MapObjects2.Recordset oAttributeRecordes = layer.Records;
            MapObjects2.TableDesc oAtributeColumns   = oAttributeRecordes.TableDesc;

            iColumnsCount = oAtributeColumns.FieldCount;
            for (short i = 0; i < iColumnsCount; i++)
            {
                DataColumn oColumn = new DataColumn(oAtributeColumns.get_FieldName(i));
                dtLayerAttribute.Columns.Add(oColumn);
            }

            oAttributeRecordes.MoveFirst();
            while (!oAttributeRecordes.EOF)
            {
                DataRow oNewRow = dtLayerAttribute.NewRow();

                for (short i = 0; i < iColumnsCount; i++)
                {
                    sFieldName          = oAttributeRecordes.TableDesc.get_FieldName(i).ToString();
                    oNewRow[sFieldName] = oAttributeRecordes.Fields.Item(sFieldName).ValueAsString;
                }

                dtLayerAttribute.Rows.Add(oNewRow);
                oAttributeRecordes.MoveNext();
            }

            return(dtLayerAttribute);
        }
Example #12
0
        /// <summary>
        /// load layer from file, layer ->axMap1 ocx
        /// </summary>
        private void InitializeMainMap()
        {
            axMap1.Layers.Clear();
            axMap1.ScrollBars=false;
            MapObjects2.DataConnection mapCon=new MapObjects2.DataConnectionClass();
            try
            {
                mapCon.Database=Path.GetDirectoryName(Application.ExecutablePath)+"\\shaps\\";
                for(int m=0;m<3;m++)
                {
                    for(int i=0;i<mapLayer.m_layers.Length;i++)
                    {
                        MapObjects2.MapLayer layer;
                        layer = new MapObjects2.MapLayer();
                        layer.GeoDataset=mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                        switch (m)
                        {
                            case 0:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                                    continue;
                                break;
                            case 1:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypeLine)
                                    continue;
                                break;
                            case 2:
                                if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePoint)
                                    continue;
                                break;
                            default:
                                continue;
                        }
                        mapLayer.m_layers[i].layer=layer;
                        axMap1.Layers.Add(mapLayer.m_layers[i].layer);
                        mapLayer.m_layers[i].layer.Symbol.Style=(short)mapLayer.m_layers[i].dtSymbol;
                        mapLayer.m_layers[i].layer.Symbol.Color=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        mapLayer.m_layers[i].layer.Symbol.Size=(short)mapLayer.m_layers[i].dtSize;
                        if(mapLayer.m_layers[i].layer.shapeType==MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                            mapLayer.m_layers[i].layer.Symbol.OutlineColor=System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                    }
                }

                zoomRect=axMap1.Extent;
                zoomRect.ScaleRectangle(SC);
                                //axMap1.CenterAt(118.6679,39.5009);
                axMap1.Extent=zoomRect;
                axMap1.Refresh();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("����ͼ��ʧ��,�����������!","����",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ExceptionHandler.Handle("����ͼ��ʧ��,�����������!", ex );
            }
        }
Example #13
0
        /// <summary>
        /// load layer from file, layer -> mapMain ocx
        /// </summary>
        private void InitializeMainMap()
        {
            mapMain.Layers.Clear();
            mapMain.ScrollBars = false;
            MapObjects2.DataConnection mapCon = new MapObjects2.DataConnectionClass();
            try
            {
                mapCon.Database = Path.GetDirectoryName(Application.ExecutablePath) + "\\shaps\\";
                for (int m = 0; m < 3; m++)
                {
                    for (int i = 0; i < mapLayer.m_layers.Length; i++)
                    {
                        MapObjects2.MapLayer layer;
                        layer            = new MapObjects2.MapLayer();
                        layer.GeoDataset = mapCon.FindGeoDataset(mapLayer.m_layers[i].dtFile);
                        switch (m)
                        {
                        case 0:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                            {
                                continue;
                            }
                            break;

                        case 1:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypeLine)
                            {
                                continue;
                            }
                            break;

                        case 2:
                            if (layer.shapeType != MapObjects2.ShapeTypeConstants.moShapeTypePoint)
                            {
                                continue;
                            }
                            break;

                        default:
                            continue;
                        }
                        mapLayer.m_layers[i].layer = layer;
                        mapMain.Layers.Add(mapLayer.m_layers[i].layer);
                        mapLayer.m_layers[i].layer.Symbol.Style = (short)mapLayer.m_layers[i].dtSymbol;
                        mapLayer.m_layers[i].layer.Symbol.Color = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        mapLayer.m_layers[i].layer.Symbol.Size  = (short)mapLayer.m_layers[i].dtSize;
                        if (mapLayer.m_layers[i].layer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                        {
                            mapLayer.m_layers[i].layer.Symbol.OutlineColor = System.Convert.ToUInt32(mapLayer.m_layers[i].dtColor);
                        }
                    }
                }

                zoomRect = mapMain.Extent;
                zoomRect.ScaleRectangle(SC);
                //				mapMain.CenterAt(STAT.X,STAT.Y);
                mapMain.Extent = zoomRect;
                mapMain.Refresh();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("加载图层失败,请重新起动软件!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ExceptionHandler.Handle("加载图层失败,请重新起动软件!", ex);
            }
        }
Example #14
0
        public frmAttributesData(MapObjects2.MapLayer layer)
        {
            InitializeComponent();

            this._mapLayer = layer;
        }
Example #15
0
        public void LoadLayersToLegend(AxMapObjects2.AxMap mapObject)
        {
            if (mapObject == null)
            {
                return;
            }

            this._mapObject = mapObject;

            int iLayersCount = 0;

            iLayersCount = mapObject.Layers.Count;
            pnlLegend.Controls.Clear();

            int iCtrlsCounter = 0;

            for (int i = 0; i < iLayersCount; i++)
            {
                CheckBox oCkbLayer = new CheckBox();
                object   oLayer    = mapObject.Layers.Item(i);
                if (oLayer is MapObjects2.MapLayer)
                {
                    MapObjects2.MapLayer oMapLayer = oLayer as MapObjects2.MapLayer;
                    oCkbLayer.Text    = oMapLayer.Name;
                    oCkbLayer.Checked = oMapLayer.Visible;

                    if (oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePoint || oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypeMultipoint)
                    {
                        oCkbLayer.Image = Properties.Resources.pointShape;
                    }
                    else if (oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypeEllipse || oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypeLine || oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypeRectangle)
                    {
                        oCkbLayer.Image = Properties.Resources.lineShape;
                    }
                    else if (oMapLayer.shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                    {
                        oCkbLayer.Image = Properties.Resources.polygonShape;
                    }
                }
                else if (oLayer is MapObjects2.ImageLayer)
                {
                    MapObjects2.ImageLayer oImageLayer = oLayer as MapObjects2.ImageLayer;

                    oCkbLayer.Image   = Properties.Resources.image;
                    oCkbLayer.Text    = oImageLayer.Name;
                    oCkbLayer.Checked = oImageLayer.Visible;
                }

                oCkbLayer.Visible           = true;
                oCkbLayer.AutoSize          = true;
                oCkbLayer.FlatStyle         = FlatStyle.Flat;
                oCkbLayer.Anchor            = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left);
                oCkbLayer.ImageAlign        = ContentAlignment.MiddleLeft;
                oCkbLayer.TextAlign         = ContentAlignment.MiddleRight;
                oCkbLayer.TextImageRelation = TextImageRelation.ImageBeforeText;
                oCkbLayer.ContextMenuStrip  = mnuLayerProperty;

                oCkbLayer.CheckedChanged += new EventHandler(CkbLayer_CheckedChanged);
                oCkbLayer.MouseDown      += new MouseEventHandler(oCkbLayer_MouseDown);

                this.pnlLegend.Controls.Add(oCkbLayer);
                oCkbLayer.Location = new System.Drawing.Point(30, iCtrlsCounter * (oCkbLayer.Height + 12) + 20);
                iCtrlsCounter++;
            }

            this.pnlLegend.Refresh();
        }
Example #16
0
        public frmAttributesData(MapObjects2.MapLayer layer)
        {
            InitializeComponent();

            this._mapLayer = layer;
        }