Exemplo n.º 1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdNorthArrowAttribute.OnClick implementation

            LibCerMap.FrmNorthArrwoAttribute frm = new LibCerMap.FrmNorthArrwoAttribute();
            frm.ShowDialog();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdNorthArrowAttribute.OnClick implementation

            IGraphicsContainer       GraphicsContainer       = m_hookHelper.ActiveView.GraphicsContainer;
            IGraphicsContainerSelect GraphicsContainerSelect = GraphicsContainer as IGraphicsContainerSelect;
            int SelectElementCount = GraphicsContainerSelect.ElementSelectionCount;

            IEnumElement pEnumElement = GraphicsContainerSelect.SelectedElements;
            ////判断选择要素的类型是否在两种以上
            IElement           pElement           = pEnumElement.Next();
            IElementProperties pElementProperties = pElement as IElementProperties;
            //第一个要素属性类型
            string pSelElementType = pElementProperties.Type;

            for (int i = 0; i < SelectElementCount; i++)
            {
                if (pSelElementType != pElementProperties.Type)
                {
                    MessageBox.Show("请选择同一种类型的要素!");
                    return;
                }
                pElement           = pEnumElement.Next();
                pElementProperties = pElement as IElementProperties;
            }

            //当选择要素类型相同时,开始进行修改样式
            IEnumElement EnumElement = GraphicsContainerSelect.SelectedElements;

            EnumElement.Reset();
            IElement           Element           = EnumElement.Next();
            IElementProperties ElementProperties = Element as IElementProperties;

            //当选择的要素为指北针、比例尺、图例、DataFrame时,必须选择一个
            if (ElementProperties.Type == "地图整饰要素框架" || ElementProperties.Type == "Map Surround Frame" || ElementProperties.Type == "Data Frame")
            {
                if (SelectElementCount == 1)
                {
                    if (ElementProperties.Name == "North Arrow")
                    {
                        LibCerMap.FrmNorthArrwoAttribute frm = new LibCerMap.FrmNorthArrwoAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Scale Line" || ElementProperties.Name == "比例尺" || ElementProperties.Name.Contains("Scale Bar"))
                    {
                        LibCerMap.FrmScaleBarAttribute frm = new LibCerMap.FrmScaleBarAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Scale Text")
                    {
                        LibCerMap.FrmScaleTextAttribute frm = new LibCerMap.FrmScaleTextAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Name == "Legend" || ElementProperties.Name == "图例")
                    {
                        LibCerMap.FrmLegendAttribute frm = new LibCerMap.FrmLegendAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                        frm.ShowDialog();
                    }
                    else if (ElementProperties.Type == "Data Frame")
                    {
                        int SelIndex = 0;
                        LibCerMap.FrmFrameAttrSel frmsel = new LibCerMap.FrmFrameAttrSel();
                        frmsel.ShowDialog();
                        if (frmsel.DialogResult == DialogResult.OK)
                        {
                            SelIndex = frmsel.FrmIndex;
                        }
                        if (SelIndex == 1)
                        {
                            LibCerMap.FrmNavigationGrids frm = new LibCerMap.FrmNavigationGrids(SymbolStyle, m_hookHelper);
                            frm.ShowDialog();
                        }
                        else if (SelIndex == 2)
                        {
                            LibCerMap.FrmFrameAttribute frm = new LibCerMap.FrmFrameAttribute(SymbolStyle, Element, GraphicsContainer, m_hookHelper);
                            frm.ShowDialog();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("当选择要素为指北针、比例尺、图例、Frame窗体时,只可以选择一个要素");
                }
            }
            else if (ElementProperties.Type == "Text" || ElementProperties.Type == "文本")
            {
                LibCerMap.FrmAddText frm = new LibCerMap.FrmAddText(Element as ITextElement, m_hookHelper);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //ITextSymbol pTextSymbol = frm.pTextElement.Symbol;
                    //for (int i = 0; i < SelectElementCount; i++)
                    //{
                    //    ITextElement pTextElement = Element as ITextElement;
                    //    //pTextElement.Symbol = pTextSymbol;
                    //    Element = EnumElement.Next();
                    //}
                    m_hookHelper.ActiveView.Refresh();
                }
            }

            else if (ElementProperties.Type == "Marker" || ElementProperties.Type == "标记")
            {
                IMarkerElement      pMarkerElement = Element as IMarkerElement;
                LibCerMap.FrmSymbol FrmMarker      = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pMarkerElement.Symbol, esriSymbologyStyleClass.esriStyleClassMarkerSymbols);
                FrmMarker.ShowDialog();
                if (FrmMarker.DialogResult == DialogResult.OK)
                {
                    IMarkerSymbol pMarkerSymbol = FrmMarker.GetStyleGalleryItem().Item as IMarkerSymbol;
                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pMarkerElement.Symbol = pMarkerSymbol;
                        Element        = EnumElement.Next();
                        pMarkerElement = Element as IMarkerElement;
                    }
                }
            }
            else if (ElementProperties.Type == "Line" || ElementProperties.Type == "线")
            {
                ILineElement        pLineElement = Element as ILineElement;
                LibCerMap.FrmSymbol frm          = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pLineElement.Symbol, esriSymbologyStyleClass.esriStyleClassLineSymbols);
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    ILineSymbol pLineSymbol = frm.GetStyleGalleryItem().Item as ILineSymbol;
                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pLineElement.Symbol = pLineSymbol;
                        Element             = EnumElement.Next();
                        pLineElement        = Element as ILineElement;
                    }
                }
            }

            else if (ElementProperties.Type == "Polygon" || ElementProperties.Type == "Rectangle" ||
                     ElementProperties.Type == "Circle" || ElementProperties.Type == "Ellipse" ||
                     ElementProperties.Type == "面" || ElementProperties.Type == "矩形" ||
                     ElementProperties.Type == "圆形" || ElementProperties.Type == "椭圆")
            {
                IFillShapeElement   pFillShapeElement = Element as IFillShapeElement;
                LibCerMap.FrmSymbol frm = new LibCerMap.FrmSymbol(SymbolStyle, (ISymbol)pFillShapeElement.Symbol, esriSymbologyStyleClass.esriStyleClassFillSymbols);
                frm.ShowDialog();
                if (frm.DialogResult == DialogResult.OK)
                {
                    IFillSymbol pFillsymbol = frm.GetStyleGalleryItem().Item as IFillSymbol;

                    for (int i = 0; i < SelectElementCount; i++)
                    {
                        pFillShapeElement.Symbol = pFillsymbol;
                        Element           = EnumElement.Next();
                        pFillShapeElement = Element as IFillShapeElement;
                    }
                }
            }

            m_hookHelper.ActiveView.Refresh();
        }