Example #1
0
        //创建所有要素的轮廓线
        private void CreateAllElementFrame()
        {
            IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView.GraphicsContainer;

            IElement pElement = pGraphicsContainer.Next();

            //IEnumElement pp =

            IMapSurroundFrame pMapsurroundFrame = new MapSurroundFrameClass();

            pMapsurroundFrame.MapSurround = pGraphicsContainer as IMapSurround;

            IFrameProperties pFrameProperties = pMapsurroundFrame as IFrameProperties;

            //边框的间距和圆角
            if (SymbolBorder != null)
            {
                if (this.txtBorderGap.Text != null)
                {
                    SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                }
                if (this.txtBorderAngle.Text != null)
                {
                    SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                }
            }
            if (SymbolBackground != null)
            {
                if (txtBackgroundGap.Text != null)
                {
                    SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                }
                if (txtBackgroundAngle.Text != null)
                {
                    SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                }
            }
            if (SymbolShadow != null)
            {
                if (txtShadowX.Text != null)
                {
                    SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                }
                if (txtShadowY.Text != null)
                {
                    SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                }
                if (txtShadowAngle.Text != null)
                {
                    SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                }
            }
            //边框
            pFrameProperties.Border = SymbolBorder;

            //背景
            pFrameProperties.Background = SymbolBackground;
            //阴影
            pFrameProperties.Shadow = SymbolShadow;
        }
Example #2
0
        private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e)
        {
            IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;

            //Get the frame containing the focus map
            IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap);

            if (styleGalleryItem.Item is IBackground)
            {
                //Set the frame's background
                frameProperties.Background = (IBackground)styleGalleryItem.Item;
            }
            else if (styleGalleryItem.Item is IBorder)
            {
                //Set the frame's border
                frameProperties.Border = (IBorder)styleGalleryItem.Item;
            }
            else if (styleGalleryItem.Item is IShadow)
            {
                //Set the frame's shadow
                frameProperties.Shadow = (IShadow)styleGalleryItem.Item;
            }

            //Refresh the PageLayoutControl
            axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IActiveView pActiveView = (IActiveView)m_PageLayOutControl.PageLayout;

            IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)pActiveView;

            IMap pMap = pActiveView.FocusMap;

            IMapFrame pMapFrame = (IMapFrame)pGraphicsContainer.FindFrame(pMap);

            IStyleSelector pStyleSelector = new ShadowSelectorClass();

            bool m_bOK = pStyleSelector.DoModal(m_PageLayOutControl.hWnd);

            if (!m_bOK)
            {
                return;
            }

            IShadow pShadow = (IShadow)pStyleSelector.GetStyle(0);

            IFrameProperties pFrameProperties = (IFrameProperties)pMapFrame;

            pFrameProperties.Shadow = pShadow;

            m_PageLayOutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
        private void btReturnShadow_Click(object sender, EventArgs e)
        {
            IFrameProperties pFrameProperties = m_pMapFrame as IFrameProperties;

            pFrameProperties.Shadow = null;
            btShadow.Image          = null;
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Example #5
0
        private void btReturnShadow_Click(object sender, EventArgs e)
        {
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            pFrameProperties.Shadow = null;
            btShadow.Image          = null;
            m_hookHelper.ActiveView.Refresh();
        }
Example #6
0
        private void FrmFrameAttribute_Load(object sender, EventArgs e)
        {
            IFrameElement    FrameElement    = Element as IFrameElement;
            IFrameProperties FrameProperties = FrameElement as IFrameProperties;

            //设置默认边框、背景、阴影

            if (FrameProperties.Border != null)
            {
                FrmFrameBorder Frm = new FrmFrameBorder(SymbolStyle, (ISymbolBorder)FrameProperties.Border);

                if (btBorder.Image != null)
                {
                    btBorder.Image.Dispose();
                }
                btBorder.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)FrameProperties.Border, btBorder.Width - 14, btBorder.Height - 14);

                //记录
                pSymbolBorder = FrameProperties.Border as ISymbolBorder;
                //重新加载
                SymbolBorder             = FrameProperties.Border as ISymbolBorder;
                this.txtBorderAngle.Text = SymbolBorder.CornerRounding.ToString();
                this.txtBorderGap.Text   = SymbolBorder.Gap.ToString();
            }
            if (FrameProperties.Background != null)
            {
                FrmFrameBackground Frm = new FrmFrameBackground(SymbolStyle, (ISymbolBackground)FrameProperties.Background);
                if (btBackground.Image != null)
                {
                    btBackground.Image.Dispose();
                }
                btBackground.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)FrameProperties.Background, btBackground.Width - 14, btBackground.Height - 14);

                //记录
                pSymbolBackground = FrameProperties.Background as ISymbolBackground;
                //重新加载
                SymbolBackground             = FrameProperties.Background as ISymbolBackground;
                this.txtBackgroundAngle.Text = SymbolBackground.CornerRounding.ToString();
                this.txtBackgroundGap.Text   = SymbolBackground.Gap.ToString();
            }
            if (FrameProperties.Shadow != null)
            {
                FrmFrameShadow Frm = new FrmFrameShadow(SymbolStyle, (ISymbolShadow)FrameProperties.Shadow);
                if (btShadow.Image != null)
                {
                    btShadow.Image.Dispose();
                }
                btShadow.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)FrameProperties.Shadow, btShadow.Width - 14, btShadow.Height - 14);

                //记录
                pSymbolShadow = FrameProperties.Shadow as ISymbolShadow;
                //重新加载
                SymbolShadow             = FrameProperties.Shadow as ISymbolShadow;
                this.txtShadowAngle.Text = SymbolShadow.CornerRounding.ToString();
                this.txtShadowX.Text     = SymbolShadow.HorizontalSpacing.ToString();
                this.txtShadowY.Text     = SymbolShadow.VerticalSpacing.ToString();
            }
        }
        //更新界面值,false-界面值更新至对象,true-对象值更新至界面
        private void UpdateUI(bool bValue)
        {
            if (bValue)
            {
                #region 更新界面
                //批北针属性
                this.NorthArrowAngle.Value = m_pNorthArrow.CalibrationAngle;
                this.NorthArrowSize.Value  = m_pNorthArrow.Size;
                IColor pNorthArrowColor = m_pNorthArrow.Color;
                Color  pColor           = ColorTranslator.FromOle(pNorthArrowColor.RGB);
                colorNorthArrow.SelectedColor = pColor;

                //Frame属性
                IFrameProperties pFrameProperties = m_pMapFrame as IFrameProperties;
                if (pFrameProperties.Border != null)
                {
                    FrmFrameBorder Frm = new FrmFrameBorder(m_strSymbolStyle, (ISymbolBorder)pFrameProperties.Border);
                    btBorder.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)pFrameProperties.Border, btBorder.Width - 14, btBorder.Height - 14);
                    //pOriNAborder = pFrameProperties.Border as ISymbolBorder;
                    //重新加载
                    ISymbolBorder SymbolBorder = pFrameProperties.Border as ISymbolBorder;
                    this.txtBorderAngle.Text = SymbolBorder.CornerRounding.ToString();
                    this.txtBorderGap.Text   = SymbolBorder.Gap.ToString();
                }

                if (pFrameProperties.Background != null)
                {
                    FrmFrameBackground Frm = new FrmFrameBackground(m_strSymbolStyle, (ISymbolBackground)pFrameProperties.Background);
                    btBackground.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)pFrameProperties.Background, btBackground.Width - 14, btBackground.Height - 14);
                    //pOriNAbackground = pFrameProperties.Background as ISymbolBackground;
                    //重新加载
                    ISymbolBackground SymbolBackground = pFrameProperties.Background as ISymbolBackground;
                    this.txtBackgroundAngle.Text = SymbolBackground.CornerRounding.ToString();
                    this.txtBackgroundGap.Text   = SymbolBackground.Gap.ToString();
                }
                if (pFrameProperties.Shadow != null)
                {
                    FrmFrameShadow Frm = new FrmFrameShadow(m_strSymbolStyle, (ISymbolShadow)pFrameProperties.Shadow);
                    btShadow.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)pFrameProperties.Shadow, btShadow.Width - 14, btShadow.Height - 14);
                    //pOriNAshadow = pFrameProperties.Shadow as ISymbolShadow;

                    //重新加载
                    ISymbolShadow SymbolShadow = pFrameProperties.Shadow as ISymbolShadow;
                    this.txtShadowAngle.Text = SymbolShadow.CornerRounding.ToString();
                    this.txtShadowX.Text     = SymbolShadow.HorizontalSpacing.ToString();
                    this.txtShadowY.Text     = SymbolShadow.VerticalSpacing.ToString();
                }
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                #endregion
            }
            else
            {
                #region 更新对象属性值

                #endregion
            }
        }
Example #8
0
        private void axPageLayoutControl1_OnPageLayoutReplaced(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnPageLayoutReplacedEvent e)
        {
            //Get the frame containing the focus map
            IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap);

            //Create a new ServerStyleGalleryItem with its name set
            IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItemClass();

            styleGalleryItem.Name = "myStyle";

            ISymbologyStyleClass styleClass;


            //Get the background style class and remove any custom style
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassBackgrounds);
            if (styleClass.GetItem(0).Name == "myStyle")
            {
                styleClass.RemoveItem(0);
            }
            if (frameProperties.Background != null)
            {
                //Set the background into the style gallery item
                styleGalleryItem.Item = frameProperties.Background;
                //Add the item to the style class
                styleClass.AddItem(styleGalleryItem, 0);
            }

            //Get the border style class and remove any custom style
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassBorders);
            if (styleClass.GetItem(0).Name == "myStyle")
            {
                styleClass.RemoveItem(0);
            }
            if (frameProperties.Border != null)
            {
                //Set the border into the style gallery item
                styleGalleryItem.Item = frameProperties.Border;
                //Add the item to the style class
                styleClass.AddItem(styleGalleryItem, 0);
            }

            //Get the shadow style class and remove any custom style
            styleClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassShadows);
            if (styleClass.GetItem(0).Name == "myStyle")
            {
                styleClass.RemoveItem(0);
            }
            if (frameProperties.Shadow != null)
            {
                //Set the shadow into the style gallery item
                styleGalleryItem.Item = frameProperties.Shadow;
                //Add the item to the style class
                styleClass.AddItem(styleGalleryItem, 0);
            }
        }
Example #9
0
        //创建页边距内的轮廓线
        private void CreatePageFrame()
        {
            IPageLayout pPageLayout = pActiveView as IPageLayout;
            IPage       pPage       = pPageLayout.Page as IPage;

            //边框的间距和圆角
            if (SymbolBorder != null)
            {
                if (this.txtBorderGap.Text != null)
                {
                    SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                }
                if (this.txtBorderAngle.Text != null)
                {
                    SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                }
            }
            if (SymbolBackground != null)
            {
                if (txtBackgroundGap.Text != null)
                {
                    SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                }
                if (txtBackgroundAngle.Text != null)
                {
                    SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                }
            }
            if (SymbolShadow != null)
            {
                if (txtShadowX.Text != null)
                {
                    SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                }
                if (txtShadowY.Text != null)
                {
                    SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                }
                if (txtShadowAngle.Text != null)
                {
                    SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                }
            }
            IFrameProperties pFrameProperties = pPage as IFrameProperties;

            //边框
            pFrameProperties.Border = SymbolBorder;
            //背景
            pFrameProperties.Background = SymbolBackground;
            //阴影
            pFrameProperties.Shadow = SymbolShadow;
        }
