Example #1
0
File: Info.cs Project: hkiaipc/guye
        /// <summary>
        /// 
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public double CalcScale(AxMapObjects2.AxMap map)
        {
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
            MPoint[] pts = new MPoint[2];
            pts[0] = new MPoint();
            pts[0].x = map.Extent.Left;
            pts[0].y = map.Extent.Bottom;
            pts[1] = new MPoint();
            pts[1].x = map.Extent.Right;
            pts[1].y = map.Extent.Top;
            double Len1=pts[1].x-pts[0].x;
            double Len2=pts[1].y-pts[0].y;
            return Len1*Len2;

            #region ...
            //			System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)map.hWnd);
            //
            //			MPoint[] pts = new MPoint[2];
            //			pts[0] = new MPoint();
            //			pts[0].x = map.Extent.Left;
            //			pts[0].y = map.Extent.Top;
            //			pts[1] = new MPoint();
            //			pts[1].x = map.Extent.Right;
            //			pts[1].y = map.Extent.Top;
            //
            //			double dLen1 = this.CalcLenght(pts,2);
            //
            //			double dLen2 = map.Width / g.DpiX * 2.54 /100;
            //
            //			return dLen1 / dLen2;
            #endregion //...
        }
Example #2
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 #3
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 #4
0
        public ReplayOperation(AxMapObjects2.AxMap mapControl)
        {
            this._mapControl = mapControl;
            this._trackingLayer = mapControl.TrackingLayer;
            this.AddEventSymbols();

            this._trackingPointSymbolIndex = this._trackingLayer.SymbolCount - 1;
            this._trackingLineSymbolIndex = this._trackingLayer.SymbolCount - 2;
        }
Example #5
0
        public bool DeleteLayer(object layer, AxMapObjects2.AxMap mapControl)
        {
            if (layer == null || mapControl == null) return false;

            short iLayersCount = mapControl.Layers.Count;

            for (short i = 0; i < iLayersCount; i++)
            {
                if (layer.Equals(mapControl.Layers.Item(i)))
                {
                    mapControl.Layers.Remove(i);
                    return true;
                }
            }

            return false;
        }
Example #6
0
        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;
        }
Example #7
0
        /// <summary>
        /// �����ͼ�ĵ�ǰ������
        /// </summary>
        /// <param name="mapControl"></param>
        /// <returns></returns>
        public double ComputeMapScale(AxMapObjects2.AxMap mapControl)
        {
            System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd((System.IntPtr)mapControl.hWnd);

            Point oPoint1 = new PointClass();
            oPoint1.X = mapControl.Extent.Left;
            oPoint1.Y = mapControl.Extent.Top;

            Point oPoint2 = new PointClass();
            oPoint2.X = mapControl.Extent.Right;
            oPoint2.Y =mapControl.Extent.Top;

            double dLen1 = this.ComputeDistance(oPoint1, oPoint2);
            double dLen2 = mapControl.Width / g.DpiX * 2.54 / 100;

            g.Dispose();

            return dLen1 / dLen2;
        }
Example #8
0
        public void LoadLayersToNavigation(AxMapObjects2.AxMap mapControl)
        {
            if (mapControl == null || mapControl.Layers.Count == 0) return;

            object oLayer = null;
            object oBackLayer = null;

            short iLayersCount = mapControl.Layers.Count;

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

                if (oLayer is MapObjects2.MapLayer &&  (oLayer as MapObjects2.MapLayer).shapeType == MapObjects2.ShapeTypeConstants.moShapeTypePolygon)
                    oBackLayer = oLayer;
            }

            if (oBackLayer == null && iLayersCount > 0)
                oBackLayer = mapControl.Layers.Item(iLayersCount - 1);

            this.mapControl.Layers.Clear();
            this.mapControl.Layers.Add(oBackLayer);
            this.mapControl.Refresh();
        }
Example #9
0
 public void ZoomInMap(Rectangle mapExtent, ref AxMapObjects2.AxMap mapControl)
 {
     mapControl.Extent = mapExtent.Extent;
 }
Example #10
0
        public void ZoomAndCenterMap(double scaleFactor, Point centerPoint, ref AxMapObjects2.AxMap mapControl)
        {
            Rectangle oExtent = new RectangleClass();
            oExtent.Left = mapControl.FullExtent.Left;
            oExtent.Right = mapControl.FullExtent.Right;
            oExtent.Top = mapControl.FullExtent.Top;
            oExtent.Bottom = mapControl.FullExtent.Bottom;

            oExtent.ScaleRectangle(scaleFactor);
            oExtent.Offset(centerPoint.X - oExtent.Center.X, centerPoint.Y - oExtent.Center.Y);

            mapControl.Extent = oExtent;
        }
Example #11
0
        /// <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);
                }
            }
        }
Example #12
0
 public string GetLayerDatasetName(string layerAliasName,AxMapObjects2.AxMap mapControl)
 {
     throw new NotImplementedException();
 }
