Exemple #1
0
        private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            IPoint pPoint = new PointClass();

            pPoint.X = e.pageX;
            pPoint.Y = e.pageY;
            Console.WriteLine(pPoint.X + "," + pPoint.Y);
            pElement = GeomapLoad.getElement(axPageLayoutControl1, pPoint);
            IBorder pBorder = new SymbolBorder();

            pBorder.Gap = 1.0;
            (pElement as IMapSurroundFrame).Border = pBorder;
            axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemple #2
0
 private void axPageLayoutControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e)
 {
     if (this.m_Application.CurrentTool != null)
     {
         this.m_CurrentTool = this.m_ToolCol[this.m_Application.CurrentTool];
         if (e.button == 1)
         {
             this.m_CurrentTool.OnMouseDown(e.button, e.shift, (int)e.pageX, (int)e.pageY);
         }
         else if (e.button == 2)
         {
             this.m_CurrentTool.OnContextMenu(e.x, e.y);
         }
     }
 }
        private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                return;
            }

            //Create an envelope by tracking a rectangle
            IEnvelope envelope = axPageLayoutControl1.TrackRectangle();

            //Create a map frame element with a new map
            IMapFrame mapFrame = new MapFrameClass();

            mapFrame.Map = new MapClass();

            //Add the map frame to the PageLayoutControl with specified geometry
            axPageLayoutControl1.AddElement((IElement)mapFrame, envelope, null, null, 0);
            //Refresh the PageLayoutControl
            axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        //点击地图框事件
        private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                IPageLayout        pPageLayout        = axPageLayoutControl1.PageLayout;;
                IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
                IActiveView        pActiveView        = pPageLayout as IActiveView;
                IMapFrame          pMapFrame;
                IMapSurroundFrame  pMapSurroundFrame;
                IElement           pElement;
                switch (tag)
                {
                    #region 添加标题
                case 1:
                    ITextElement pTextElement = new TextElementClass();
                    pTextElement.Text   = title;
                    pTextElement.Symbol = pTextSymbol;
                    pElement            = pTextElement as IElement;
                    try
                    {
                        pElement.Geometry = axPageLayoutControl1.TrackRectangle();
                    }
                    catch
                    {
                        MessageBox.Show("请拉框选择范围!", "提示");
                        return;
                    }
                    pGraphicsContainer.AddElement(pElement, 0);
                    axPageLayoutControl1.Refresh();
                    tag = 0;
                    break;
                    #endregion

                    #region 添加图例
                case 2:
                    pLegend2 = new LegendClass_2();
                    pElement = axPageLayoutControl1.FindElementByName("legend");
                    if (pElement != null)
                    {
                        pGraphicsContainer.DeleteElement(pElement);
                    }

                    pElementTypeName = "lenend";
                    pUid             = new UIDClass();
                    pUid.Value       = "esriCato.Legend";
                    if (pGraphicsContainer == null)
                    {
                        return;
                    }
                    pMapSurround     = pLegend2 as IMapSurround;
                    pMapSurround.Map = pActiveView.FocusMap;
                    pMapFrame        = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;
                    if (pMapFrame == null)
                    {
                        return;
                    }

                    pMapSurroundFrame                  = new MapSurroundFrameClass();
                    pMapSurroundFrame                  = pMapFrame.CreateSurroundFrame(pUid, null);
                    pMapSurroundFrame.MapSurround      = pMapSurround;
                    pMapSurroundFrame.MapSurround.Name = pElementTypeName;
                    pMapSurroundFrame.MapFrame         = pMapFrame;

                    pElement = pMapSurroundFrame as IElement;
                    try
                    {
                        pElement.Geometry = axPageLayoutControl1.TrackRectangle();
                    }
                    catch
                    {
                        MessageBox.Show("请拉框选择范围!", "提示");
                        return;
                    }
                    pElement.Activate(pActiveView.ScreenDisplay);
                    pElement.Draw(pActiveView.ScreenDisplay, null);

                    pGraphicsContainer.AddElement(pElement, 0);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

                    //图例标题字体样式
                    pLegend2.Title            = "图例";
                    pTitltFont.Name           = "黑体";
                    pTitltFont.Bold           = true;
                    pTitltFont.Size           = 16;
                    pTitltTextSymbol.Color    = ColorToIColor(Color.Black);
                    pTitltTextSymbol.Font     = pTitltFont;
                    pLenendFormat.TitleSymbol = pTitltTextSymbol;

                    //图例图层名字体样式
                    pLayerFont.Name       = "仿宋_GB2312";
                    pLayerFont.Size       = 13;
                    pLayerTextSymbol.Font = pLayerFont;

                    //图例标签字体样式
                    pLabelFont.Name       = "仿宋_GB2312";
                    pLabelFont.Size       = 13;
                    pLabelTextSymbol.Font = pLayerFont;

                    for (int i = 0; i < pLenendItemsString.Count; i++)
                    {
                        for (int j = 0; j < pLegend2.ItemCount; j++)
                        {
                            if (pLenendItemsString[i].ToString() == pLegend2.get_Item(j).Layer.Name)
                            {
                                pLegend2.RemoveItem(j);
                            }
                        }
                    }
                    pLegend2.AdjustColumns(pColumnCount);
                    pLegend2.Refresh();
                    tag = 0;
                    break;
                    #endregion

                    #region 添加指北针
                case 3:
                    if (pGraphicsContainer == null)
                    {
                        return;
                    }
                    pElement = axPageLayoutControl1.FindElementByName("northarrow");
                    if (pElement != null)
                    {
                        pGraphicsContainer.DeleteElement(pElement);
                    }
                    pElementTypeName = "northarrow";
                    pUid             = new UIDClass();
                    pUid.Value       = "esriCato.MarkerNorthArrow";

                    pMapFrame                     = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;
                    pMapSurroundFrame             = new MapSurroundFrameClass();
                    pMapSurroundFrame             = pMapFrame.CreateSurroundFrame(pUid, null);
                    pMapSurroundFrame.MapSurround = pNorthArrowStyleGalleryItem.Item as IMapSurround;
                    pElement = pMapSurroundFrame as IElement;
                    try
                    {
                        pElement.Geometry = axPageLayoutControl1.TrackRectangle();
                    }
                    catch
                    {
                        MessageBox.Show("请拉框选择范围!", "提示");
                        return;
                    }
                    pGraphicsContainer.AddElement(pElement, 0);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    tag = 0;
                    break;
                    #endregion

                    #region 添加比例尺
                case 4:
                    if (pGraphicsContainer == null)
                    {
                        return;
                    }
                    pElement = axPageLayoutControl1.FindElementByName("scalebar");
                    if (pElement != null)
                    {
                        pGraphicsContainer.DeleteElement(pElement);
                    }
                    IScaleBar pScaleBar;
                    pScaleBar           = pScaleStyleGalleryItem.Item as IScaleBar;
                    pScaleBar.Units     = esriUnits.esriKilometers;
                    pScaleBar.UnitLabel = " KM";
                    pElementTypeName    = "scalebar";
                    pUid       = new UIDClass();
                    pUid.Value = "esriCato.AlternatingScaleBar";

                    pMapFrame                     = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;
                    pMapSurroundFrame             = new MapSurroundFrameClass();
                    pMapSurroundFrame             = pMapFrame.CreateSurroundFrame(pUid, null);
                    pMapSurroundFrame.MapSurround = pScaleStyleGalleryItem.Item as IMapSurround;
                    pElement = pMapSurroundFrame as IElement;
                    try
                    {
                        pElement.Geometry = axPageLayoutControl1.TrackRectangle();
                    }
                    catch
                    {
                        MessageBox.Show("请拉框选择范围!", "提示");
                    }
                    pGraphicsContainer.AddElement(pElement, 0);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    tag = 0;
                    break;
                    #endregion
                }
            }
        }