Example #10
0
        //取消按钮
        private void btCancel_Click(object sender, EventArgs e)
        {
            IFrameElement    pFrameElement    = Element as IFrameElement;
            IFrameProperties pFrameProperties = pFrameElement as IFrameProperties;

            //边框
            pFrameProperties.Border = pSymbolBorder;
            //背景
            pFrameProperties.Background = pSymbolBackground;
            //阴影
            pFrameProperties.Shadow = pSymbolShadow;

            this.Close();
        }
Example #11
0
        //创建要素的轮廓线
        private void CreateSelectElementFrame()
        {
            IFrameElement    pFrameElement    = Element as IFrameElement;
            IFrameProperties pFrameProperties = pFrameElement as IFrameProperties;

            //边框的间距和圆角
            if (SymbolBorder != null)
            {
                if (this.txtBorderGap.Text != null)
                {
                    SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                }
                if (this.txtBorderAngle.Text != null)
                {
                    SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                }
            }
            if (SymbolBackground != null)
            {
                if (txtBackgroundGap.Text != null)
                {
                    SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                }
                if (txtBackgroundAngle.Text != null)
                {
                    SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                }
            }
            if (SymbolShadow != null)
            {
                if (txtShadowX.Text != null)
                {
                    SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                }
                if (txtShadowY.Text != null)
                {
                    SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                }
                if (txtShadowAngle.Text != null)
                {
                    SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                }
            }
            //边框
            pFrameProperties.Border = SymbolBorder;
            //背景
            pFrameProperties.Background = SymbolBackground;
            //阴影
            pFrameProperties.Shadow = SymbolShadow;
        }
Example #12
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add shadow.OnClick implementation

            IStyleSelector ipSSelector = new ShadowSelectorClass();

            if (ipSSelector.DoModal(0))
            {
                IMap map = m_PageLayControl.ActiveView.FocusMap;
                IGraphicsContainer gContainer =
                    m_PageLayControl.ActiveView.GraphicsContainer;
                IFrameProperties fProperties =
                    (IFrameProperties)gContainer.FindFrame(map);
                fProperties.Shadow = (IShadow)ipSSelector.GetStyle(0);
                m_PageLayControl.ActiveView.Refresh();
            }
        }
        //边框
        private void btBorder_Click(object sender, EventArgs e)
        {
            IFrameProperties pFrameProperties = m_pMapFrame as IFrameProperties;
            //pFrameProperties.Border = SymbolBorder;
            FrmFrameBorder Frm = new FrmFrameBorder(m_strSymbolStyle, (ISymbolBorder)pFrameProperties.Border);

            if (Frm.ShowDialog() == DialogResult.OK)
            {
                ISymbolBorder SymbolBorder = Frm.GetSymbolBorder();
                if (SymbolBorder != null)
                {
                    btBorder.Image          = Frm.GetImageByGiveSymbolAfterSelectItem(btBorder.Width - 14, btBorder.Height - 14);
                    pFrameProperties.Border = SymbolBorder;
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
        }
        //阴影
        private void btShadow_Click(object sender, EventArgs e)
        {
            IFrameProperties pFrameProperties = m_pMapFrame as IFrameProperties;
            FrmFrameShadow   Frm = new FrmFrameShadow(m_strSymbolStyle, (ISymbolShadow)pFrameProperties.Shadow);

            Frm.ShowDialog();
            if (Frm.DialogResult == DialogResult.OK)
            {
                ISymbolShadow SymbolShadow = Frm.GetSymbolShadow();
                if (SymbolShadow != null)
                {
                    btShadow.Image          = Frm.GetImageByGiveSymbolAfterSelectItem(btShadow.Width - 14, btShadow.Height - 14);
                    pFrameProperties.Shadow = SymbolShadow;
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
        }
        //取消按钮
        private void btCancel_Click(object sender, EventArgs e)
        {
            IFrameProperties pFrameProperties    = m_pMapFrame as IFrameProperties;
            IFrameProperties pFramePropertiesOrg = m_pMapFrameOrg as IFrameProperties;

            pFrameProperties.Border     = pFramePropertiesOrg.Border;
            pFrameProperties.Background = pFramePropertiesOrg.Background;
            pFrameProperties.Shadow     = pFramePropertiesOrg.Shadow;

            m_pNorthArrow.Size             = m_pNorthArrowOrg.Size;
            m_pNorthArrow.Color            = m_pNorthArrowOrg.Color;
            m_pNorthArrow.CalibrationAngle = m_pNorthArrowOrg.CalibrationAngle;


            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            this.Close();
        }
Example #16
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add Borders.OnClick implementation
            // TODO: Add Backgrounds.OnClick implementation
            GetSymbol symbolForm = new GetSymbol(esriSymbologyStyleClass.esriStyleClassBorders);

            symbolForm.Text = "选择边框";
            IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassBorders);

            symbolForm.Dispose();
            if (styleGalleryItem == null)
            {
                return;
            }
            //Get the frame containing the focus map
            IFrameProperties frameProperties = (IFrameProperties)pPageLayoutControl.GraphicsContainer.FindFrame(pPageLayoutControl.ActiveView.FocusMap);

            frameProperties.Border = (IBorder )styleGalleryItem.Item;
            pPageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
Example #17
0
        //创建选择要素的轮廓线
        private void CreateSelectElementFrame()
        {
            IGraphicsContainer       pGraphicsContainer       = m_hookHelper.ActiveView.GraphicsContainer;
            IGraphicsContainerSelect pGraphicsContainerSelect = pGraphicsContainer as IGraphicsContainerSelect;
            int          SelectElementCount = pGraphicsContainerSelect.ElementSelectionCount;
            IEnumElement pEnumElement       = pGraphicsContainerSelect.SelectedElements;

            pEnumElement.Reset();
            IElement pElement = pEnumElement.Next();

            for (int i = 0; i < SelectElementCount; i++)
            {
                IElementProperties pElementProperties = pElement as IElementProperties;
                IFrameElement      pFrameElement      = pElement as IFrameElement;
                IFrameProperties   pFrameProperties   = pFrameElement as IFrameProperties;
                //边框的间距和圆角
                if (SymbolBorder != null)
                {
                    if (this.txtBorderGap.Text != null)
                    {
                        SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                    }
                    if (this.txtBorderAngle.Text != null)
                    {
                        SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                    }
                }
                if (SymbolBackground != null)
                {
                    if (txtBackgroundGap.Text != null)
                    {
                        SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                    }
                    if (txtBackgroundAngle.Text != null)
                    {
                        SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                    }
                }
                if (SymbolShadow != null)
                {
                    if (txtShadowX.Text != null)
                    {
                        SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                    }
                    if (txtShadowY.Text != null)
                    {
                        SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                    }
                    if (txtShadowAngle.Text != null)
                    {
                        SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                    }
                }
                //边框
                pFrameProperties.Border = SymbolBorder;
                //背景
                pFrameProperties.Background = SymbolBackground;
                //阴影
                pFrameProperties.Shadow = SymbolShadow;

                pElement = pEnumElement.Next();
            }
        }
Example #18
0
        private void FrmScaleBarAttribute_Load(object sender, EventArgs e)
        {
            if (FrmIndex == 2)
            {
                this.tabItemFrame.Visible = true;
            }
            else
            {
                this.tabItemFrame.Visible = false;
            }
            //根据加载进来的比例尺设计界面的初始值
            //格数默认值
            DivisionNum.Value    = ScaleBar.Divisions;
            SubDivisionNum.Value = ScaleBar.Subdivisions;
            //单位默认值:单位、单位位置、标签、间隔
            //单位
            if (ScaleBar.UnitLabel == "厘米")
            {
                coboBoxUnits.SelectedIndex = 0;
            }
            else if (ScaleBar.UnitLabel == "度")
            {
                coboBoxUnits.SelectedIndex = 1;
            }
            else if (ScaleBar.UnitLabel == "分米")
            {
                coboBoxUnits.SelectedIndex = 2;
            }
            else if (ScaleBar.UnitLabel == "英尺")
            {
                coboBoxUnits.SelectedIndex = 3;
            }
            else if (ScaleBar.UnitLabel == "英寸")
            {
                coboBoxUnits.SelectedIndex = 4;
            }
            else if (ScaleBar.UnitLabel == "千米" || ScaleBar.UnitLabel == "Kilometers")
            {
                coboBoxUnits.SelectedIndex = 5;
            }
            else if (ScaleBar.UnitLabel == "米" || ScaleBar.UnitLabel == "Meters")
            {
                coboBoxUnits.SelectedIndex = 6;
            }
            else if (ScaleBar.UnitLabel == "英里")
            {
                coboBoxUnits.SelectedIndex = 7;
            }
            else if (ScaleBar.UnitLabel == "毫米")
            {
                coboBoxUnits.SelectedIndex = 8;
            }
            else if (ScaleBar.UnitLabel == "海里")
            {
                coboBoxUnits.SelectedIndex = 9;
            }
            else if (ScaleBar.UnitLabel == "点")
            {
                coboBoxUnits.SelectedIndex = 10;
            }
            else if (ScaleBar.UnitLabel == "UnitsLast")
            {
                coboBoxUnits.SelectedIndex = 11;
            }
            else if (ScaleBar.UnitLabel == "UnknownUnits")
            {
                coboBoxUnits.SelectedIndex = 12;
            }
            else if (ScaleBar.UnitLabel == "码")
            {
                coboBoxUnits.SelectedIndex = 13;
            }
            else
            {
                coboBoxUnits.SelectedIndex = 12;
            }
            //coboBoxUnits.SelectedIndex = 6;

            //位置
            if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarAfterBar)
            {
                coboBoxPos.SelectedIndex = 0;
            }
            else if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarAbove)
            {
                coboBoxPos.SelectedIndex = 1;
            }
            else if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarAfterLabels)
            {
                coboBoxPos.SelectedIndex = 2;
            }
            else if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarBeforeBar)
            {
                coboBoxPos.SelectedIndex = 3;
            }
            else if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarBeforeLabels)
            {
                coboBoxPos.SelectedIndex = 4;
            }
            else if (ScaleBar.UnitLabelPosition == esriScaleBarPos.esriScaleBarBelow)
            {
                coboBoxPos.SelectedIndex = 5;
            }
            //间隔
            UnitsGap.Value = ScaleBar.UnitLabelGap;

            //频率、频率位置、频率间隔 默认值
            if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint)
            {
                cbBoxFrequency.SelectedIndex = 0;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarDivisions)
            {
                cbBoxFrequency.SelectedIndex = 1;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarDivisionsAndFirstSubdivisions)
            {
                cbBoxFrequency.SelectedIndex = 2;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarDivisionsAndSubdivisions)
            {
                cbBoxFrequency.SelectedIndex = 3;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarMajorDivisions)
            {
                cbBoxFrequency.SelectedIndex = 4;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarNone)
            {
                cbBoxFrequency.SelectedIndex = 5;
            }
            else if (ScaleBar.LabelFrequency == esriScaleBarFrequency.esriScaleBarOne)
            {
                cbBoxFrequency.SelectedIndex = 6;
            }

            //频率位置
            if (ScaleBar.LabelPosition == esriVertPosEnum.esriAbove)
            {
                cbBoxPostion.SelectedIndex = 0;
            }
            else if (ScaleBar.LabelPosition == esriVertPosEnum.esriTop)
            {
                cbBoxPostion.SelectedIndex = 1;
            }
            else if (ScaleBar.LabelPosition == esriVertPosEnum.esriOn)
            {
                cbBoxPostion.SelectedIndex = 2;
            }
            else if (ScaleBar.LabelPosition == esriVertPosEnum.esriBottom)
            {
                cbBoxPostion.SelectedIndex = 3;
            }
            else if (ScaleBar.LabelPosition == esriVertPosEnum.esriBelow)
            {
                cbBoxPostion.SelectedIndex = 4;
            }
            //频率间距
            FrequencyGap.Value = ScaleBar.LabelGap;

            //比例尺的宽度
            BarsSize.Value = ScaleBar.BarHeight;

            IColor pScaleBarColor = ScaleBar.BarColor;
            Color  pColor         = ColorTranslator.FromOle(pScaleBarColor.RGB);

            colorBar.SelectedColor = pColor;

            //设置默认边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (pFrameProperties.Border != null)
            {
                FrmFrameBorder Frm = new FrmFrameBorder(SymbolStyle, (ISymbolBorder)pFrameProperties.Border);
                btBorder.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)pFrameProperties.Border, btBorder.Width - 14, btBorder.Height - 14);
                //重新加载
                SymbolBorder             = pFrameProperties.Border as ISymbolBorder;
                this.txtBorderAngle.Text = SymbolBorder.CornerRounding.ToString();
                this.txtBorderGap.Text   = SymbolBorder.Gap.ToString();
            }
            if (pFrameProperties.Background != null)
            {
                FrmFrameBackground Frm = new FrmFrameBackground(SymbolStyle, (ISymbolBackground)pFrameProperties.Background);
                btBackground.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)pFrameProperties.Background, btBackground.Width - 14, btBackground.Height - 14);
                //重新加载
                SymbolBackground             = pFrameProperties.Background as ISymbolBackground;
                this.txtBackgroundAngle.Text = SymbolBackground.CornerRounding.ToString();
                this.txtBackgroundGap.Text   = SymbolBackground.Gap.ToString();
            }
            if (pFrameProperties.Shadow != null)
            {
                FrmFrameShadow Frm = new FrmFrameShadow(SymbolStyle, (ISymbolShadow)pFrameProperties.Shadow);
                btShadow.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)pFrameProperties.Shadow, btShadow.Width - 14, btShadow.Height - 14);
                //重新加载
                SymbolShadow             = pFrameProperties.Shadow as ISymbolShadow;
                this.txtShadowAngle.Text = SymbolShadow.CornerRounding.ToString();
                this.txtShadowX.Text     = SymbolShadow.HorizontalSpacing.ToString();
                this.txtShadowY.Text     = SymbolShadow.VerticalSpacing.ToString();
            }
        }