Example #13
0
        public object GetLayerByName(AxMapObjects2.AxMap mapControl, string layerName)
        {
            short iLayersCount = mapControl.Layers.Count;

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

                if (oLayer is MapObjects2.MapLayer && (oLayer as MapObjects2.MapLayer).Name.Equals(layerName))return oLayer;
                else if(oLayer is MapObjects2.ImageLayer && (oLayer as MapObjects2.ImageLayer).Name.Equals(layerName))return oLayer;
            }

            return null;
        }
Example #14
0
 private void mapControl_AfterTrackingLayerDraw(object sender, AxMapObjects2._DMapEvents_AfterTrackingLayerDrawEvent e)
 {
 }
Example #15
0
        private void mapControl_AfterTrackingLayerDraw(object sender, AxMapObjects2._DMapEvents_AfterTrackingLayerDrawEvent e)
        {
            //���Ƶ�����ͼ�е���ͼ��Χ����
            frmNavigation.Instance.DrawMainMapViewExtent(this.mapControl.Extent);

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

            Invoke((MethodInvoker)delegate{this._geoeventUpdate.UpdateLabelLocation(this._currentMessageCollection);});
        }
Example #16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMap2_AfterLayerDraw(object sender, AxMapObjects2._DMapEvents_AfterLayerDrawEvent e)
 {
     if(e.index!=0)
         return;
     symE=new MapObjects2.SymbolClass();
     symE.OutlineColor=(uint)MapObjects2.ColorConstants.moRed;
     symE.Outline=true;
     symE.SymbolType=MapObjects2.SymbolTypeConstants.moFillSymbol;
     symE.Style=(short)MapObjects2.FillStyleConstants.moTransparentFill;
     axMap2.DrawShape(axMap1.Extent,symE);
     MapObjects2.TextSymbol tsy=new MapObjects2.TextSymbolClass();
 }
Example #17
0
 public GeoeventUpdate(AxMapObjects2.AxMap mapControl)
 {
     this._mapControl = mapControl;
     this._trackingLayer = this._mapControl.TrackingLayer;
     this.InitCarSymbols();
 }
Example #18
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;
        }
Example #19
0
 private void mapControl_MouseMoveEvent(object sender, AxMapObjects2._DMapEvents_MouseMoveEvent e)
 {
     MapObjects2.Point oMousePosition = mapControl.ToMapPoint(e.x, e.y);
     this.labCoordinates.Text = string.Format("���� �� X = {0}, Y = {1}", oMousePosition.X.ToString(), oMousePosition.Y.ToString());
 }
Example #20
0
        private void mapControl_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
            MapObjects2.Point oMousePosition = mapControl.ToMapPoint(e.x, e.y);
            MapUtil.MapOperation oMapOper = new GPSTrackingMonitor.MapUtil.MapOperation();

            switch (GlobeVariables.CurrentOperation)
            {
                case GPSTrackingMonitor.MapUtil.MapOperationType.ZoomIn:
                    oMapOper.ZoomInMap(mapControl.TrackRectangle(),ref mapControl);
                    break;
                case GPSTrackingMonitor.MapUtil.MapOperationType.ZoomOut:
                    oMapOper.ZoomOutMap(mapControl.TrackRectangle(), ref mapControl);
                    break;
                case GPSTrackingMonitor.MapUtil.MapOperationType.Pan:
                    mapControl.Pan();
                    break;
                case GPSTrackingMonitor.MapUtil.MapOperationType.Measure:
                    this._measureLine = mapControl.TrackLine();
                    this.labMeasure.Text = string.Format("���� �� {0} ��", oMapOper.ComputeDistance(this._measureLine).ToString());
                    break;
                case GPSTrackingMonitor.MapUtil.MapOperationType.Identify:
                    MapUtil.FeatureInformations oFeatureInfos = oMapOper.GetIdentifyFeatureInfos(oMousePosition, this.mapControl,GlobeVariables.MapInfosCollection);
                    this._frmIdentify.UpdateFeatureInfos(oFeatureInfos, MousePosition);
                    break;
                case GPSTrackingMonitor.MapUtil.MapOperationType.FetchPoint:
                    this.OnPointFetched(oMousePosition);
                    break;
                default:
                    break;
            }
        }
Example #21
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;
                }
            }
        }
Example #22
0
 public void ZoomOutMap(Rectangle mapExtent, ref AxMapObjects2.AxMap mapControl)
 {
     Rectangle oRectangle = mapControl.Extent;
     oRectangle.ScaleRectangle(mapControl.Extent.Height / mapExtent.Extent.Height);
     mapControl.Extent = oRectangle;
 }
Example #23
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void axMap2_MouseUpEvent(object sender, AxMapObjects2._DMapEvents_MouseUpEvent e)
 {
     MapObjects2.Point pointE;
     pointE = axMap2.ToMapPoint(e.x, e.y);
     axMap1.CenterAt(pointE.X,pointE.Y);
     axMap2.Extent =axMap2.Extent;
 }
