Exemplo n.º 1
0
        private void mapControl_BeforeLayerDraw(object sender, AxMapObjects2._DMapEvents_BeforeLayerDrawEvent e)
        {
            if (e.index == this.mapControl.Layers.Count - 1)
            {
                //绘制导航地图中的视图范围框线
                frmNavigation.Instance.DrawMainMapViewExtent(this.mapControl.Extent);

                //更新比例尺
                MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();
                this._mapScale     = oMapOper.ComputeMapScale(this.mapControl);
                this.lblScale.Text = string.Format("比例尺 : 1 : {0}", this._mapScale.ToString());
            }

            object oLayer    = this.mapControl.Layers.Item(e.index);
            int    iMinScale = 0;
            int    iMaxScale = 0;

            string[] sScales = new string[2];

            if (oLayer is MapObjects2.MapLayer)
            {
                sScales   = (oLayer as MapLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0)
                {
                    return;
                }

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as MapLayer).Visible = true;
                }
                else
                {
                    (oLayer as MapLayer).Visible = false;
                }
            }
            else if (oLayer is MapObjects2.ImageLayer)
            {
                sScales   = (oLayer as ImageLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0)
                {
                    return;
                }

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as ImageLayer).Visible = true;
                }
                else
                {
                    (oLayer as ImageLayer).Visible = false;
                }
            }
        }
Exemplo n.º 2
0
        private void mnuAddLayers_Click(object sender, EventArgs e)
        {
            OpenFileDialog oFileDialog = new OpenFileDialog();
            oFileDialog.Filter = "ESRI Shapefile(*.shp) | *.shp| All Support Format(*.*) | *.*";
            oFileDialog.Multiselect = true;

            if (oFileDialog.ShowDialog() == DialogResult.OK)
            {
                MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();
                List<string> oLayerPaths = new List<string>(oFileDialog.FileNames);

                oMapOper.LoadLayers(oLayerPaths, GlobeVariables.MapInfosCollection, GlobeVariables.MapControl);
                frmLegend.Instance.LoadLayer();
                frmNavigation.Instance.LoadBackgroudLayer(GlobeVariables.MapInfosCollection.Layers);
            }
        }
Exemplo n.º 3
0
        private void mnuAddLayers_Click(object sender, EventArgs e)
        {
            OpenFileDialog oFileDialog = new OpenFileDialog();

            oFileDialog.Filter      = "ESRI Shapefile(*.shp) | *.shp| All Support Format(*.*) | *.*";
            oFileDialog.Multiselect = true;

            if (oFileDialog.ShowDialog() == DialogResult.OK)
            {
                MapUtil.MapOperation oMapOper    = new MapUtil.MapOperation();
                List <string>        oLayerPaths = new List <string>(oFileDialog.FileNames);

                oMapOper.LoadLayers(oLayerPaths, GlobeVariables.MapInfosCollection, GlobeVariables.MapControl);
                frmLegend.Instance.LoadLayer();
                frmNavigation.Instance.LoadBackgroudLayer(GlobeVariables.MapInfosCollection.Layers);
            }
        }