Example #19
0
        //设计比例尺属性
        private void CreateScaleBar()
        {
            //格数设计
            string pOriDiv = double.Parse(DivisionNum.Text).ToString();

            ScaleBar.Divisions = short.Parse(pOriDiv);
            string pOriSubDiv = double.Parse(SubDivisionNum.Text).ToString();

            ScaleBar.Subdivisions = short.Parse(pOriSubDiv);

            //单位设计
            if (coboBoxUnits.SelectedItem != null)
            {
                if (coboBoxUnits.SelectedItem.ToString() == "Centimeters")
                {
                    ScaleBar.Units = esriUnits.esriCentimeters;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "DecimalDegrees")
                {
                    ScaleBar.Units = esriUnits.esriDecimalDegrees;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Decimeters")
                {
                    ScaleBar.Units = esriUnits.esriDecimeters;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Feet")
                {
                    ScaleBar.Units = esriUnits.esriFeet;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Inches")
                {
                    ScaleBar.Units = esriUnits.esriInches;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Kilometers")
                {
                    ScaleBar.Units = esriUnits.esriKilometers;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Meters")
                {
                    ScaleBar.Units = esriUnits.esriMeters;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Miles")
                {
                    ScaleBar.Units = esriUnits.esriMiles;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Millimeters")
                {
                    ScaleBar.Units = esriUnits.esriMillimeters;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "NauticalMiles")
                {
                    ScaleBar.Units = esriUnits.esriNauticalMiles;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Points")
                {
                    ScaleBar.Units = esriUnits.esriPoints;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "UnitsLast")
                {
                    ScaleBar.Units = esriUnits.esriUnitsLast;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "UnknownUnits")
                {
                    ScaleBar.Units = esriUnits.esriUnknownUnits;
                }
                else if (coboBoxUnits.SelectedItem.ToString() == "Yards")
                {
                    ScaleBar.Units = esriUnits.esriYards;
                }
            }
            else
            {
                ScaleBar.Units = esriUnits.esriUnknownUnits;
            }

            //比例尺单位标签
            ScaleBar.UnitLabel = txtUnitsLabel.Text;

            //单位标签样式
            if (UnitsLabelSymbols != null)
            {
                ScaleBar.UnitLabelSymbol = UnitsLabelSymbols;
            }
            //单位标签位置
            if (coboBoxPos.SelectedItem.ToString() == "After Bar")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterBar;
            }
            else if (coboBoxPos.SelectedItem.ToString() == "Above Bar")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAbove;
            }
            else if (coboBoxPos.SelectedItem.ToString() == "After Labels")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterLabels;
            }
            else if (coboBoxPos.SelectedItem.ToString() == "Before Bar")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarBeforeBar;
            }
            else if (coboBoxPos.SelectedItem.ToString() == "Before Labels")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarBeforeLabels;
            }
            else if (coboBoxPos.SelectedItem.ToString() == "Below Bar")
            {
                ScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarBelow;
            }
            //单位标签间隔
            ScaleBar.UnitLabelGap = double.Parse(UnitsGap.Text);

            //频率设置
            if (cbBoxFrequency.SelectedItem.ToString() == "Divisions And First Mid point")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "Divisions")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisions;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "Divisions And First Subdivisions")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstSubdivisions;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "Divisions And Subdivisions")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndSubdivisions;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "ends(and zero)")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarMajorDivisions;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "no labels")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarNone;
            }
            else if (cbBoxFrequency.SelectedItem.ToString() == "single labels")
            {
                ScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarOne;
            }
            //位置设计
            if (cbBoxPostion.SelectedItem.ToString() == "Above Bar")
            {
                ScaleBar.LabelPosition = esriVertPosEnum.esriAbove;
            }
            else if (cbBoxPostion.SelectedItem.ToString() == "Below bar")
            {
                ScaleBar.LabelPosition = esriVertPosEnum.esriBelow;
            }
            else if (cbBoxPostion.SelectedItem.ToString() == "Align to bottom of bar")
            {
                ScaleBar.LabelPosition = esriVertPosEnum.esriBottom;
            }
            else if (cbBoxPostion.SelectedItem.ToString() == "Center on bar")
            {
                ScaleBar.LabelPosition = esriVertPosEnum.esriOn;
            }
            else if (cbBoxPostion.SelectedItem.ToString() == "Align to top of bar")
            {
                ScaleBar.LabelPosition = esriVertPosEnum.esriTop;
            }
            //间隔设计
            ScaleBar.LabelGap = double.Parse(FrequencyGap.Text);

            //标注样式
            if (FrequencyLabelSymbols != null)
            {
                ScaleBar.LabelSymbol = FrequencyLabelSymbols;
            }

            //比例尺Bar大小、颜色设计
            //大小
            ScaleBar.BarHeight = double.Parse(BarsSize.Text);
            //颜色
            if (colorBar.SelectedColor != null)
            {
                ScaleBar.BarColor = ClsGDBDataCommon.ColorToIColor(colorBar.SelectedColor);
            }
            else
            {
                return;
            }

            //设置边框、阴影、背景的距离和圆角
            if (SymbolBorder != null)
            {
                if (this.txtBorderGap.Text != null)
                {
                    SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                }
                if (txtBorderAngle.Text != null)
                {
                    SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                }
            }
            if (SymbolBackground != null)
            {
                if (txtBackgroundGap.Text != null)
                {
                    SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                }
                if (txtBackgroundAngle.Text != null)
                {
                    SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                }
            }
            if (SymbolShadow != null)
            {
                if (txtShadowX.Text != null)
                {
                    SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                }
                if (txtShadowY.Text != null)
                {
                    SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                }
                if (txtShadowAngle.Text != null)
                {
                    SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                }
            }
            //添加边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (SymbolBorder != null)
            {
                pFrameProperties.Border = SymbolBorder;
            }
            if (SymbolBackground != null)
            {
                pFrameProperties.Background = SymbolBackground;
            }
            if (SymbolShadow != null)
            {
                pFrameProperties.Shadow = SymbolShadow;
            }
        }
        private void FrmScaleTextAttribute_Load(object sender, EventArgs e)
        {
            if (FrmIndex == 2)
            {
                this.tabItemFrame.Visible = true;
            }
            else
            {
                this.tabItemFrame.Visible = false;
            }
            //将选择的文字比例尺的一般属性赋值给属性表
            if (ScaleText.Separator == " = ")
            {
                ckBoxAsolute.Checked  = false;
                ckBoxRelative.Checked = true;
                txtSeparator.Text     = " = ";
            }
            else if (ScaleText.Separator == ":")
            {
                ckBoxRelative.Checked   = false;
                ckBoxAsolute.Checked    = true;
                txtSeparator.Text       = ":";
                cmbBoxMapUnits.Enabled  = false;
                cmbBoxPageUnits.Enabled = false;
                txtPageLabel.Enabled    = false;
                txtMapLabel.Enabled     = false;
            }
            else if (ScaleText.Separator == " equals ")
            {
                ckBoxAsolute.Checked  = false;
                ckBoxRelative.Checked = true;
                txtSeparator.Text     = " equals ";
            }
            //布局
            if (ScaleText.PageUnitLabel == "in" || ScaleText.PageUnitLabel == "inch")
            {
                cmbBoxPageUnits.SelectedIndex = 1;
            }
            else if (ScaleText.PageUnitLabel == "cm" || ScaleText.PageUnitLabel == "centimeter" || ScaleText.PageUnitLabel == "page unit")
            {
                cmbBoxPageUnits.SelectedIndex = 0;
            }
            //地图
            if (ScaleText.MapUnitLabel == "feet" || ScaleText.MapUnitLabel == "ft")
            {
                cmbBoxMapUnits.SelectedIndex = 3;
            }
            else if (ScaleText.MapUnitLabel == "miles")
            {
                cmbBoxMapUnits.SelectedIndex = 7;
            }
            else if (ScaleText.MapUnitLabel == "km")
            {
                cmbBoxMapUnits.SelectedIndex = 5;
            }
            else if (ScaleText.MapUnitLabel == "meters")
            {
                cmbBoxMapUnits.SelectedIndex = 6;
            }
            else if (ScaleText.MapUnitLabel == "yards")
            {
                cmbBoxMapUnits.SelectedIndex = 12;
            }
            else if (ScaleText.MapUnitLabel == "map units")
            {
                cmbBoxMapUnits.SelectedIndex = 11;
            }

            //字体名称加载
            //加载字体名称
            InstalledFontCollection pFontCollection = new InstalledFontCollection();

            FontFamily[] pFontFamily = pFontCollection.Families;
            for (int i = 0; i < pFontFamily.Length; i++)
            {
                string pFontName = pFontFamily[i].Name;
                this.cboBoxFontName.Items.Add(pFontName);
            }
            this.cboBoxFontName.Text = "宋体";
            //加载字体大小
            for (int i = 3; i <= 100; i++)
            {
                this.cboBoxFontSize.Items.Add(i.ToString());
            }
            this.cboBoxFontSize.Text = "15";
            //颜色
            FontColor.SelectedColor = Color.Black;
            //设置默认边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (pFrameProperties.Border != null)
            {
                FrmFrameBorder Frm = new FrmFrameBorder(SymbolStyle, (ISymbolBorder)pFrameProperties.Border);
                btBorder.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)pFrameProperties.Border, btBorder.Width - 14, btBorder.Height - 14);
                //重新加载
                SymbolBorder             = pFrameProperties.Border as ISymbolBorder;
                this.txtBorderAngle.Text = SymbolBorder.CornerRounding.ToString();
                this.txtBorderGap.Text   = SymbolBorder.Gap.ToString();
            }
            if (pFrameProperties.Background != null)
            {
                FrmFrameBackground Frm = new FrmFrameBackground(SymbolStyle, (ISymbolBackground)pFrameProperties.Background);
                btBackground.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)pFrameProperties.Background, btBackground.Width - 14, btBackground.Height - 14);
                //重新加载
                SymbolBackground             = pFrameProperties.Background as ISymbolBackground;
                this.txtBackgroundAngle.Text = SymbolBackground.CornerRounding.ToString();
                this.txtBackgroundGap.Text   = SymbolBackground.Gap.ToString();
            }
            if (pFrameProperties.Shadow != null)
            {
                FrmFrameShadow Frm = new FrmFrameShadow(SymbolStyle, (ISymbolShadow)pFrameProperties.Shadow);
                btShadow.Image = Frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)pFrameProperties.Shadow, btShadow.Width - 14, btShadow.Height - 14);
                //重新加载
                SymbolShadow             = pFrameProperties.Shadow as ISymbolShadow;
                this.txtShadowAngle.Text = SymbolShadow.CornerRounding.ToString();
                this.txtShadowX.Text     = SymbolShadow.HorizontalSpacing.ToString();
                this.txtShadowY.Text     = SymbolShadow.VerticalSpacing.ToString();
            }
        }
