Beispiel #1
0
        private void PreviewColorSet()
        {
            PreviewImage(m_styleGalleryItem);
            grpSymbol.Tag = m_styleGalleryItem.Item;

            Color     pColor;
            IRgbColor pRgbColor;

            if (m_styleGalleryItem.Item is IMarkerSymbol)
            {
                IMarkerSymbol pMrkSymbol = (IMarkerSymbol)m_styleGalleryItem.Item;
                pRgbColor = PublicClass.GetRGBColor(pMrkSymbol.Color);
                pColor    = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue);

                colorPoint.Color     = pColor;
                colorPoint.ForeColor = pColor;

                if (pRgbColor.Transparency == 0)
                {
                    colorPoint.Color     = Color.Transparent;
                    colorPoint.ForeColor = Color.Transparent;
                }

                numPtSize.Value    = (decimal)pMrkSymbol.Size;
                numPtXOffSet.Value = (decimal)pMrkSymbol.XOffset;
                numPtYOffSet.Value = (decimal)pMrkSymbol.YOffset;
                SetGroupVisible(1);
            }
            else if (m_styleGalleryItem.Item is ILineSymbol)
            {
                ILineSymbol pLineSymbol = (ILineSymbol)m_styleGalleryItem.Item;
                pRgbColor = PublicClass.GetRGBColor(pLineSymbol.Color);
                pColor    = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue);

                colorLine.Color     = pColor;
                colorLine.ForeColor = pColor;

                if (pRgbColor.Transparency == 0)
                {
                    colorLine.Color     = Color.Transparent;
                    colorLine.ForeColor = Color.Transparent;
                }

                numLineWidth.Value = (decimal)pLineSymbol.Width;
                ILineProperties pLineProp = pLineSymbol as ILineProperties;
                if (pLineProp != null)
                {
                    numLineOffSet.Value = (decimal)pLineProp.Offset;
                }
                else
                {
                    numLineOffSet.Value = 0;
                }
                SetGroupVisible(2);
            }
            else if (m_styleGalleryItem.Item is IFillSymbol)
            {
                IFillSymbol pFillSymbol = (IFillSymbol)m_styleGalleryItem.Item;
                pRgbColor = PublicClass.GetRGBColor(pFillSymbol.Color);
                pColor    = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue);

                colorPolygon.Color     = pColor;
                colorPolygon.ForeColor = pColor;

                if (pRgbColor.Transparency == 0)
                {
                    colorPolygon.Color     = Color.Transparent;
                    colorPolygon.ForeColor = Color.Transparent;;
                }

                if (pFillSymbol.Outline != null)
                {
                    ILineSymbol pOutLine = pFillSymbol.Outline;
                    pRgbColor = PublicClass.GetRGBColor(pOutLine.Color);
                    pColor    = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue);

                    colorBorder.Color     = pColor;
                    colorBorder.ForeColor = pColor;

                    if (pRgbColor.Transparency == 0)
                    {
                        colorBorder.Color     = Color.Transparent;
                        colorBorder.ForeColor = Color.Transparent;
                    }

                    numOutLineWidth.Value = (decimal)pOutLine.Width;
                }
                else
                {
                    btnOutLineColor.BackColor = this.BackColor;
                    numOutLineWidth.Value     = 0;
                }
                SetGroupVisible(3);
            }
            else if (m_styleGalleryItem.Item is ITextSymbol)
            {
                ITextSymbol pTextSymbol = (ITextSymbol)m_styleGalleryItem.Item;
                pRgbColor = PublicClass.GetRGBColor(pTextSymbol.Color);
                pColor    = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue);

                colorAnno.Color     = pColor;
                colorAnno.ForeColor = pColor;
                SetGroupVisible(4);

                stdole.IFontDisp pFontDisp = pTextSymbol.Font;
                toolBarStyle.Buttons["toolBlod"].Pushed      = pFontDisp.Bold;
                toolBarStyle.Buttons["toolItalic"].Pushed    = pFontDisp.Italic;
                toolBarStyle.Buttons["toolUnderline"].Pushed = pFontDisp.Underline;

                ToolBarButton btn;
                for (int i = 0; i < toolBarAlign.Buttons.Count; i++)
                {
                    btn        = toolBarAlign.Buttons[i];
                    btn.Pushed = false;
                }

                if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                {
                    btn        = toolBarAlign.Buttons["toolLeft"];
                    btn.Pushed = true;
                }
                else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                {
                    btn        = toolBarAlign.Buttons["toolCenter"];
                    btn.Pushed = true;
                }
                else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                {
                    btn        = toolBarAlign.Buttons["toolRight"];
                    btn.Pushed = true;
                }
                else
                {
                    btn        = toolBarAlign.Buttons["toolFull"];
                    btn.Pushed = true;
                }

                cmbTextFont.Text  = pFontDisp.Name;
                numTextSize.Value = (decimal)pTextSymbol.Size;
                anGle.Value       = (decimal)pTextSymbol.Angle;
                IFormattedTextSymbol pFTextSymbol = pTextSymbol as IFormattedTextSymbol;
                if (pFTextSymbol != null)
                {
                    if (pFTextSymbol.Background != null)
                    {
                        if (pFTextSymbol.Background is IBalloonCallout)
                        {
                            fillGroup.Visible = true;
                            IBalloonCallout pBallCallout = pFTextSymbol.Background as IBalloonCallout;
                            IFillSymbol     pFillSymbol  = pBallCallout.Symbol;
                            if (pFillSymbol != null)
                            {
                                pRgbColor = pFillSymbol.Color as IRgbColor;
                                l_ColorForPolygon.BackColor = ColorTranslator.FromOle(pRgbColor.RGB);

                                ILineSymbol pLineSymbol = pFillSymbol.Outline;
                                if (pLineSymbol != null)
                                {
                                    pRgbColor = pLineSymbol.Color as IRgbColor;
                                    l_ColorForLine.ForeColor = ColorTranslator.FromOle(pRgbColor.RGB);
                                    txt_LineWidth.Text       = pLineSymbol.Width.ToString();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                SetGroupVisible(5);
            }
            cmbTextFont.SelectedIndexChanged += new EventHandler(cmbTextFont_SelectedIndexChanged);
            numTextSize.ValueChanged         += new EventHandler(numTextSize_ValueChanged);
            txt_LineWidth.TextChanged        += new EventHandler(txt_LineWidth_TextChanged);
            anGle.ValueChanged += new EventHandler(anGle_ValueChanged);
        }
Beispiel #2
0
        private void AddCallOutElement(IPolyline pPolyline)
        {
            IGraphicsContainer pGraphicCtn = m_pActiveView.GraphicsContainer;

            try
            {
                frmEdit frmCallOut       = new frmEdit(true);
                PublicClass.POINTAPI pos = new PublicClass.POINTAPI();
                PublicClass.GetCursorPos(ref pos);
                frmCallOut.Location = new System.Drawing.Point(pos.x, pos.y); // * pScreen.BitsPerPixel
                int scrW = Screen.PrimaryScreen.WorkingArea.Width;            //主显示宽度
                int scrH = Screen.PrimaryScreen.WorkingArea.Height;           //主显示高度
                frmCallOut.Location = new System.Drawing.Point(pos.x, pos.y); // * pScreen.BitsPerPixel
                if (pos.x + frmCallOut.Width > scrW &&
                    pos.y + frmCallOut.Height > scrH)                         //超出显示器边界宽和高,则迂回
                {
                    frmCallOut.Location = new System.Drawing.Point(scrW - frmCallOut.Width,
                                                                   scrH - frmCallOut.Height);
                }
                if (pos.x + frmCallOut.Width > scrW &&
                    pos.y + frmCallOut.Height < scrH)  //超出显示器边界宽,则迂回
                {
                    frmCallOut.Location = new System.Drawing.Point(scrW - frmCallOut.Width, pos.y);
                }
                if (pos.x + frmCallOut.Width < scrW &&
                    pos.y + frmCallOut.Height > scrH)  //超出显示器边界高,则迂回
                {
                    frmCallOut.Location = new System.Drawing.Point(pos.x, scrH - frmCallOut.Height);
                }
                frmCallOut.ShowDialog();
                if (frmCallOut.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                ITextElement pTextElement = new TextElementClass();
                pTextElement.ScaleText = true;
                pTextElement.Text      = frmCallOut.AnnoText;

                IFormattedTextSymbol pTextSymbol = (IFormattedTextSymbol)frmCallOut.m_pTextSymbol;

                IBalloonCallout pCallout = new BalloonCalloutClass();
                pCallout.Symbol        = frmCallOut.m_pFillSymbol;
                pCallout.AnchorPoint   = pPolyline.FromPoint;
                pTextSymbol.Background = (ITextBackground)pCallout;

                pTextElement.Symbol = pTextSymbol as ITextSymbol;
                IElement pElement = (IElement)pTextElement;
                pElement.Geometry = pPolyline.ToPoint;

                //刷新显示
                frmCallOut.Dispose();
                IGraphicsContainerSelect pGraphicsSel = pGraphicCtn as IGraphicsContainerSelect;
                pGraphicsSel.UnselectAllElements();
                pGraphicsSel.SelectElement(pElement);
                pGraphicCtn.AddElement(pElement, 0);
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("添加文本注记失败:" + ex.Message, "提示");
                return;
            }
        }
Beispiel #3
0
        private void ChangeTextSymbol()
        {
            ITextSymbol pTextSymbol = grpSymbol.Tag as ITextSymbol;

            if (pTextSymbol == null)
            {
                return;
            }

            //得到注记颜色
            System.Drawing.Color pColor = btnTextColor.BackColor;
            pColor = colorAnno.Color;
            if (colorAnno.Color == Color.Transparent)
            {
                pTextSymbol.Color.Transparency = 0;
            }
            else
            {
                pTextSymbol.Color.Transparency = 255;
            }
            pTextSymbol.Color = PublicClass.GetRGBColor(pColor.R, pColor.G, pColor.B);

            //得到注记字体格式
            stdole.IFontDisp pFontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
            pFontDisp.Name      = cmbTextFont.Text;
            pFontDisp.Bold      = toolBarStyle.Buttons["toolBlod"].Pushed;
            pFontDisp.Italic    = toolBarStyle.Buttons["toolItalic"].Pushed;
            pFontDisp.Underline = toolBarStyle.Buttons["toolUnderline"].Pushed;
            pFontDisp.Size      = numTextSize.Value;

            pTextSymbol.Font = pFontDisp;

            //得到注记对齐格式
            if (toolBarAlign.Buttons["toolLeft"].Pushed)
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            }
            else if (toolBarAlign.Buttons["toolCenter"].Pushed)
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
            }
            else if (toolBarAlign.Buttons["toolRight"].Pushed)
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
            }
            else
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
            }

            pTextSymbol.Angle = (double)anGle.Value;
            //设置背景
            IFormattedTextSymbol pFTextSymbol = pTextSymbol as IFormattedTextSymbol;

            if (pFTextSymbol != null)
            {
                if (pFTextSymbol.Background != null)
                {
                    if (pFTextSymbol.Background is IBalloonCallout)
                    {
                        IBalloonCallout pBallCallout = pFTextSymbol.Background as IBalloonCallout;
                        IFillSymbol     pFillSymbol  = pBallCallout.Symbol;
                        if (pFillSymbol != null)
                        {
                            pFillSymbol.Color = PublicClass.GetRGBColor(l_ColorForPolygon.BackColor.R, l_ColorForPolygon.BackColor.G, l_ColorForPolygon.BackColor.B);

                            ILineSymbol pLineSymbol = pFillSymbol.Outline;
                            if (pLineSymbol != null)
                            {
                                pLineSymbol.Color = PublicClass.GetRGBColor(l_ColorForLine.ForeColor.R, l_ColorForLine.ForeColor.G, l_ColorForLine.ForeColor.B);
                                if (!string.IsNullOrEmpty(txt_LineWidth.Text))
                                {
                                    pLineSymbol.Width = double.Parse(txt_LineWidth.Text);
                                }
                                pFillSymbol.Outline = pLineSymbol;
                            }
                        }
                    }
                }
            }
            grpSymbol.Tag = pTextSymbol;
            IStyleGalleryItem item = new ServerStyleGalleryItemClass();

            item.Name = "tempSymbol";
            item.Item = pTextSymbol;

            PreviewImage(item);
            m_styleGalleryItem = item;
        }