Exemplo n.º 4
0
        private void mapControl_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
            MapObjects2.Point    oMousePosition = mapControl.ToMapPoint(e.x, e.y);
            MapUtil.MapOperation oMapOper       = new MapUtil.MapOperation();

            switch (GlobeVariables.CurrentOperation)
            {
            case MapUtil.MapOperationType.ZoomIn:
                oMapOper.ZoomInMap(mapControl.TrackRectangle(), ref mapControl);
                break;

            case MapUtil.MapOperationType.ZoomOut:
                oMapOper.ZoomOutMap(mapControl.TrackRectangle(), ref mapControl);
                break;

            case MapUtil.MapOperationType.Pan:
                mapControl.Pan();
                break;

            case MapUtil.MapOperationType.Measure:
                this._measureLine    = mapControl.TrackLine();
                this.labMeasure.Text = string.Format("长度 : {0} 米", oMapOper.ComputeDistance(this._measureLine).ToString());
                break;

            case MapUtil.MapOperationType.Identify:
                MapUtil.FeatureInformations oFeatureInfos = oMapOper.GetIdentifyFeatureInfos(oMousePosition, this.mapControl, GlobeVariables.MapInfosCollection);
                this._frmIdentify.UpdateFeatureInfos(oFeatureInfos, MousePosition);
                break;

            case MapUtil.MapOperationType.FetchPoint:
                this.OnPointFetched(oMousePosition);
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
        //public void LoadLayersToLegendControl(ProjectUtil.MapStruct mapInfosCollection, System.Windows.Forms.ImageList imageList, ref System.Windows.Forms.TreeView legendControl)
        //{
        //    if (legendControl.Nodes.Count == 0)
        //        legendControl.Nodes.Add("layergroup", "ͼ��", imageList.Images.IndexOfKey("layergroup"));
        //    string sShapeType = string.Empty;
        //    foreach (ProjectUtil.ILayerStruct item in mapInfosCollection.Layers)
        //    {
        //        if (item is ProjectUtil.MapLayerInfoStruct)
        //        {
        //            sShapeType = ((MapObjects2.ShapeTypeConstants)(item as ProjectUtil.MapLayerInfoStruct).ShapeType).ToString();
        //            legendControl.Nodes[0].Nodes.Add(sShapeType,item.AliasName, imageList.Images.IndexOfKey(sShapeType));
        //        }
        //        else if (item is ProjectUtil.ImageLayerInfoStruct)
        //        {
        //            legendControl.Nodes[0].Nodes.Add("ImageLayer", item.AliasName, imageList.Images.IndexOfKey("ImageLayer"));
        //        }
        //    }
        //}
        public FeatureInformations GetIdentifyFeatureInfos(MapObjects2.Point mousePosition,AxMapObjects2.AxMap mapControl,MapProject.MapStruct mapInfosCollection)
        {
            FeatureInformations oFeatureInfos = null;

            foreach (ILayerStruct oLayerInfos in mapInfosCollection.Layers)
            {
                if (oLayerInfos.LayerType != (short)LayerTypeConstants.moMapLayer)
                    continue;

                MapUtil.MapOperation oMapOper = new MapOperation();
                MapObjects2.MapLayer oMapLayer = oMapOper.GetLayerByName(mapControl, oLayerInfos.AliasName) as MapObjects2.MapLayer;

                if (oMapLayer.Visible == false)
                    continue;

                Recordset oSelectedRecords = oMapLayer.SearchShape(mousePosition,SearchMethodConstants.moAreaIntersect, "");

                if (oSelectedRecords.EOF)
                    continue;

                oSelectedRecords.MoveFirst();

                oFeatureInfos = new FeatureInformations();
                oFeatureInfos.CurrentLayerInfos = oLayerInfos;
                oFeatureInfos.Geometry = oSelectedRecords.Fields.Item("shape").Value;

                TableDesc oTableDesc = oSelectedRecords.TableDesc;
                oFeatureInfos.FieldsAndValuesCollection = new Dictionary<string,string>();
                int iFieldsCount = oTableDesc.FieldCount;
                string sFieldName = "";
                string sValue = "";

                for (short i = 0; i < iFieldsCount; i++)
                {
                    sFieldName = oTableDesc.get_FieldName(i);
                    sValue = oSelectedRecords.Fields.Item(sFieldName).ValueAsString;
                    oFeatureInfos.FieldsAndValuesCollection.Add(sFieldName, sValue);
                }

                break;
            }

            return oFeatureInfos;
        }
Exemplo n.º 6
0
        private void mapControl_BeforeLayerDraw(object sender, AxMapObjects2._DMapEvents_BeforeLayerDrawEvent e)
        {
            if (e.index == this.mapControl.Layers.Count - 1)
            {
                //���Ƶ�����ͼ�е���ͼ��Χ����
                frmNavigation.Instance.DrawMainMapViewExtent(this.mapControl.Extent);

                //���±�����
                MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();
                this._mapScale = oMapOper.ComputeMapScale(this.mapControl);
                this.lblScale.Text = string.Format("������ �� 1 : {0}", this._mapScale.ToString());
            }

            object oLayer = this.mapControl.Layers.Item(e.index);
            int iMinScale = 0;
            int iMaxScale = 0;
            string[] sScales = new string[2];

            if (oLayer is MapObjects2.MapLayer)
            {
                sScales = (oLayer as MapLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as MapLayer).Visible = true;
                }
                else
                {
                    (oLayer as MapLayer).Visible = false;
                }
            }
            else if (oLayer is MapObjects2.ImageLayer)
            {
                sScales = (oLayer as ImageLayer).Tag.Split('-');
                iMinScale = int.Parse(sScales[0]);
                iMaxScale = int.Parse(sScales[1]);

                if (iMinScale == 0 && iMaxScale == 0) return;

                if (this._mapScale >= iMinScale && this._mapScale <= iMaxScale)
                {
                    (oLayer as ImageLayer).Visible = true;
                }
                else
                {
                    (oLayer as ImageLayer).Visible = false;
                }
            }
        }
Exemplo n.º 7
0
        private void mapControl_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
            MapObjects2.Point oMousePosition = mapControl.ToMapPoint(e.x, e.y);
            MapUtil.MapOperation oMapOper = new MapUtil.MapOperation();

            switch (GlobeVariables.CurrentOperation)
            {
                case MapUtil.MapOperationType.ZoomIn:
                    oMapOper.ZoomInMap(mapControl.TrackRectangle(), ref mapControl);
                    break;
                case MapUtil.MapOperationType.ZoomOut:
                    oMapOper.ZoomOutMap(mapControl.TrackRectangle(), ref mapControl);
                    break;
                case MapUtil.MapOperationType.Pan:
                    mapControl.Pan();
                    break;
                case MapUtil.MapOperationType.Measure:
                    this._measureLine = mapControl.TrackLine();
                    this.labMeasure.Text = string.Format("���� �� {0} ��", oMapOper.ComputeDistance(this._measureLine).ToString());
                    break;
                case MapUtil.MapOperationType.Identify:
                    MapUtil.FeatureInformations oFeatureInfos = oMapOper.GetIdentifyFeatureInfos(oMousePosition, this.mapControl,GlobeVariables.MapInfosCollection);
                    this._frmIdentify.UpdateFeatureInfos(oFeatureInfos, MousePosition);
                    break;
                case MapUtil.MapOperationType.FetchPoint:
                    this.OnPointFetched(oMousePosition);
                    break;
                default:
                    break;
            }
        }