Example #21
0
        //支持6中element,点,线,面,注记,Inkgraphic,MapFrame
        private bool GetProperty(IDisplay pDisplay, IElement pElement)
        {
            try
            {
                //获得FrameELEment的属性
                if (pElement is IFrameElement)
                {
                    IFrameProperties pFrameProperty   = (IFrameProperties)pElement;
                    IFrameDecoration pFrameDecoration = null;
                    IClone           pClone;
                    int  i;
                    bool bExist = false;

                    //得到地图边框属性
                    if (pFrameProperty.Border != null)
                    {
                        pFrameDecoration = (IFrameDecoration)pFrameProperty.Border;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbBorder.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Border;
                            DevComponents.Editors.ComboItem item = cmbBorder.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbBorder.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbBorder, pFrameProperty.Border, esriSymbologyStyleClass.esriStyleClassBorders);
                        }

                        GetDecorationColor(pFrameDecoration, btnBorderColor);
                        numBorderGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numBorderGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numBorderRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }

                    //得到地图背景属性
                    if (pFrameProperty.Background != null)
                    {
                        pFrameDecoration = (IFrameDecoration)((IFrameElement)pElement).Background;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbBack.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Background;
                            DevComponents.Editors.ComboItem item = cmbBack.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbBack.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbBack, pFrameProperty.Background, esriSymbologyStyleClass.esriStyleClassBackgrounds);
                        }

                        GetDecorationColor(pFrameDecoration, btnBackColor);

                        numBackGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numBackGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numBackRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }

                    //得到地图阴影属性
                    if (pFrameProperty.Shadow != null)
                    {
                        pFrameDecoration = (IFrameDecoration)pFrameProperty.Shadow;
                        //判断和列表框中的符号是否相同
                        bExist = false;
                        for (i = 0; i < cmbShadow.Items.Count; i++)
                        {
                            pClone = (IClone)pFrameProperty.Shadow;
                            DevComponents.Editors.ComboItem item = cmbShadow.Items[i] as DevComponents.Editors.ComboItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (pClone.Equals(item.Tag))
                            {
                                bExist = true;
                                break;
                            }
                        }
                        if (bExist)
                        {
                            cmbShadow.SelectedIndex = i;
                        }
                        else
                        {
                            PreViewCustom(cmbShadow, pFrameProperty.Shadow, esriSymbologyStyleClass.esriStyleClassShadows);
                        }

                        GetDecorationColor(pFrameDecoration, btnShadowColor);

                        numShadowGapX.Value  = (decimal)pFrameDecoration.HorizontalSpacing;
                        numShadowGapY.Value  = (decimal)pFrameDecoration.VerticalSpacing;
                        numShadowRound.Value = (decimal)pFrameDecoration.CornerRounding;
                    }
                }
                IElementProperties3 pElementProp = pElement as IElementProperties3;
                txtName.Text = pElementProp.Name;
                IEnvelope pBounds = new EnvelopeClass();
                pElement.QueryBounds(pDisplay, pBounds);
                IArea pArea = (IArea)pBounds;
                numCenterX.Text    = pArea.Centroid.X.ToString("f4");
                numCenterY.Text    = pArea.Centroid.Y.ToString("f4");
                numHeight.Text     = pBounds.Height.ToString("f4");
                numWidth.Text      = pBounds.Width.ToString("f4");
                numLowerLeftX.Text = pBounds.LowerLeft.X.ToString("f4");
                numLowerLeftY.Text = pBounds.LowerLeft.Y.ToString("f4");

                if (pElement is IMarkerElement)
                {
                    IMarkerElement pMrkElement = pElement as IMarkerElement;
                    picPoint.Tag = pMrkElement.Symbol;
                    PreViewSymbol((ISymbol)picPoint.Tag, ref picPoint);
                }
                else if (pElement is ILineElement)
                {
                    ILineElement pLinElement = pElement as ILineElement;
                    picLine.Tag = pLinElement.Symbol;
                    PreViewSymbol((ISymbol)picLine.Tag, ref picLine);
                }
                else if (pElement is IFillShapeElement)
                {
                    IFillShapeElement pFillElement = pElement as IFillShapeElement;
                    picPoly.Tag = pFillElement.Symbol;
                    PreViewSymbol((ISymbol)picPoly.Tag, ref picPoly);

                    //得到面积
                    pArea        = (IArea)pElement.Geometry;
                    numArea.Text = pArea.Area.ToString("0.00");
                    //得到周长
                    IPolygon pPolygon = new PolygonClass();
                    pElement.QueryOutline(m_pDisplay, pPolygon);
                    IRing pOutRing = new RingClass();
                    pPolygon.QueryExteriorRings(ref pOutRing);
                    numLength.Text = pOutRing.Length.ToString("0.00");
                }
                else if (pElement is ITextElement)
                {
                    ITextElement pTxtElement = pElement as ITextElement;
                    txtText.Text = pTxtElement.Text;
                    picText.Tag  = pTxtElement.Symbol;
                    PreViewSymbol((ISymbol)picText.Tag, ref picText);
                }
                if (pElement is IFrameElement)
                {
                    //判断指北针,比例尺,比例文本
                    IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame;
                    if (pMapSurroundFrame != null)
                    {
                        IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                        if (pMapSurround != null)
                        {
                            if (pMapSurround is INorthArrow)
                            {
                                picArrow.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picArrow);
                            }
                            else if (pMapSurround is IScaleBar)
                            {
                                picScale.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picScale);
                            }
                            else if (pMapSurround is IScaleText)
                            {
                                picScaleText.Tag = pMapSurround;
                                PreViewSymbol(pMapSurround, ref picScaleText);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("显示属性出错:" + ex.Message);
                return(false);
            }
        }
        //创建文字比例尺
        private void CreateScaleText()
        {
            //文字比例尺样式:绝对类型和相对类型
            if (ckBoxAsolute.Checked)
            {
                ScaleText.Style     = esriScaleTextStyleEnum.esriScaleTextAbsolute;
                ScaleText.Separator = txtSeparator.Text;
            }
            else if (ckBoxRelative.Checked)
            {
                ScaleText.Style     = esriScaleTextStyleEnum.esriScaleTextRelative;
                ScaleText.Separator = txtSeparator.Text;
            }
            //布局单位
            if (cmbBoxPageUnits.SelectedItem.ToString() == "Centimeters")
            {
                ScaleText.PageUnits     = esriUnits.esriCentimeters;
                ScaleText.PageUnitLabel = txtPageLabel.Text;
            }
            else if (cmbBoxPageUnits.SelectedItem.ToString() == "Inches")
            {
                ScaleText.PageUnits     = esriUnits.esriInches;
                ScaleText.PageUnitLabel = txtPageLabel.Text;
            }
            else if (cmbBoxPageUnits.SelectedItem.ToString() == "Points")
            {
                ScaleText.PageUnits     = esriUnits.esriPoints;
                ScaleText.PageUnitLabel = txtPageLabel.Text;
            }
            //地图单位
            if (cmbBoxMapUnits.SelectedItem.ToString() == "Centimeters")
            {
                ScaleText.MapUnits     = esriUnits.esriCentimeters;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Decimal Degrees")
            {
                ScaleText.MapUnits     = esriUnits.esriDecimalDegrees;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Decimeters")
            {
                ScaleText.MapUnits     = esriUnits.esriDecimeters;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Feet")
            {
                ScaleText.MapUnits     = esriUnits.esriFeet;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Inches")
            {
                ScaleText.MapUnits     = esriUnits.esriInches;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Kilometers")
            {
                ScaleText.MapUnits     = esriUnits.esriKilometers;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Meters")
            {
                ScaleText.MapUnits     = esriUnits.esriMeters;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Miles")
            {
                ScaleText.MapUnits     = esriUnits.esriMiles;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Millimeters")
            {
                ScaleText.MapUnits     = esriUnits.esriMillimeters;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Nautical Miles")
            {
                ScaleText.MapUnits     = esriUnits.esriNauticalMiles;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Points")
            {
                ScaleText.MapUnits     = esriUnits.esriPoints;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Unknown Units")
            {
                ScaleText.MapUnits     = esriUnits.esriUnknownUnits;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }
            else if (cmbBoxMapUnits.SelectedItem.ToString() == "Yards")
            {
                ScaleText.MapUnits     = esriUnits.esriYards;
                ScaleText.MapUnitLabel = txtMapLabel.Text;
            }

            if (TextSymbol == null)
            {
                //字体样式
                ITextSymbol pTextSymbol = new TextSymbolClass();
                IFontDisp   pFont       = new StdFontClass() as IFontDisp;

                pFont.Name = this.cboBoxFontName.Text;
                pFont.Size = decimal.Parse(this.cboBoxFontSize.Text);

                if (FontColor.SelectedColor != null)
                {
                    pTextSymbol.Color = ClsGDBDataCommon.ColorToIColor(FontColor.SelectedColor);
                }
                //风格
                if (toolBtnBold.Checked == true)
                {
                    pFont.Bold = true;
                }
                else
                {
                    pFont.Bold = false;
                }
                if (toolBtnIntend.Checked == true)
                {
                    pFont.Italic = true;
                }
                else
                {
                    pFont.Italic = false;
                }
                if (toolBtnUnderline.Checked == true)
                {
                    pFont.Underline = true;
                }
                else
                {
                    pFont.Underline = false;
                }
                if (toolBtnStrikethrough.Checked == true)
                {
                    pFont.Strikethrough = true;
                }
                else
                {
                    pFont.Strikethrough = false;
                }

                pTextSymbol.Font = pFont;
                ScaleText.Symbol = pTextSymbol;
            }
            else if (TextSymbol != null)
            {
                ScaleText.Symbol = TextSymbol;
            }

            //设置边框、阴影、背景的距离和圆角
            //边框、背景、阴影距离、角度
            if (SymbolBorder != null)
            {
                if (this.txtBorderGap.Text != null)
                {
                    SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                }
                if (txtBorderAngle.Text != null)
                {
                    SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                }
            }
            if (SymbolBackground != null)
            {
                if (txtBackgroundGap.Text != null)
                {
                    SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                }
                if (txtBackgroundAngle.Text != null)
                {
                    SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                }
            }
            if (SymbolShadow != null)
            {
                if (txtShadowX.Text != null)
                {
                    SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                }
                if (txtShadowY.Text != null)
                {
                    SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                }
                if (txtShadowAngle.Text != null)
                {
                    SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                }
            }
            //添加边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (SymbolBorder != null)
            {
                pFrameProperties.Border = SymbolBorder;
            }
            if (SymbolBackground != null)
            {
                pFrameProperties.Background = SymbolBackground;
            }
            if (SymbolShadow != null)
            {
                pFrameProperties.Shadow = SymbolShadow;
            }
        }
Example #23
0
        public bool SetElementProp()
        {
            try
            {
                //if (txtName.Text.Trim() == "")
                //{
                //    MessageBox.Show("请输入变量名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);yjl0616
                //    return false;
                //}
                IElementProperties3 pElementProp = m_pOrgElement as IElementProperties3;

                if (pElementProp != null)
                {
                    pElementProp.Name = txtName.Text;
                }

                //对于FrameElement的情况
                if (m_pOrgElement is IFrameElement)
                {
                    IFrameProperties pFrameProperty      = null;
                    IFrameDecoration pFrameDecoration    = null;
                    DevComponents.Editors.ComboItem item = cmbBorder.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbBorder.SelectedIndex != -1 && item != null)
                    {
                        IBorder pBorder = (IBorder)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pBorder;
                        pFrameDecoration.HorizontalSpacing    = (double)numBorderGapX.Value;
                        pFrameDecoration.VerticalSpacing      = (double)numBorderGapY.Value;
                        pFrameDecoration.CornerRounding       = (short)numBorderRound.Value;
                        ((IFrameElement)m_pOrgElement).Border = pBorder;
                    }
                    else
                    {
                        ((IFrameElement)m_pOrgElement).Border = null;
                    }
                    item = cmbBack.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbBack.SelectedIndex != -1 && item != null)
                    {
                        IBackground pBackground = (IBackground)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pBackground;
                        pFrameDecoration.HorizontalSpacing        = (double)numBackGapX.Value;
                        pFrameDecoration.VerticalSpacing          = (double)numBackGapY.Value;
                        pFrameDecoration.CornerRounding           = (short)numBackRound.Value;
                        ((IFrameElement)m_pOrgElement).Background = pBackground;
                    }
                    else
                    {
                        ((IFrameElement)m_pOrgElement).Background = null;
                    }
                    item = cmbShadow.SelectedItem as DevComponents.Editors.ComboItem;
                    if (cmbShadow.SelectedIndex != -1 && item != null)
                    {
                        IShadow pShadow = (IShadow)(item.Tag);
                        pFrameDecoration = (IFrameDecoration)pShadow;
                        pFrameDecoration.HorizontalSpacing = (double)numShadowGapX.Value;
                        pFrameDecoration.VerticalSpacing   = (double)numShadowGapY.Value;
                        pFrameDecoration.CornerRounding    = (short)numShadowRound.Value;
                        pFrameProperty        = (IFrameProperties)m_pOrgElement;
                        pFrameProperty.Shadow = pShadow;
                    }
                    else
                    {
                        pFrameProperty        = (IFrameProperties)m_pOrgElement;
                        pFrameProperty.Shadow = null;
                    }
                }
                IEnvelope pBounds = new EnvelopeClass();
                m_pOrgElement.QueryBounds(m_pDisplay, pBounds);

                //设置偏移
                double dx, dy;
                IPoint pFromPoint = pBounds.LowerLeft;

                if (chkUseOffDist.Checked)
                {
                    dx = Convert.ToDouble(numLowerLeftX.Text);
                    dy = Convert.ToDouble(numLowerLeftY.Text);
                }
                else
                {
                    dx = Convert.ToDouble(numLowerLeftX.Text) - pFromPoint.X;
                    dy = Convert.ToDouble(numLowerLeftY.Text) - pFromPoint.Y;
                }
                m_pTransform.Move(dx, dy);

                //设置缩放
                pFromPoint = pBounds.LowerLeft;
                if (chkUsePercent.Checked)
                {
                    dx = ((Convert.ToDouble(numWidth.Text) / 100) * pBounds.Width) / pBounds.Width;
                    dy = ((Convert.ToDouble(numHeight.Text) / 100) * pBounds.Width) / pBounds.Height;
                }
                else
                {
                    dx = Convert.ToDouble(numWidth.Text) / pBounds.Width;
                    dy = Convert.ToDouble(numHeight.Text) / pBounds.Height;
                }
                m_pTransform.Scale(pFromPoint, dx, dy);

                //设置符号
                if (m_pOrgElement is IMarkerElement)
                {
                    IMarkerElement pMrkElement = m_pOrgElement as IMarkerElement;
                    IMarkerSymbol  pSymbol     = (IMarkerSymbol)picPoint.Tag;
                    double         dblSize     = pMrkElement.Symbol.Size;
                    pMrkElement.Symbol = (IMarkerSymbol)picPoint.Tag;
                    pSymbol.Size       = dblSize;
                    pMrkElement.Symbol = pSymbol;
                }
                else if (m_pOrgElement is ILineElement)
                {
                    ILineElement pLinElement = m_pOrgElement as ILineElement;
                    pLinElement.Symbol = (ILineSymbol)picLine.Tag;
                }
                else if (m_pOrgElement is IFillShapeElement)
                {
                    IFillShapeElement pFillElement = m_pOrgElement as IFillShapeElement;
                    pFillElement.Symbol = (IFillSymbol)picPoly.Tag;
                }
                else if (m_pOrgElement is ITextElement)
                {
                    ITextElement pTxtElement = m_pOrgElement as ITextElement;
                    pTxtElement.Text   = txtText.Text;
                    pTxtElement.Symbol = (ITextSymbol)picText.Tag;
                }

                if (m_pOrgElement is IFrameElement)
                {
                    //判断指北针,比例尺,比例文本
                    IMapSurroundFrame pMapSurroundFrame = m_pOrgElement as IMapSurroundFrame;
                    if (pMapSurroundFrame != null)
                    {
                        IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                        if (pMapSurround != null)
                        {
                            if (pMapSurround is INorthArrow)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picArrow.Tag;
                                pMapSurroundFrame.MapSurround.Name = "指北针";
                            }
                            else if (pMapSurround is IScaleBar)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picScale.Tag;
                                pMapSurroundFrame.MapSurround.Name = "比例尺";
                            }
                            else if (pMapSurround is IScaleText)
                            {
                                pMapSurroundFrame.MapSurround      = (IMapSurround)picScaleText.Tag;
                                pMapSurroundFrame.MapSurround.Name = "比例尺";
                            }
                        }
                    }
                }

                m_pGraphicCtn.UpdateElement(m_pOrgElement);
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                if (chkUseOffDist.Checked)
                {
                    numLowerLeftX.Text = "0";
                    numLowerLeftY.Text = "0";
                }
                if (chkUsePercent.Checked)
                {
                    numHeight.Text = "100";
                    numWidth.Text  = "100";
                }
                return(true);
            }
            catch
            {
                //MessageBox.Show("保存属性时出现错误,错误描述为:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //
        }
Example #24
0
        //更新图例
        private void UpdateLegend()
        {
            //边框、背景、阴影的间距
            if (txtBorderGap.Text != null && pSymbolBorder != null)
            {
                pSymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
            }
            if (txtBackgroundGap.Text != null && pSymbolBackground != null)
            {
                pSymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
            }
            if (txtShadowX.Text != null && pSymbolShadow != null)
            {
                pSymbolShadow.VerticalSpacing = double.Parse(this.txtShadowX.Text);
            }
            if (txtShadowY.Text != null && pSymbolShadow != null)
            {
                pSymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowY.Text);
            }
            //边框、背景、阴影的角度
            if (txtBorderAngle.Text != null && pSymbolBorder != null)
            {
                pSymbolBorder.CornerRounding = short.Parse(txtBorderAngle.Text);
            }
            if (txtBackgroundAngle.Text != null && pSymbolBackground != null)
            {
                pSymbolBackground.CornerRounding = short.Parse(txtBackgroundAngle.Text);
            }
            if (txtShadowAngle.Text != null && pSymbolShadow != null)
            {
                pSymbolShadow.CornerRounding = short.Parse(txtShadowAngle.Text);
            }
            //边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (pSymbolBorder != null)
            {
                pFrameProperties.Border = pSymbolBorder;
            }
            if (pSymbolBackground != null)
            {
                pFrameProperties.Background = pSymbolBackground;
            }
            if (pSymbolShadow != null)
            {
                pFrameProperties.Shadow = pSymbolShadow;
            }

            ILegendFormat pLegendFormat = new LegendFormatClass();

            //标题设置  显示
            if (this.cBoxShowTitle.Checked == true)
            {
                pLegendFormat.ShowTitle = true;
            }
            else
            {
                pLegendFormat.ShowTitle = false;
            }
            //标题样式

            if (pTitleSymbol != null)
            {
                pLegendFormat.TitleSymbol = pTitleSymbol;
            }

            //图面样式以及高度和样式设计
            if (pLinePatch != null)
            {
                pLegendFormat.DefaultLinePatch = pLinePatch;
            }
            if (pAreaPatch != null)
            {
                pLegendFormat.DefaultAreaPatch = pAreaPatch;
            }
            if (txtPatchWith.Text != null)
            {
                pLegendFormat.DefaultPatchWidth = double.Parse(txtPatchWith.Text);
            }
            if (txtPatchHeight.Text != null)
            {
                pLegendFormat.DefaultPatchHeight = double.Parse(txtPatchHeight.Text);
            }

            //第四界面从上到下图例各部分之间的距离
            pLegendFormat.TitleGap           = double.Parse(txtTitleAndLegend.Text);
            pLegendFormat.VerticalItemGap    = double.Parse(txtLegendItems.Text);
            pLegendFormat.HorizontalItemGap  = double.Parse(txtColumns.Text);
            pLegendFormat.HeadingGap         = double.Parse(txtHeadings.Text);
            pLegendFormat.TextGap            = double.Parse(txtLabelsAndDescription.Text);
            pLegendFormat.VerticalPatchGap   = double.Parse(txtPatchesV.Text);
            pLegendFormat.HorizontalPatchGap = double.Parse(txtPatchAndLabels.Text);

            //样式添加到图例
            Legend.Title  = this.txtLegendTitle.Text;
            Legend.Format = pLegendFormat;
            //地图链接

            Legend.AutoVisibility = cBoxAddVisibleLayer.Checked; //只显示显示的图层
            Legend.AutoAdd        = cBoxAddNewLayer.Checked;     //自动添加显示的图层
            Legend.AutoReorder    = cBoxNewOrder.Checked;        //按照图层顺序排列图例

            //Legend.ClearItems();
            //Legend.Refresh();

            //图例列数
            double pLegendColumn = double.Parse(this.LegendColumn.Text);
            //图例中要包含的图层个数为  pSelectedidx.Count
            double pLegendItemCount = pSelectedidx.Count;
            //计算图例分裂的位置
            int    ColumnPos = (int)(pLegendItemCount / pLegendColumn);
            double remainder = (pLegendItemCount % pLegendColumn) / pLegendColumn;

            if (remainder >= 0.5)
            {
                ColumnPos = ColumnPos + 1;
            }

            for (int i = 0; i < pSelectedidx.Count; i++)
            {
                ILegendItem pLegendItem = new HorizontalLegendItemClass();
                pLegendItem.Layer = pMap.get_Layer(pSelectedidx[i]);
                int lengendinex = 0;//记录同名图层在legend中的位置
                for (int j = 0; j < Legend.ItemCount; j++)
                {
                    if (Legend.Item[j].Layer == pLegendItem.Layer)
                    {
                        lengendinex = j;
                        break;
                    }
                }
                pLegendItem.ShowDescriptions  = Legend.Item[lengendinex].ShowDescriptions;
                pLegendItem.ShowHeading       = Legend.Item[lengendinex].ShowHeading;
                pLegendItem.ShowLabels        = Legend.Item[lengendinex].ShowLabels;
                pLegendItem.ShowLayerName     = Legend.Item[lengendinex].ShowLayerName;
                pLegendItem.HeadingSymbol     = Legend.Item[lengendinex].HeadingSymbol;
                pLegendItem.LayerNameSymbol   = Legend.Item[lengendinex].LayerNameSymbol;
                pLegendItem.LegendClassFormat = Legend.Item[lengendinex].LegendClassFormat;

                //列数设置
                //列数设置
                if (ColumnPos <= 1)
                {
                    pLegendItem.NewColumn = true;
                }
                else if (ColumnPos > 1 && i > 0)
                {
                    int columnI = i % ColumnPos;
                    if (columnI == 0)
                    {
                        pLegendItem.NewColumn = true;
                    }
                }
                legendlist.Add(pLegendItem);
            }
            Legend.ClearItems();
            Legend.Refresh();
            for (int i = 0; i < legendlist.Count; i++)
            {
                Legend.AddItem(legendlist[i]);
            }
            ILegendLayout pLegendLayout = pLegendFormat as ILegendLayout;

            pLegendLayout.ScaleGraphicsOnResize = false;
            m_hookHelper.ActiveView.Refresh();
        }
Example #25
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            m_legend.Name = this.textBoxElement.Text.Trim();
            m_legend.Title = this.textBox1.Text; //图例的标题
            ILayer player;
            ILegendItem pLegendItem = null;
            #region //设置图例显示的项
            if (this.listBox2.Items.Count != 0)
            {
                m_legend.ClearItems();
                foreach (object item in this.listBox2 .Items ) //设置需要的图例项  根据用户需要添加
                {
                    for (int j = 0; j < m_pageLayoutControl.ActiveView.FocusMap.LayerCount; j++)
                    {
                        player = m_pageLayoutControl.ActiveView.FocusMap.get_Layer(j);
                        if (player.Name == item .ToString ())
                        {

                             IFeatureLayer pFLayer = player as IFeatureLayer;
                             IFeatureClass pFeatureClass = pFLayer.FeatureClass;
                           if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                             {
                                continue;
                              }
                              else
                               {
                              pLegendItem = new HorizontalLegendItemClass(); //图例项标签的样式
                              pLegendItem.Layer = player;
                              pLegendItem.Columns = 1;
                              pLegendItem.ShowDescriptions = false;
                              pLegendItem.ShowHeading = false;
                              pLegendItem.ShowLabels = true;
                              switch (comboBox1.SelectedItem.ToString().Trim () )
                              {
                                  case "所有文本符号":
                                      pLegendItem.LayerNameSymbol = pTextSymbol; //设置字体样式
                                      pLegendItem.HeadingSymbol = pTextSymbol;
                                      pLegendItem.LegendClassFormat.LabelSymbol = pTextSymbol;
                                      break;
                                  case "所有图层名称":
                                      pLegendItem.LayerNameSymbol = pTextSymbol;
                                      break;
                                  case "所有标题项":
                                      pLegendItem.HeadingSymbol = pTextSymbol;
                                      break;
                                  case "所有标注项":
                                      pLegendItem.LegendClassFormat.LabelSymbol = pTextSymbol;
                                      break;
                                  case "所有描述性文字":
                                      break;

                              }

                              }
                            m_legend.AddItem(pLegendItem );
                        }
                    }

                }
            }
            #endregion
            plegendFormat.DefaultPatchHeight = Convert.ToDouble(this.textBoxHeight.Text);//块的高度
            plegendFormat.DefaultPatchWidth = Convert.ToDouble(this.textBoxWidth.Text);//块的宽度

            #region //设置图例的底色边框
            IMapSurround pmapsurronud = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = pmapsurronud;
            m_FrameProperties = (IFrameProperties)mapSurroundFrame;
               // m_SymbolBackground.FillSymbol.Color = ConvertColorToIColor(this.btnBackGroundColor.BackColor);
            m_FrameProperties.Background =(IBackground ) m_SymbolBackground;
               // m_SymbolBorder.LineSymbol.Color = ConvertColorToIColor(this.btnBolderColor.BackColor);
            m_FrameProperties.Border = (IBorder)m_SymbolBorder;
               // m_SymbolShadow.FillSymbol.Color = ConvertColorToIColor(this.btnShadowColor.BackColor);
            m_FrameProperties.Shadow = (IShadow)m_SymbolShadow;

            #endregion

                IEnvelope pEnvelop = new EnvelopeClass();  //图例的位置
                pEnvelop.PutCoords(Convert.ToDouble(this.textBoxX.Text), Convert.ToDouble(this.textBoxY.Text),
                Convert.ToDouble(this.textBoxX.Text) + Convert.ToDouble(this.textBoxWidth1.Text),
                Convert.ToDouble(this.textBoxY.Text) + Convert.ToDouble(this.textBoxHeight1.Text));

            IElement m_element = mapSurroundFrame   as IElement;
            m_element.Geometry = pEnvelop;
            m_pageLayoutControl.AddElement(m_element ,Type.Missing ,Type .Missing ,m_legend .Name ,0);
            m_pageLayoutControl.ActiveView.Refresh();
            this.Close();
        }
Example #26
0
        private void UpdateSymbol(IStyleGalleryItem styleGalleryItem)
        {
            //Get IPage interface
            IPage page = axPageLayoutControl1.Page;

            //Apply the symbol as a property to the page
            if (optIPropertySupport.Checked)
            {
                //Query interface for IPropertySupport
                IPropertySupport propertySupport = page as IPropertySupport;
                //If the symbol can be applied
                if (propertySupport.CanApply(styleGalleryItem.Item))
                {
                    //Apply the object
                    propertySupport.Apply(styleGalleryItem.Item);
                }
                else
                {
                    MessageBox.Show("Unable to apply this symbol!");
                }
            }

            //Apply the symbol as an IFrameProperties property
            if (optIFrameProperties.Checked)
            {
                //Query interface for IFrameProperties
                IFrameProperties frameProperties = page as IFrameProperties;
                if (styleGalleryItem.Item is IBorder)
                {
                    //Set the frame's border
                    frameProperties.Border = styleGalleryItem.Item as IBorder;
                }
                else if (styleGalleryItem.Item is IBackground)
                {
                    //Set the frame's background
                    frameProperties.Background = styleGalleryItem.Item as IBackground;
                }
                else if (styleGalleryItem.Item is IColor)
                {
                    MessageBox.Show("There is no color property on IFrameProperties!");
                }
                else if (styleGalleryItem.Item is IShadow)
                {
                    //Set the frame's shadow
                    frameProperties.Shadow = styleGalleryItem.Item as IShadow;
                }
            }

            //Apply the symbol as an IPage property
            if (optIPage.Checked)
            {
                if (styleGalleryItem.Item is IBorder)
                {
                    //Set the frame's border
                    page.Border = styleGalleryItem.Item as IBorder;
                }
                else if (styleGalleryItem.Item is IBackground)
                {
                    //Set the frame's background
                    page.Background = styleGalleryItem.Item as IBackground;
                }
                else if (styleGalleryItem.Item is IColor)
                {
                    //Set the frame's background color
                    page.BackgroundColor = styleGalleryItem.Item as IColor;
                }
                else if (styleGalleryItem.Item is IShadow)
                {
                    MessageBox.Show("There is no shadow property on IPage!");
                }
            }

            //Refresh
            axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
Example #27
0
        //创建图例
        private void CreateLegend()
        {
            ILegendFormat     pLegendFormat     = new LegendFormatClass();
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pActiveView = m_hookHelper.ActiveView as IActiveView;
            pMap        = pActiveView.FocusMap;

            //边框、背景、阴影的间距
            if (txtLegendFrameGap.Text != null && pSymbolBorder != null)
            {
                pSymbolBorder.Gap = double.Parse(this.txtLegendFrameGap.Text);
            }
            if (txtLegendFrameGap.Text != null && pSymbolBackground != null)
            {
                pSymbolBackground.Gap = double.Parse(this.txtLegendFrameGap.Text);
            }
            if (txtLegendFrameGap.Text != null && pSymbolShadow != null)
            {
                pSymbolShadow.VerticalSpacing   = double.Parse(this.txtLegendFrameGap.Text) + 10;
                pSymbolShadow.HorizontalSpacing = double.Parse(this.txtLegendFrameGap.Text) + 10;
            }
            //边框、背景、阴影的角度
            if (txtLegendFrameAngle.Text != null && pSymbolBorder != null)
            {
                pSymbolBorder.CornerRounding = short.Parse(txtLegendFrameAngle.Text);
            }
            if (txtLegendFrameAngle.Text != null && pSymbolBackground != null)
            {
                pSymbolBackground.CornerRounding = short.Parse(txtLegendFrameAngle.Text);
            }
            if (txtLegendFrameAngle.Text != null && pSymbolShadow != null)
            {
                pSymbolShadow.CornerRounding = short.Parse(txtLegendFrameAngle.Text);
            }
            //边框、背景、阴影
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (pSymbolBorder != null)
            {
                pFrameProperties.Border = pSymbolBorder;
            }
            if (pSymbolBackground != null)
            {
                pFrameProperties.Background = pSymbolBackground;
            }
            if (pSymbolShadow != null)
            {
                pFrameProperties.Shadow = pSymbolShadow;
            }

            //显示标题
            pLegendFormat.ShowTitle = true;
            //标题位置
            pLegendFormat.TitlePosition = esriRectanglePosition.esriTopSide;
            //标题样式
            pLegendFormat.TitleSymbol = CreateTitleSymbol();


            //第四界面从上到下图例各部分之间的距离
            pLegendFormat.TitleGap           = double.Parse(txtTitleAndLegend.Text);
            pLegendFormat.VerticalItemGap    = double.Parse(txtLegendItems.Text);
            pLegendFormat.HorizontalItemGap  = double.Parse(txtColumns.Text);
            pLegendFormat.HeadingGap         = double.Parse(txtHeadings.Text);
            pLegendFormat.TextGap            = double.Parse(txtLabelsAndDescription.Text);
            pLegendFormat.VerticalPatchGap   = double.Parse(txtPatchesV.Text);
            pLegendFormat.HorizontalPatchGap = double.Parse(txtPatchAndLabels.Text);

            pLegendFormat.LayerNameGap = 2;

            //图面的样式以及高度和宽度
            if (pLinePatch != null)
            {
                pLegendFormat.DefaultLinePatch = pLinePatch;
            }
            if (pAreaPatch != null)
            {
                pLegendFormat.DefaultAreaPatch = pAreaPatch;
            }
            pLegendFormat.DefaultPatchHeight = double.Parse(this.txtPatchHeight.Text);
            pLegendFormat.DefaultPatchWidth  = double.Parse(this.txtPatchWith.Text);


            //创建图例
            ILegend pLegend = new LegendClass_2();

            //图例名称
            //pLegend.Name = this.txtLegendTitle.Text;
            pLegend.AutoVisibility = false; //显示显示的图层
            pLegend.AutoAdd        = false; //自动添加新数据到图例

            pLegend.AutoReorder = true;     //根据图层顺序自动排列
            pLegend.Title       = this.txtLegendTitle.Text;
            pLegend.Format      = pLegendFormat;

            pLegend.Map = pMap;
            pLegend.ClearItems();
            //pLegend.Refresh();

            //图例列数
            double pLegendColumn = double.Parse(this.LegendColumn.Text);
            //图例中要包含的图层个数为  pSelectedidx.Count
            double pLegendItemCount = pSelectedidx.Count;
            //计算图例分裂的位置
            int    ColumnPos = (int)(pLegendItemCount / pLegendColumn);
            double remainder = (pLegendItemCount % pLegendColumn) / pLegendColumn;

            if (remainder >= 0.5)
            {
                ColumnPos = ColumnPos + 1;
            }
            //设置添加到图例的图层
            for (int i = 0; i < pSelectedidx.Count; i++)
            {
                ILegendItem pLegendItem = new HorizontalLegendItemClass();

                ILayer pLayer = (ILayer)(pMap.get_Layer(pSelectedidx[i]));
                if (!pLayer.Valid)
                {
                    continue;
                }
                pLegendItem.Layer = pLayer;

                //显示标注和描述
                pLegendItem.ShowDescriptions = true;
                pLegendItem.ShowLabels       = true;

                //标注和描述字体样式
                ITextSymbol pLDTextSymbol = new TextSymbolClass();
                IFontDisp   pLDFont       = new StdFontClass() as IFontDisp;
                IRgbColor   pLDColor      = new RgbColorClass();
                pLDColor.Red        = 0;
                pLDColor.Green      = 0;
                pLDColor.Blue       = 0;
                pLDTextSymbol.Color = pLDColor;

                pLDFont.Size       = (decimal)8;
                pLDFont.Name       = "宋体";
                pLDTextSymbol.Font = pLDFont;
                ILegendClassFormat pLegendClassFormat = new LegendClassFormatClass();
                pLegendClassFormat.LabelSymbol       = pLDTextSymbol;
                pLegendClassFormat.DescriptionSymbol = pLDTextSymbol;

                pLegendItem.LegendClassFormat = pLegendClassFormat;
                //图层名称是否显示
                if (pLegendItem.Layer is IFeatureLayer)
                {
                    if (((IGeoFeatureLayer)pLegendItem.Layer).Renderer is ISimpleRenderer)
                    {
                        pLegendItem.ShowHeading   = false;
                        pLegendItem.ShowLayerName = false;
                    }
                    else
                    {
                        pLegendItem.ShowLayerName = true;
                        pLegendItem.ShowHeading   = true;
                        //图层名称和头文件的样式
                        ITextSymbol pLHTextSymbol = new TextSymbolClass();
                        IFontDisp   pLHFont       = new StdFontClass() as IFontDisp;
                        IRgbColor   pLHColor      = new RgbColorClass();
                        pLDColor.Red   = 0;
                        pLDColor.Green = 0;
                        pLDColor.Blue  = 0;

                        pLHTextSymbol.Color = pLHColor;
                        pLHFont.Name        = "宋体";
                        pLHFont.Size        = 10;
                        pLHFont.Bold        = true;
                        pLHTextSymbol.Font  = pLHFont;
                        pLHTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;

                        pLegendItem.HeadingSymbol   = pLHTextSymbol;
                        pLegendItem.LayerNameSymbol = pLHTextSymbol;
                    }
                }
                else if (pLegendItem.Layer is IRasterLayer)
                {
                    pLegendItem.ShowLayerName = true;
                    pLegendItem.ShowHeading   = true;
                    //图层名称和头文件的样式
                    ITextSymbol pLHTextSymbol = new TextSymbolClass();
                    IFontDisp   pLHFont       = new StdFontClass() as IFontDisp;
                    IRgbColor   pLHColor      = new RgbColorClass();
                    pLDColor.Red   = 0;
                    pLDColor.Green = 0;
                    pLDColor.Blue  = 0;

                    pLHTextSymbol.Color = pLHColor;
                    pLHFont.Name        = "宋体";
                    pLHFont.Size        = 10;
                    pLHFont.Bold        = true;
                    pLHTextSymbol.Font  = pLHFont;
                    pLHTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;

                    pLegendItem.HeadingSymbol   = pLHTextSymbol;
                    pLegendItem.LayerNameSymbol = pLHTextSymbol;
                }

                //列数设置
                if (ColumnPos <= 1)
                {
                    pLegendItem.NewColumn = true;
                }
                else if (ColumnPos > 1 && i > 0)
                {
                    int columnI = i % ColumnPos;
                    if (columnI == 0)
                    {
                        pLegendItem.NewColumn = true;
                    }
                }

                ILegendLayout pLegendLayout = pLegendFormat as ILegendLayout;
                pLegendLayout.ScaleGraphicsOnResize = false;


                //将图层及样式设计加入图例中
                pLegend.AddItem(pLegendItem);
                pLegend.Refresh();
            }



            //将图例加载到PageLayout上
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pMap) as IMapFrame;

            if (pMapFrame == null)
            {
                return;
            }

            pMapSurroundFrame.MapFrame    = pMapFrame;
            pMapSurroundFrame.MapSurround = (IMapSurround)pLegend;
            IElement pElement = (IElement)pMapSurroundFrame;


            IPageLayout pPageLayout = (IPageLayout)pActiveView;
            IPage       pPage       = pPageLayout.Page;
            double      pWidth      = pPage.PrintableBounds.XMax / 10.0;
            double      pHeigth     = pPage.PrintableBounds.YMin / 10.0;

            IEnvelope pEnvelope = new EnvelopeClass();

            pEnvelope.PutCoords(pWidth, pHeigth, pWidth + 6, pHeigth + 6);
            pElement.Geometry = (IGeometry)pEnvelope;

            pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0);

            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null);
        }
Example #28
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            m_legend.Name  = this.textBoxElement.Text.Trim();
            m_legend.Title = this.textBox1.Text; //图例的标题
            ILayer      player;
            ILegendItem pLegendItem = null;

            #region //设置图例显示的项
            if (this.listBox2.Items.Count != 0)
            {
                m_legend.ClearItems();
                foreach (object item in this.listBox2.Items)   //设置需要的图例项  根据用户需要添加
                {
                    for (int j = 0; j < m_pageLayoutControl.ActiveView.FocusMap.LayerCount; j++)
                    {
                        player = m_pageLayoutControl.ActiveView.FocusMap.get_Layer(j);
                        if (player.Name == item.ToString())
                        {
                            IFeatureLayer pFLayer       = player as IFeatureLayer;
                            IFeatureClass pFeatureClass = pFLayer.FeatureClass;
                            if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                            {
                                continue;
                            }
                            else
                            {
                                pLegendItem                  = new HorizontalLegendItemClass(); //图例项标签的样式
                                pLegendItem.Layer            = player;
                                pLegendItem.Columns          = 1;
                                pLegendItem.ShowDescriptions = false;
                                pLegendItem.ShowHeading      = false;
                                pLegendItem.ShowLabels       = true;
                                switch (comboBox1.SelectedItem.ToString().Trim())
                                {
                                case "所有文本符号":
                                    pLegendItem.LayerNameSymbol = pTextSymbol;   //设置字体样式
                                    pLegendItem.HeadingSymbol   = pTextSymbol;
                                    pLegendItem.LegendClassFormat.LabelSymbol = pTextSymbol;
                                    break;

                                case "所有图层名称":
                                    pLegendItem.LayerNameSymbol = pTextSymbol;
                                    break;

                                case "所有标题项":
                                    pLegendItem.HeadingSymbol = pTextSymbol;
                                    break;

                                case "所有标注项":
                                    pLegendItem.LegendClassFormat.LabelSymbol = pTextSymbol;
                                    break;

                                case "所有描述性文字":
                                    break;
                                }
                            }
                            m_legend.AddItem(pLegendItem);
                        }
                    }
                }
            }
            #endregion
            plegendFormat.DefaultPatchHeight = Convert.ToDouble(this.textBoxHeight.Text); //块的高度
            plegendFormat.DefaultPatchWidth  = Convert.ToDouble(this.textBoxWidth.Text);  //块的宽度


            #region //设置图例的底色边框
            IMapSurround pmapsurronud = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = pmapsurronud;
            m_FrameProperties            = (IFrameProperties)mapSurroundFrame;
            // m_SymbolBackground.FillSymbol.Color = ConvertColorToIColor(this.btnBackGroundColor.BackColor);
            m_FrameProperties.Background = (IBackground )m_SymbolBackground;
            // m_SymbolBorder.LineSymbol.Color = ConvertColorToIColor(this.btnBolderColor.BackColor);
            m_FrameProperties.Border = (IBorder)m_SymbolBorder;
            // m_SymbolShadow.FillSymbol.Color = ConvertColorToIColor(this.btnShadowColor.BackColor);
            m_FrameProperties.Shadow = (IShadow)m_SymbolShadow;

            #endregion



            IEnvelope pEnvelop = new EnvelopeClass();      //图例的位置
            pEnvelop.PutCoords(Convert.ToDouble(this.textBoxX.Text), Convert.ToDouble(this.textBoxY.Text),
                               Convert.ToDouble(this.textBoxX.Text) + Convert.ToDouble(this.textBoxWidth1.Text),
                               Convert.ToDouble(this.textBoxY.Text) + Convert.ToDouble(this.textBoxHeight1.Text));


            IElement m_element = mapSurroundFrame   as IElement;
            m_element.Geometry = pEnvelop;
            m_pageLayoutControl.AddElement(m_element, Type.Missing, Type.Missing, m_legend.Name, 0);
            m_pageLayoutControl.ActiveView.Refresh();
            this.Close();
        }
Example #29
0
        private void FrmLegendAttribute_Load(object sender, EventArgs e)
        {
            //图例界面要素信息加载

            ILegendFormat pLegendFormat = Legend.Format;

            //标题
            this.txtLegendTitle.Text = Legend.Title;
            if (pLegendFormat.ShowTitle == true)
            {
                this.cBoxShowTitle.Checked  = true;
                this.txtLegendTitle.Enabled = true;
            }
            else
            {
                this.cBoxShowTitle.Checked  = false;
                this.txtLegendTitle.Enabled = false;
            }
            pTitleSymbol = pLegendFormat.TitleSymbol;
            //图面
            this.txtPatchWith.Text   = pLegendFormat.DefaultPatchWidth.ToString();
            this.txtPatchHeight.Text = pLegendFormat.DefaultPatchHeight.ToString();

            if (pLegendFormat.DefaultLinePatch != null)
            {
                FrmPatchLineAndArea frmPatchLine = new FrmPatchLineAndArea(esriSymbologyStyleClass.esriStyleClassLinePatches);
                this.btLineShape.Image = frmPatchLine.GetImageByGiveLineSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassLinePatches, (ILinePatch)pLegendFormat.DefaultLinePatch, btLineShape.Width, btLineShape.Height);
            }
            if (pLegendFormat.DefaultAreaPatch != null)
            {
                FrmPatchLineAndArea frmPatchArea = new FrmPatchLineAndArea(esriSymbologyStyleClass.esriStyleClassAreaPatches);
                this.btAreaShape.Image = frmPatchArea.GetImageByGiveAreaSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassAreaPatches, (IAreaPatch)pLegendFormat.DefaultAreaPatch, btAreaShape.Width, btAreaShape.Height);
            }

            //间隔
            this.txtTitleAndLegend.Text       = pLegendFormat.TitleGap.ToString();
            this.txtLegendItems.Text          = pLegendFormat.VerticalItemGap.ToString();
            this.txtColumns.Text              = pLegendFormat.HorizontalItemGap.ToString();
            this.txtLabelsAndDescription.Text = pLegendFormat.TextGap.ToString();
            this.txtHeadings.Text             = pLegendFormat.HeadingGap.ToString();
            this.txtPatchesV.Text             = pLegendFormat.VerticalPatchGap.ToString();
            this.txtPatchAndLabels.Text       = pLegendFormat.HorizontalPatchGap.ToString();

            //图层加载
            if (pMap.LayerCount > 0)
            {
                for (int i = 0; i < pMap.LayerCount; i++)
                {
                    //将所有数据名称加载到ListView中
                    this.LViewMapLayer.Items.Add(pMap.get_Layer(i).Name);

                    for (int j = 0; j < Legend.ItemCount; j++)
                    {
                        ILegendItem pLegendItem = Legend.Item[j];
                        if (pMap.get_Layer(i).Name == pLegendItem.Layer.Name)
                        {
                            this.LViewLegendLayer.Items.Add(pLegendItem.Layer.Name);
                            pSelectedidx.Add(i);
                        }
                    }
                }
            }

            //各类文本样式
            ILegendItem pLegendItem0 = Legend.Item[0];

            pLayerNameSymbol = pLegendItem0.LayerNameSymbol;
            pHeadingSymbol   = pLegendItem0.HeadingSymbol;
            ILegendClassFormat pLegendClassFormat = pLegendItem0.LegendClassFormat;

            pLabelSymbol       = pLegendClassFormat.LabelSymbol;
            pDescriptionSymbol = pLegendClassFormat.DescriptionSymbol;

            ////图例列数
            //ILegendItem pLegendItemff = new HorizontalLegendItemClass();
            //this.LegendColumn.Text = pLegendItemff.Columns.ToString ();
            //文本样式下拉列表
            this.cboBoxTextSymbol.SelectedIndex = 0;

            cBoxAddVisibleLayer.Checked = Legend.AutoVisibility; //只显示显示的图层
            cBoxAddNewLayer.Checked     = Legend.AutoAdd;        //自动添加显示的图层
            cBoxNewOrder.Checked        = Legend.AutoReorder;    //按照图层顺序排列图例

            //地图框架
            IFrameProperties pFrameProperties = pMapSurroundFrame as IFrameProperties;

            if (pMapSurroundFrame.Border != null)
            {
                FrmFrameBorder frm = new FrmFrameBorder(SymbolStyle, (ISymbolBorder)pMapSurroundFrame.Border);

                if (btBorder.Image != null)
                {
                    btBorder.Image.Dispose();
                }
                this.btBorder.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBorders, (ISymbolBorder)pMapSurroundFrame.Border, btBorder.Width, btBorder.Height);
                pSymbolBorder       = pFrameProperties.Border as ISymbolBorder;
                txtBorderGap.Text   = pFrameProperties.Border.Gap.ToString();
                txtBorderAngle.Text = pSymbolBorder.CornerRounding.ToString();
            }
            if (pMapSurroundFrame.Background != null)
            {
                FrmFrameBackground frm = new FrmFrameBackground(SymbolStyle, (ISymbolBackground)pMapSurroundFrame.Background);

                if (btBackground.Image != null)
                {
                    btBackground.Image.Dispose();
                }
                this.btBackground.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassBackgrounds, (ISymbolBackground)pMapSurroundFrame.Background, btBackground.Width, btBackground.Height);

                pSymbolBackground       = pFrameProperties.Background as ISymbolBackground;
                txtBackgroundGap.Text   = pSymbolBackground.Gap.ToString();
                txtBackgroundAngle.Text = pSymbolBackground.CornerRounding.ToString();
            }
            if (pFrameProperties.Shadow != null)
            {
                FrmFrameShadow frm = new FrmFrameShadow(SymbolStyle, (ISymbolShadow)pFrameProperties.Shadow);

                if (btShadow.Image != null)
                {
                    btShadow.Image.Dispose();
                }
                this.btShadow.Image = frm.GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass.esriStyleClassShadows, (ISymbolShadow)pFrameProperties.Shadow, btShadow.Width, btShadow.Height);

                pSymbolShadow       = pFrameProperties.Shadow as ISymbolShadow;
                txtShadowX.Text     = pSymbolShadow.HorizontalSpacing.ToString();
                txtShadowY.Text     = pSymbolShadow.VerticalSpacing.ToString();
                txtShadowAngle.Text = pSymbolShadow.CornerRounding.ToString();
            }
        }