Example #24
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 #25
0
        /// <summary>
        /// axMap1 mouse down event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMap1_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
            switch(tBarIndex)
            {
                case 1:
                {
                    MapObjects2.Rectangle zoomInRect=new MapObjects2.RectangleClass();
                    MapObjects2.Point zoomInPt=new MapObjects2.PointClass();
                    zoomInRect=this.axMap1.TrackRectangle();
                    if (zoomInRect.Height>0 && zoomInRect.Width>0)
                    {
                        axMap1.Extent=zoomInRect;
                        axMap1.Extent=axMap1.Extent;
                    }
                    else
                    {
                        zoomInPt=axMap1.ToMapPoint(e.x,e.y);
                        axMap1.CenterAt(zoomInPt.X,zoomInPt.Y);
                        zoomRect=axMap1.Extent;
                        sr=0.5;
                        zoomRect.ScaleRectangle(sr);
                        axMap1.Extent=zoomRect;
                        axMap1.Extent=axMap1.Extent;
                    }

                    ShowLayers();
                    axMap2.Extent=axMap2.Extent;
                    iScale=System.Convert.ToInt64(mapLayer.CalcScale(this.axMap1));
            //					MessageBox.Show(iScale.ToString());
            //                    if(iScale<=MAX_SCALE)
            //                    {
            //                        MessageBox.Show("ѡ��ͼ�α�����С��������ѡ��!","����",MessageBoxButtons.OK,MessageBoxIcon.Warning);
            //                        zoomFull();
            //                        return;
            //                    }
                    break;
                }

                case 2:
                {
                    MapObjects2.Rectangle zoomOutRect=new MapObjects2.RectangleClass();
                    MapObjects2.Point zoomOutPt=new MapObjects2.PointClass();
                    zoomOutRect=axMap1.TrackRectangle();
                    if(zoomOutRect.Height>0 && zoomOutRect.Width>0)
                    {
                        sr=axMap1.Extent.Width/zoomOutRect.Width;
                        axMap1.CenterAt(zoomOutRect.Center.X,zoomOutRect.Center.Y);
                    }
                    else
                    {
                        zoomOutPt=axMap1.ToMapPoint(e.x,e.y);
                        axMap1.CenterAt(zoomOutPt.X,zoomOutPt.Y);
                        sr=2;
                    }
                    zoomRect=axMap1.Extent;
                    zoomRect.ScaleRectangle(sr);
                    axMap1.Extent=zoomRect;
                    axMap1.Extent=axMap1.Extent;

                    ShowLayers();
                    axMap2.Extent=axMap2.Extent;
                    break;
                }

                case 3:
                {
                    axMap1.Pan();
                   axMap2.Extent=axMap2.Extent;
                    break;
                }

                default:
                {
                    if(radioButton1.Checked==false)
                    {
                        MapObjects2.Point point;
                        point=axMap1.ToMapPoint(e.x,e.y);

                              // MessageBox.Show(point.X.ToString());
                              // MessageBox.Show(point.Y.ToString());

                        for(int i=0;i<s_Info.Length;i++)
                        {
                            if(point.X>System.Convert.ToDouble(
                                s_Info[i].s_East)-20 &&
                                point.X<System.Convert.ToDouble(s_Info[i].s_East)+20 &&
                                point.Y>System.Convert.ToDouble(s_Info[i].s_West)-20 &&
                                point.Y<System.Convert.ToDouble(s_Info[i].s_West)+20
                                )
                            {
                        //        Point position=new Point();
                                GisMapSName=s_Info[i].s_Name;
                                GisMapSNo=s_Info[i].s_No;
                                //						position.X=e.x+POSITIONX;
                                //						position.Y=e.y+POSITIONY;
                                //                      GisMapMenu.Show(this,position);
                                if(GisMapSNo=="2"||GisMapSNo=="3")
                                {
                                    frmDataNowD f=new frmDataNowD(GisMapSName,GisMapSNo);
                                    f.ShowDialog();
                                    break;
                                }
                                else
                                {
                                    frmDataNow f=new frmDataNow(GisMapSName);
                                    f.ShowDialog();
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }
Example #26
0
        /// <summary>
        /// ����ͼ�㼯��
        /// </summary>
        /// <param name="layerPaths">ͼ��·������</param>
        /// <param name="map">��ͼ����</param>
        public List<LayerInformations> LoadLayers(List<string> layerPaths, ref AxMapObjects2.AxMap mapControl)
        {
            BaseHandler.MapManager oMapManager = new GPSTrackingMonitor.BaseHandler.MapManager();
            List<LayerInformations> oLayerfosCollection = new List<LayerInformations>();

            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);
                    mapControl.Layers.Add(oMapLayer);

                    oLayerfosCollection.Add(new LayerInformations(oMapLayer, oMapLayer.GeoDataset.Name, oLayerType, oMapLayer.shapeType));
                }
                else if (oLayerType == LayerTypeConstants.moImageLayer)
                {
                    ImageLayer oImageLayer = oMapManager.GetSingleImageLayer(sLayerPath);
                    mapControl.Layers.Add(oImageLayer);

                    oLayerfosCollection.Add(new LayerInformations(oImageLayer, oImageLayer.Name, oLayerType, (ShapeTypeConstants)(-1)));
                }
            }

            return oLayerfosCollection;
        }