예제 #1
0
        public void AddScaleBar()
        {
            IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer;
            //Get the MapFrame
            IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap);

            if (mapFrame == null)
            {
                return;
            }

            //Create a legend
            UID uID = new UIDClass();

            uID.Value = "esriCarto.ScaleLine";
            //Create a MapSurroundFrame from the MapFrame
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

            if (mapSurroundFrame == null)
            {
                return;
            }
            if (mapSurroundFrame.MapSurround == null)
            {
                return;
            }

            // m_styleSelector = new ScaleBarSelectorClass();
            IEnvelope m_envelop = new EnvelopeClass();

            m_envelop.PutCoords(5, 5, 10, 10);

            ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars;
            frmLegendItemSymbol frmScaleBar     = new frmLegendItemSymbol();
            IStyleGalleryItem   pstyGallertItem = frmScaleBar.GetItem(styleClass);

            if (pstyGallertItem == null)
            {
                return;
            }
            IScaleBar pScalebar = pstyGallertItem.Item as IScaleBar;

            pScalebar.Units = m_pagelayoutControl.ActiveView.FocusMap.MapUnits;
            pScalebar.Map   = m_pagelayoutControl.ActiveView.FocusMap;
            pScalebar.UseMapSettings();

            IMapSurround m_mapSurround;

            m_mapSurround = (IMapSurround)pScalebar;
            mapSurroundFrame.MapSurround = m_mapSurround;
            IElement m_element = (IElement)mapSurroundFrame;

            m_element.Geometry = m_envelop;
            m_pagelayoutControl.AddElement(m_element, Type.Missing, Type.Missing, "ScaleLine", 3);
            m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #2
0
        private void btnLegendSymbol_Click(object sender, EventArgs e)
        { //未设置成功??????????????
            frmLegendItemSymbol frmLengendSymbol = new frmLegendItemSymbol();

            ESRI.ArcGIS.Controls.esriSymbologyStyleClass pStyleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassLegendItems;
            IStyleGalleryItem pStyleGalleryItem = frmLengendSymbol.GetItem(pStyleClass);


            // pTextSymbol = frmLengendSymbol.pTextSymbol;
        }
 public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass)
 {
     //Set the style class
     axSymbologyControl1.StyleClass = styleClass;
     axSymbologyControl1.Update();
     //Show the modal form
     this.ShowDialog();
     //Return the selected label style
     return(m_styleGalleryItem);
 }
예제 #4
0
        public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass)
        {
            pStyleGalleryItem = null;
            //Set the style class of SymbologyControl1
            axSymbologyControl1.StyleClass = styleClass;

            //Change cursor
            this.Cursor = Cursors.Default;

            //Show the modal form
            this.ShowDialog();

            //return the label style that has been selected from the SymbologyControl
            return(pStyleGalleryItem);
        }
예제 #5
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ChangeFrameBackGround.OnClick implementation
            // IActiveView pActiveView;
            //IGraphicsContainer pGraphicsContainer;

            //  IMap pMap;
            // pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
            ///  pMap = pActiveView.FocusMap;
            // pGraphicsContainer = pActiveView as IGraphicsContainer;

            // pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            //  IStyleSelector pStyleSelector;
            // pStyleSelector = new BackgroundSelectorClass();
            //􁰒􂼎􄗝􁢽􁇍􄈵􁸚􁇍􄈵􃒭􂫼􁠋
            // bool m_bOK;
            //  m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);

            //􁔧􂫼􁠋􁣝􀏟(cancel􁯊􄗔􀟎􄖛􂿟)
            // if (!m_bOK) return;
            //  IBackground pBackground;
            //􃦋􁕫􀏔􀏾􃚠􁱃􁇍􄈵
            // pBackground = pStyleSelector.GetStyle(0) as IBackground;
            //􄆒􃕂
            if (m_element is IMapFrame)
            {
                m_MapFrame = m_element as IMapFrame;
            }
            frmLegendItemSymbol frmBackGround = new frmLegendItemSymbol();

            ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassBackgrounds;
            IStyleGalleryItem pStyleGalleryItem = frmBackGround.GetItem(styleClass);

            if (pStyleGalleryItem != null)
            {
                m_MapFrame.Background = (IBackground)pStyleGalleryItem.Item;
            }
            else
            {
                return;
            }
            // pMapFrame.Background = pBackground;
            //􀠋􁮄􃚠􁱃

            m_PageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
            m_PageLayoutControl.ActiveView.Refresh();
        }
예제 #6
0
        public IStyleGalleryItem GetItem(ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass)
        {
            //Retrieve the selected area/line patch style from the SymbologyControl
            m_styleGalleryItem = null;
            //disable ok button
            button1.Enabled = false;

            //Set the style class of SymbologyControl1
            axSymbologyControl1.StyleClass = styleClass;
            //Unselect any selected item in the current style class
            axSymbologyControl1.GetStyleClass(styleClass).UnselectItem();

            //Show the modal form
            this.ShowDialog();

            //return the label style that has been selected from the SymbologyControl
            return(m_styleGalleryItem);
        }
