Esempio n. 1
0
        public override IElement GetElement(IPageLayout ipageLayout_0)
        {
            if (!((base.m_pElement != null) && this.bool_0))
            {
                this.bool_0 = true;
                this.CreateElement(ipageLayout_0);
            }
            if (base.m_pElement == null)
            {
                return(null);
            }
            IPoint    position = this.GetPosition(ipageLayout_0);
            IEnvelope bounds   = new EnvelopeClass();

            base.m_pElement.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, bounds);
            if ((base.m_pElement as IMapSurroundFrame).MapSurround is IScaleText)
            {
                IScaleText mapSurround = (base.m_pElement as IMapSurroundFrame).MapSurround as IScaleText;
                try
                {
                    mapSurround.Map = (ipageLayout_0 as IActiveView).FocusMap;
                    mapSurround.Refresh();
                    switch (base.ElementLocation.LocationType)
                    {
                    case LocationType.LeftUpper:
                    case LocationType.LeftCenter:
                    case LocationType.LeftLower:
                        position.X -= bounds.Height;
                        goto Label_0112;

                    case LocationType.RightUpper:
                    case LocationType.RightCenter:
                    case LocationType.RightLower:
                        goto Label_0112;

                    case LocationType.LowerLeft:
                    case LocationType.LowerCenter:
                    case LocationType.LowerRight:
                        position.Y -= bounds.Height;
                        goto Label_0112;
                    }
                }
                catch
                {
                }
            }
Label_0112:
            if (!bounds.IsEmpty)
            {
                IEnvelope envelope2 = new EnvelopeClass();
                envelope2.PutCoords(position.X, position.Y, position.X + bounds.Width, position.Y + bounds.Height);
                base.m_pElement.Geometry = envelope2;
            }
            return(base.m_pElement);
        }
Esempio n. 2
0
        //创建比例尺
        private void CreateScale()
        {
            if (StyleGalleryItem == null)
            {
                return;
            }

            IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView.GraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(m_hookHelper.ActiveView.FocusMap) as IMapFrame;

            if (pMapFrame == null)
            {
                return;
            }

            if (StyleGalleryItem.Item is IScaleBar)
            {
                IScaleBar pScaleBar = (IScaleBar)StyleGalleryItem.Item;
                pScaleBar.Refresh();
                IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();
                pMapSurroundFrame.MapFrame = pMapFrame;

                pMapSurroundFrame.MapSurround = (IMapSurround)pScaleBar;
                IElement pElement = (IElement)pMapSurroundFrame;

                //添加和指北针一样大小的窗口
                double pScaleBarSize = 15;
                //显示结果大小
                IActiveView pActiveView = m_hookHelper.ActiveView;
                IPageLayout pPageLayout = (IPageLayout)pActiveView;
                IPage       pPage       = pPageLayout.Page;

                double pWidth  = pPage.PrintableBounds.XMin + 2;
                double pHeigth = pPage.PrintableBounds.YMin + 2;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.PutCoords(pWidth, pHeigth, pWidth + 10, pHeigth + 1);
                pElement.Geometry = (IGeometry)pEnv;

                //Add the element to the graphics container
                pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0);
                //Refresh
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null);
            }
            else if (StyleGalleryItem.Item is IScaleText)
            {
                IScaleText pScaleText = (IScaleText)StyleGalleryItem.Item;
                pScaleText.Refresh();
                IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();
                pMapSurroundFrame.MapFrame = pMapFrame;

                pMapSurroundFrame.MapSurround = (IMapSurround)pScaleText;
                IElement pElement = (IElement)pMapSurroundFrame;

                //显示结果大小
                IActiveView pActiveView = m_hookHelper.ActiveView;
                IPageLayout pPageLayout = (IPageLayout)pActiveView;
                IPage       pPage       = pPageLayout.Page;


                double pWidth  = pPage.PrintableBounds.XMin + 2;
                double pHeigth = pPage.PrintableBounds.YMin + 2;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.PutCoords(pWidth, pHeigth, pWidth + 10, pHeigth + 1);
                pElement.Geometry = (IGeometry)pEnv;

                //Add the element to the graphics container
                pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0);
                //Refresh
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null);
            }
        }