Example #30
0
        private void LegendWizard_Load(object sender, EventArgs e)
        {
            if (m_pageLayoutControl.ActiveView.FocusMap == null)
            {
                MessageBox.Show("请先添加地图");
                return;
            }
            #region                       //点击 添加图例按钮 或在 PageLayoutControl中双击图例时
            if (mapSurroundFrame == null) //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例;
            {
                //Get the GraphicsContainer
                IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer;
                graphicsContainer.Reset();
                IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties;
                //Get the MapFrame
                IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap);
                if (mapFrame == null)
                {
                    return;
                }
                while (pElementPerties != null) //从地图中获得已有的图例
                {
                    if (pElementPerties.Type == "Map Surround Frame")
                    {
                        pMapSurrounFrame = pElementPerties as IMapSurroundFrame;
                        if (pMapSurrounFrame.MapSurround.Name == "Legend")
                        {
                            m_legend = pMapSurrounFrame.MapSurround as ILegend;
                            break;
                        }
                    }
                    pElementPerties = (IElementProperties)graphicsContainer.Next();
                }
                if (m_legend == null) //当地图中没有添加图例时 创建新图例
                {
                    //Create a legend
                    UID uID = new UIDClass();
                    uID.Value = "esriCarto.Legend";

                    //Create a MapSurroundFrame from the MapFrame
                    mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

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

                    m_legend = mapSurroundFrame.MapSurround as ILegend;
                }
                else
                {
                    mapSurroundFrame = pMapSurrounFrame;
                }



                UID m_uid = new UIDClass();
                m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}";
                m_mapLayers = m_mapControl.Map as IMapLayers;
                m_emuLayer  = m_mapLayers.get_Layers(m_uid, true);//获取图层
                if (m_emuLayer != null)
                {
                    m_emuLayer.Reset();
                    ILayer m_layer = null;
                    while ((m_layer = m_emuLayer.Next()) != null)
                    {
                        this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中
                    }
                }
            }
            #endregion
            else //在双击任意范围打印框中图例时,获得图例,及图层信息;
            {
                if (m_Map == null)
                {
                    MessageBox.Show("请先添加地图!");
                }
                for (int k = 0; k < m_Map.LayerCount; k++)
                {
                    listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString());
                }
                m_legend = mapSurroundFrame.MapSurround as ILegend;
            }
            //以下设置需要用到的变量 及初始化 对话框
            plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的

            pTextSymbol      = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式

            if (m_legend.Title != null)
            {
                textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本
            }
            else
            {
                textBox1.Text = "Legend";
            }

            this.textBoxWidth.Text  = "36";
            this.textBoxHeight.Text = "15";
            IMapSurround mapSurround = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = mapSurround;
            m_FrameProperties            = (IFrameProperties)mapSurroundFrame;
            ISymbolBackground pSymbolBack   = m_FrameProperties.Background as ISymbolBackground;
            ISymbolBorder     pSymbolBorder = m_FrameProperties.Border as ISymbolBorder;
            ISymbolShadow     pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow;
            if (pSymbolBack != null)
            {
                this.btnBackGroundColor.BackColor = ColorTranslator.FromOle(pSymbolBack.FillSymbol.Color.RGB);
            }
            if (pSymbolBorder != null)
            {
                this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB);
            }
            if (pSymbolShadow != null)
            {
                this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB);
            }
        }