예제 #7
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ChangeFrameShadow.OnClick implementation

            /* IActiveView pActiveView;
             * IGraphicsContainer pGraphicsContainer;
             * IMapFrame pMapFrame;
             * IMap pMap;
             * pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
             * pMap = pActiveView.FocusMap;
             * pGraphicsContainer = pActiveView as IGraphicsContainer;
             * pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
             * IStyleSelector pStyleSelector;
             * pStyleSelector = new ShadowSelectorClass();
             * //􁰒􂼎􄗝􁢽􁇍􄈵􁸚􁇍􄈵􃒭􂫼􁠋
             * bool m_bOK;
             * m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);
             * //􀽖􁵰􂫼􁠋􁣝cancel􁣝􄪂􀟭􄗔􀟎
             * if (!m_bOK) return;
             * IShadow pShadow;
             * //􀒢􄗝􁢽􀰼􀐁􁕫􀠄􀏔􀏾IShadow􁇍􄈵
             * pShadow = pStyleSelector.GetStyle(0) as IShadow;
             * IFrameProperties pFrameProperties;
             * pFrameProperties = pMapFrame as IFrameProperties;
             * //􄆒􃕂*/
            IElementProperties pElementProties = m_element as IElementProperties;

            if (m_element is IMapFrame)
            {
                m_MapFrame = m_element as IMapFrame;
            }
            else if (pElementProties.Type == "Map Surround Frame")
            {
                IMapSurroundFrame pMapSurrounFrame = pElementProties as IMapSurroundFrame;
                if (pMapSurrounFrame.MapSurround.Name == "Legend")
                {
                    //ILegend pLegend = m_element as ILegend;
                    //为了改变边框,背景,阴影等样式
                    //IMapSurround pmapSurd = (IMapSurround)pLegend;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //  pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar")
                {
                    // IScaleBar pScaleBatr = m_element as IScaleBar;
                    // IMapSurround pmapSurd = (IMapSurround)pScaleBatr ;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //  pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "Scale Text")
                {
                    //IScaleText pScaleText = m_element as IScaleText;
                    // IMapSurround pmapSurd = (IMapSurround)pScaleText;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "North Arrow")
                {
                    // INorthArrow pNorthArrow = m_element as INorthArrow;
                    //  IMapSurround pmapSurd = (IMapSurround)pNorthArrow ;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    // pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
            }
            IFrameProperties pFrameProperties;

            pFrameProperties = m_MapFrame as IFrameProperties;
            frmLegendItemSymbol frmBackGround = new frmLegendItemSymbol();

            ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassShadows;
            IStyleGalleryItem pStyleGalleryItem = frmBackGround.GetItem(styleClass);

            if (pStyleGalleryItem != null)
            {
                pFrameProperties.Shadow = (IShadow )pStyleGalleryItem.Item;
            }
            else
            {
                return;
            }
            // pFrameProperties.Shadow = pShadow;
            m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
            m_pageLayoutControl.ActiveView.Refresh();
        }
예제 #8
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ChangeFrameBorder.OnClick implementation

            /*
             * IActiveView pActiveView;
             * IGraphicsContainer pGraphicsContainer;
             * IMapFrame pMapFrame;
             * IMap pMap;
             * pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
             * pMap = pActiveView.FocusMap;
             * pGraphicsContainer = pActiveView as IGraphicsContainer;
             * pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
             * IStyleSelector pStyleSelector;
             * //􁮄􁓎􀏔􀏾􄖍􁸚􄗝􁢽􀰼􁇍􄈵
             * pStyleSelector = new BorderSelectorClass();
             * bool m_bOK;
             * m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);
             * if (!m_bOK) return;
             * IBorder pBorder;
             * pBorder = pStyleSelector.GetStyle(0) as IBorder; //􁕫􀠄􀏔􀏾 IBorder􁇍􄈵
             */
            IElementProperties pElementProties = m_element as IElementProperties;

            if (m_element is IMapFrame)
            {
                m_MapFrame = m_element as IMapFrame;
            }
            else if (pElementProties.Type == "Map Surround Frame")
            {
                IMapSurroundFrame pMapSurrounFrame = pElementProties as IMapSurroundFrame;
                if (pMapSurrounFrame.MapSurround.Name == "Legend")
                {
                    //ILegend pLegend = m_element as ILegend;
                    //为了改变边框,背景,阴影等样式
                    //IMapSurround pmapSurd = (IMapSurround)pLegend;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //  pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar")
                {
                    // IScaleBar pScaleBatr = m_element as IScaleBar;
                    // IMapSurround pmapSurd = (IMapSurround)pScaleBatr ;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //  pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "Scale Text")
                {
                    //IScaleText pScaleText = m_element as IScaleText;
                    // IMapSurround pmapSurd = (IMapSurround)pScaleText;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    //pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
                else if (pMapSurrounFrame.MapSurround.Name == "North Arrow")
                {
                    // INorthArrow pNorthArrow = m_element as INorthArrow;
                    //  IMapSurround pmapSurd = (IMapSurround)pNorthArrow ;
                    IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                    // pmapSurdFrm.MapSurround = pmapSurd;
                    IMapFrame pMapFrm = new MapFrameClass();
                    pMapFrm    = pmapSurdFrm.MapFrame;
                    m_MapFrame = pMapFrm;
                }
            }

            frmLegendItemSymbol frmBackGround = new frmLegendItemSymbol();

            ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassBorders;
            IStyleGalleryItem pStyleGalleryItem = frmBackGround.GetItem(styleClass);

            if (pStyleGalleryItem != null)
            {
                m_MapFrame.Border = (IBorder )pStyleGalleryItem.Item;
            }
            else
            {
                return;
            }
            m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
예제 #9
0
        private void axPageLayoutControl1_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e)
        {
            if (m_element != null)
            {
                IElementProperties pElementProp = m_element as IElementProperties;

                if (pElementProp.Type == "Text")
                {
                    ITextElement  pTextElement = pElementProp as ITextElement;
                    frmTextSymbol frmText      = new frmTextSymbol(ref pTextElement);
                    frmText.ShowDialog();
                    pElementProp = pTextElement as IElementProperties;
                    m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null);
                    m_pageLayoutControl.ActiveView.Refresh();
                }
                else if (pElementProp.Type == "Map Surround Frame")
                {
                    IMapSurroundFrame pMapSurrounFrame = pElementProp as IMapSurroundFrame;
                    if (pMapSurrounFrame.MapSurround.Name == "Legend")
                    {
                        frmLegendWizard frmLegedWizard = new frmLegendWizard(m_Map, m_pageLayoutControl, pMapSurrounFrame);
                        frmLegedWizard.ShowDialog(); //修改图例属性
                    }
                    else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Hollow Scale Bar" ||
                             pMapSurrounFrame.MapSurround.Name == "Double lternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Scale Line" ||
                             pMapSurrounFrame.MapSurround.Name == "Single Division Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Stepped Scale Line")
                    {
                        ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars;
                        frmLegendItemSymbol frmScaleBar     = new frmLegendItemSymbol();
                        IStyleGalleryItem   pstyGallertItem = frmScaleBar.GetItem(styleClass);//获取样式
                        IScaleBar           pscaleBar       = pMapSurrounFrame.MapSurround as IScaleBar;
                        esriUnits           punits          = pscaleBar.Units;
                        if (pstyGallertItem != null)
                        {
                            pscaleBar = (IScaleBar)pstyGallertItem.Item;
                        }
                        else
                        {
                            return;
                        }
                        pscaleBar.Map   = m_pageLayoutControl.ActiveView.FocusMap; //重新设置比例尺依附的地图及单位
                        pscaleBar.Units = punits;
                        pscaleBar.UseMapSettings();
                        pscaleBar.Refresh();
                        pMapSurrounFrame.MapSurround = pscaleBar as IMapSurround;                    //旧的比例尺样式转换为新的比例尺样式
                        m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); //刷新
                    }
                    else if (pMapSurrounFrame.MapSurround.Name == "Scale Text")
                    {
                        frmLegendItemSymbol frmTextScal     = new frmLegendItemSymbol();
                        IStyleGalleryItem   pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts);
                        IScaleText          pScaleText      = pMapSurrounFrame.MapSurround as IScaleText;
                        esriUnits           pUnits          = pScaleText.MapUnits;
                        if (pStyGalleryItem != null)
                        {
                            pScaleText = (IScaleText)pStyGalleryItem.Item;
                        }
                        else
                        {
                            return;
                        }
                        pScaleText.Map               = m_pageLayoutControl.ActiveView.FocusMap;
                        pScaleText.MapUnits          = pScaleText.MapUnits;
                        pMapSurrounFrame.MapSurround = pScaleText as IMapSurround;
                        m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    }
                    else if (pMapSurrounFrame.MapSurround.Name.Trim() == "North Arrow")
                    {
                        INorthArrow         northArrow      = pMapSurrounFrame.MapSurround as INorthArrow;
                        frmNorthArrowSymbol frmNorthArrow   = new frmNorthArrowSymbol();
                        IStyleGalleryItem   pstyGallertItem = frmNorthArrow.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);;
                        if (pstyGallertItem != null)
                        {
                            northArrow = (INorthArrow)pstyGallertItem.Item;
                            northArrow.CalibrationAngle = frmNorthArrow.Angle();
                        }
                        else
                        {
                            return;
                        }
                        pMapSurrounFrame.MapSurround = (IMapSurround)northArrow;
                        m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    }
                }
            }
        }