Пример #1
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 );
            }
        }
Пример #2
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;
                }
            }
        }
Пример #3
0
 /// <summary>
 /// 
 /// </summary>
 private void zoomFull()
 {
     axMap1.Extent=axMap1.FullExtent ;
     axMap1.Extent=axMap1.Extent;
     zoomRect=axMap1.Extent;
     zoomRect.ScaleRectangle(SC);
     //			axMap1.CenterAt(STAT.X,STAT.Y);
     axMap1.Extent=zoomRect;
     axMap1.Extent=axMap1.Extent;
     axMap1.Refresh();
     axMap2.Extent=axMap2.Extent;
     axMap1.MousePointer=MapObjects2.MousePointerConstants.moDefault;
     tBarIndex=0;
     ShowLayers();
 }
Пример #4
0
        /// <summary>
        /// mapMain mouse down event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapMain_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.mapMain.TrackRectangle();
                if (zoomInRect.Height > 0 && zoomInRect.Width > 0)
                {
                    mapMain.Extent = zoomInRect;
                    mapMain.Extent = mapMain.Extent;
                }
                else
                {
                    zoomInPt = mapMain.ToMapPoint(e.x, e.y);
                    mapMain.CenterAt(zoomInPt.X, zoomInPt.Y);
                    zoomRect = mapMain.Extent;
                    sr       = 0.5;
                    zoomRect.ScaleRectangle(sr);
                    mapMain.Extent = zoomRect;
                    mapMain.Extent = mapMain.Extent;
                }

                ShowLayers();
                mapEye.Extent = mapEye.Extent;
                iScale        = System.Convert.ToInt64(mapLayer.CalcScale(this.mapMain));
                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 = mapMain.TrackRectangle();
                if (zoomOutRect.Height > 0 && zoomOutRect.Width > 0)
                {
                    sr = mapMain.Extent.Width / zoomOutRect.Width;
                    mapMain.CenterAt(zoomOutRect.Center.X, zoomOutRect.Center.Y);
                }
                else
                {
                    zoomOutPt = mapMain.ToMapPoint(e.x, e.y);
                    mapMain.CenterAt(zoomOutPt.X, zoomOutPt.Y);
                    sr = 2;
                }
                zoomRect = mapMain.Extent;
                zoomRect.ScaleRectangle(sr);
                mapMain.Extent = zoomRect;
                mapMain.Extent = mapMain.Extent;

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

            case 3:
            {
                mapMain.Pan();
                mapEye.Extent = mapEye.Extent;
                break;
            }

            default:
            {
                if (radioButton1.Checked == false)
                {
                    MapObjects2.Point point;
                    point = mapMain.ToMapPoint(e.x, e.y);
                    for (int i = 0; i < s_Info.Length; i++)
                    {
                        if (point.X > System.Convert.ToDouble(
                                s_Info[i].s_East) - 5 &&
                            point.X <System.Convert.ToDouble(s_Info[i].s_East) + 5 &&
                                     point.Y> System.Convert.ToDouble(s_Info[i].s_West) - 5 &&
                            point.Y < System.Convert.ToDouble(s_Info[i].s_West) + 5
                            )
                        {
                            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")
                            {
                                frmDataNowD f = new frmDataNowD(GisMapSName);
                                f.ShowDialog();
                            }
                            else
                            {
                                frmDataNow f = new frmDataNow(GisMapSName);
                                f.ShowDialog();
                            }
                        }
                    }
                }
                break;
            }
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
 public void DrawMainMapViewExtent(MapObjects2.Rectangle viewExtent)
 {
     this.mapControl.TrackingLayer.ClearEvents();
     this.mapControl.TrackingLayer.AddEvent(viewExtent, 0);
 }