Example #31
0
        private void LegendWizard_Load(object sender, EventArgs e)
        {
            if (m_pageLayoutControl.ActiveView.FocusMap == null)
            {
                MessageBox.Show("请先添加地图");
                return;

            }
            #region //点击 添加图例按钮 或在 PageLayoutControl中双击图例时
            if (mapSurroundFrame == null)  //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例;
            {

                //Get the GraphicsContainer
                IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer;
                graphicsContainer.Reset();
                IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties;
                //Get the MapFrame
                IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap);
                if (mapFrame == null) return;
                while (pElementPerties != null) //从地图中获得已有的图例
                {
                    if (pElementPerties.Type == "Map Surround Frame")
                    {
                        pMapSurrounFrame = pElementPerties as IMapSurroundFrame;
                        if (pMapSurrounFrame.MapSurround.Name == "Legend")
                        {
                            m_legend = pMapSurrounFrame.MapSurround as ILegend;
                            break;
                        }
                    }
                    pElementPerties = (IElementProperties)graphicsContainer.Next();
                }
                if (m_legend == null) //当地图中没有添加图例时 创建新图例
                {
                    //Create a legend
                    UID uID = new UIDClass();
                    uID.Value = "esriCarto.Legend";

                    //Create a MapSurroundFrame from the MapFrame
                    mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

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

                    m_legend = mapSurroundFrame.MapSurround as ILegend;
                }
                else
                {
                    mapSurroundFrame = pMapSurrounFrame;

                }

                UID m_uid = new UIDClass();
                m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}";
                m_mapLayers = m_mapControl.Map as IMapLayers;
                m_emuLayer = m_mapLayers.get_Layers(m_uid, true);//获取图层
                if (m_emuLayer != null)
                {
                    m_emuLayer.Reset();
                    ILayer m_layer = null;
                    while ((m_layer = m_emuLayer.Next()) != null)
                    {
                        this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中
                    }
                }
            }
               #endregion
            else //在双击任意范围打印框中图例时,获得图例,及图层信息;
            {
                if (m_Map == null)
                {
                    MessageBox.Show("请先添加地图!");
                }
                for (int k = 0; k < m_Map.LayerCount; k++)
                {
                    listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString());
                }
                m_legend = mapSurroundFrame .MapSurround as ILegend;
            }
            //以下设置需要用到的变量 及初始化 对话框
            plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的

            pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式

            if (m_legend.Title != null)
                textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本
            else
                textBox1.Text = "Legend";

            this.textBoxWidth.Text = "36";
            this.textBoxHeight.Text = "15";
            IMapSurround mapSurround = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = mapSurround;
            m_FrameProperties = (IFrameProperties)mapSurroundFrame;
            ISymbolBackground pSymbolBack = m_FrameProperties.Background as ISymbolBackground;
            ISymbolBorder pSymbolBorder = m_FrameProperties.Border as ISymbolBorder;
            ISymbolShadow pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow;
            if (pSymbolBack !=null )
            this.btnBackGroundColor.BackColor =ColorTranslator.FromOle ( pSymbolBack.FillSymbol.Color.RGB ) ;
            if (pSymbolBorder != null)
            this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB);
             if (pSymbolShadow != null)
            this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB);
        }