Exemple #1
0
        public void AddNorthArrow(IPageLayout pageLayout)
        {
            IGraphicsContainer container  = pageLayout as IGraphicsContainer;
            IActiveView        activeView = pageLayout as IActiveView;
            // 获得MapFrame
            IFrameElement frameElement = container.FindFrame(activeView.FocusMap);
            IMapFrame     mapFrame     = frameElement as IMapFrame;
            //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround
            UID uid = new UIDClass();

            uid.Value = "esriCarto.MarkerNorthArrow";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null);
            //设置MapSurroundFrame中指北针的点符号
            IMapSurround      mapSurround      = mapSurroundFrame.MapSurround;
            IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow;
            IMarkerSymbol     markerSymbol     = markerNorthArrow.MarkerSymbol;

            markerSymbol.Size             = 18;
            markerNorthArrow.MarkerSymbol = markerSymbol;
            //QI,确定mapSurroundFrame的位置
            IElement  element  = mapSurroundFrame as IElement;
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(0.2, 0.2, 5, 5);
            element.Geometry = envelope;
            //使用IGraphicsContainer接口添加显示
            container.AddElement(element, 0);
            activeView.Refresh();
        }
        /// <添加指北针>
        ///
        /// </添加指北针>
        /// <returns></returns>
        public bool AddNorthArrow()
        {
            IStyleSelector pStyleSelector = new NorthArrowSelectorClass();
            bool           m_bOK          = pStyleSelector.DoModal(0);

            if (m_bOK == true)
            {
                IMarkerNorthArrow pMarkerNorthArrow = pStyleSelector.GetStyle(0) as IMarkerNorthArrow;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 5);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.MarkerNorthArrow";
                IMap pMap = mainPage.ActiveView.FocusMap;
                IGraphicsContainer graphicsContainer = mainPage.ActiveView as IGraphicsContainer;
                IActiveView        activeView        = mainPage.ActiveView as IActiveView;
                IFrameElement      frameElement      = graphicsContainer.FindFrame(pMap);
                IMapFrame          mapFrame          = frameElement as IMapFrame;
                IMapSurroundFrame  mapSurroundFrame  = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null);
                IElement           element           = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;

                IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow;
                markerNorthArrow.MarkerSymbol = pMarkerNorthArrow.MarkerSymbol;
            }
            return(true);
        }
Exemple #3
0
        public static void AddNorthArrow(AxPageLayoutControl pageLayoutControl, IEnvelope envelope)
        {
            IUID uid = new UIDClass()
            {
                Value = "esriCarto.MarkerNorthArrow"
            };

            IFrameElement frameElement = (pageLayoutControl.PageLayout as IGraphicsContainer)
                                         .FindFrame(pageLayoutControl.ActiveView.FocusMap);
            IMapFrame         mapFrame         = frameElement as IMapFrame;
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as UID, null); // Dynamic Cast
            IElement          element          = mapSurroundFrame as IElement;                   // Dynamic Cast

            element.Geometry = envelope;
            element.Activate(pageLayoutControl.ActiveView.ScreenDisplay);
            (pageLayoutControl.PageLayout as IGraphicsContainer).AddElement(element, 0);
            IMapSurround mapSurround = mapSurroundFrame.MapSurround;

            // Change out the default north arrow
            IMarkerNorthArrow      markerNorthArrow      = mapSurround as IMarkerNorthArrow;       // Dynamic Cast
            IMarkerSymbol          markerSymbol          = markerNorthArrow.MarkerSymbol;
            ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ICharacterMarkerSymbol; // Dynamic Cast

            characterMarkerSymbol.CharacterIndex = 202;
            markerNorthArrow.MarkerSymbol        = characterMarkerSymbol;
        }
Exemple #4
0
//        指北针

        public void AddNorthArrow(AxPageLayoutControl axPageLayout)
        {
            //删除已经存在的指北针

            IElement pElement = axPageLayout.FindElementByName("NorthArrows");

            if (pElement != null)
            {
                axPageLayout.ActiveView.GraphicsContainer.DeleteElement(pElement);
            }


            IGraphicsContainer container  = axPageLayout.PageLayout as IGraphicsContainer;
            IActiveView        activeView = axPageLayout.PageLayout as IActiveView;
            // 获得MapFrame
            IFrameElement frameElement = container.FindFrame(activeView.FocusMap);
            IMapFrame     mapFrame     = frameElement as IMapFrame;
            //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround
            UID uid = new UIDClass();

            uid.Value = "esriCarto.MarkerNorthArrow";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null);
            //设置MapSurroundFrame中指北针的点符号
            IMapSurround      mapSurround      = mapSurroundFrame.MapSurround;
            IMarkerNorthArrow markerNorthArrow = mapSurround as IMarkerNorthArrow;
            IMarkerSymbol     markerSymbol     = markerNorthArrow.MarkerSymbol;

            markerSymbol.Size             = 48;
            markerNorthArrow.MarkerSymbol = markerSymbol;

            //QI,确定mapSurroundFrame的位置
            IElement  element  = mapSurroundFrame as IElement;
            IEnvelope envelope = new EnvelopeClass();

            double x = 15;
            double y = 22;

            envelope.PutCoords(x, y, x + 5, y + 5);
            element.Geometry = envelope;
            //使用IGraphicsContainer接口添加显示
            container.AddElement(element, 0);
            activeView.Refresh();
        }
Exemple #5
0
        public void AddNorthArrow(IPageLayout pageLayout, IMap map, double posX, double posY, double division)
        {
            try
            {
                if (pageLayout == null || map == null)
                {
                    return;
                }

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(posX - division, posY - division, posX, posY); //  Specify the location and size of the north arrow

                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.MarkerNorthArrow";

                // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location
                // Activate it and add it to the PageLayout's graphics container
                IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;                                      // Dynamic Cast
                IActiveView        activeView        = pageLayout as IActiveView;                                             // Dynamic Cast
                IFrameElement      frameElement      = graphicsContainer.FindFrame(map);
                IMapFrame          mapFrame          = frameElement as IMapFrame;                                             // Dynamic Cast
                IMapSurroundFrame  mapSurroundFrame  = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast
                IElement           element           = mapSurroundFrame as IElement;                                          // Dynamic Cast
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;

                // Change out the default north arrow
                IMarkerNorthArrow      markerNorthArrow      = mapSurround as IMarkerNorthArrow;       // Dynamic Cast
                IMarkerSymbol          markerSymbol          = markerNorthArrow.MarkerSymbol;
                ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ICharacterMarkerSymbol; // Dynamic Cast
                characterMarkerSymbol.CharacterIndex = 174;                                            // change the symbol for the North Arrow
                markerNorthArrow.MarkerSymbol        = characterMarkerSymbol;
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
        private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e)
        {
            button2.Enabled     = true;
            m_pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;
            if (m_pStyleGalleryItem == null)
            {
                return;
            }
            //获取新的指北针
            pMarkerNorthArrow = m_pStyleGalleryItem.Item as IMarkerNorthArrow;
            if (pMarkerNorthArrow == null)
            {
                return;
            }
            pCharacterMarkerSymbol      = pMarkerNorthArrow.MarkerSymbol as ICharacterMarkerSymbol;
            pCharacterMarkerSymbol.Size = 100;
            System.Drawing.Image image = PageLayoutInsert.CreatePictureFromSymbol((ISymbol)this.pCharacterMarkerSymbol, this.picBoxPreview.Width, this.picBoxPreview.Height, 0);
            this.picBoxPreview.Image = image;

            textBoxSize.Text  = pCharacterMarkerSymbol.Size.ToString();
            textBoxAngle.Text = pCharacterMarkerSymbol.Angle.ToString();
        }