Example #1
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            IRubberBand ipRubber = new RubberEnvelopeClass();
            IEnvelope   env      = ipRubber.TrackNew(this.hk.PageLayoutControl.ActiveView.ScreenDisplay, null) as IEnvelope;

            _insertTextFrm      = new InsertTextForm();
            _insertTextFrm.Text = "插入标题";
            _insertTextFrm.lblTextContent.Text = "标题内容";
            _dlgResult = _insertTextFrm.ShowDialog();
            if (_dlgResult == DialogResult.OK)
            {
                ITextSymbol textSymbol = new TextSymbolClass();
                textSymbol.Font  = _insertTextFrm.TextFont;
                textSymbol.Size  = _insertTextFrm.TextSize;
                textSymbol.Angle = _insertTextFrm.TextAngle;
                textSymbol.Color = _insertTextFrm.TextColor;

                //Create a text element
                ITextElement textElement = new TextElementClass();
                textElement.Symbol    = textSymbol;
                textElement.Text      = _insertTextFrm.InsertText;
                textElement.ScaleText = true;

                //QI to IElment
                IElement element = (IElement)textElement;
                //Set the TextElement's geometry
                element.Geometry = env;

                //Add the element to the GraphicsContainer
                this.hk.PageLayoutControl.ActiveView.GraphicsContainer.AddElement(element, 0);
                //Refresh the PageLayout
                this.hk.PageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
            }
        }
Example #2
0
        public static void SetTextElementByTextForm(InsertTextForm insertTextFrm, ITextElement textElement)
        {
            try
            {
                textElement.Text = insertTextFrm.InsertText;

                ITextSymbol textSymbol = new TextSymbolClass();
                textSymbol.Font  = insertTextFrm.TextFont;
                textSymbol.Size  = insertTextFrm.TextSize;
                textSymbol.Angle = insertTextFrm.TextAngle;
                textSymbol.Color = insertTextFrm.TextColor;

                textElement.Symbol = textSymbol;
            }
            catch (System.Exception ex)
            {
                return;
            }
        }
Example #3
0
        public static InsertTextForm GetTextElementForm(ITextElement textElement)
        {
            try
            {
                if (textElement == null)
                {
                    return(null);
                }

                double           textAngle     = textElement.Symbol.Angle;
                IColor           textColor     = textElement.Symbol.Color;
                stdole.IFontDisp textFont      = textElement.Symbol.Font;
                double           textSize      = textElement.Symbol.Size;
                string           insertText    = textElement.Text;
                InsertTextForm   insertTextFrm = new InsertTextForm(textAngle, textColor, textFont, textSize, insertText);
                return(insertTextFrm);
            }
            catch (System.Exception ex)
            {
                return(null);
            }
        }
Example #4
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            #region 旧代码
            _insertTextFrm = new InsertTextForm();
            _dlgResult     = _insertTextFrm.ShowDialog();
            if (_dlgResult == DialogResult.OK)
            {
                //Create a point and set its coordinates
                IPoint point = new PointClass();
                point.X = x;
                point.Y = y;

                ITextSymbol textSymbol = new TextSymbolClass();
                textSymbol.Font  = _insertTextFrm.TextFont;
                textSymbol.Size  = _insertTextFrm.TextSize;
                textSymbol.Angle = _insertTextFrm.TextAngle;
                textSymbol.Color = _insertTextFrm.TextColor;

                //Create a text element
                ITextElement textElement = new TextElementClass();
                textElement.Symbol    = textSymbol;
                textElement.Text      = _insertTextFrm.InsertText;
                textElement.ScaleText = true;

                //QI to IElment
                IElement element = (IElement)textElement;
                //Set the TextElement's geometry
                element.Geometry = point;

                //Add the element to the GraphicsContainer
                this.hk.PageLayoutControl.ActiveView.GraphicsContainer.AddElement(element, 0);
                //Refresh the PageLayout
                this.hk.PageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
            }
            #endregion
        }
Example #5
0
        public override void OnClick()
        {
            if (m_currentElement == null)
            {
                return;
            }

            switch (m_subType)
            {
            case 1:
                try
                {
                    if (m_currentElement is IMapFrame)
                    {
                        break;
                    }
                    this.m_pageLayoutControl.GraphicsContainer.DeleteElement(m_currentElement);
                    this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    break;
                }
                catch (System.Exception ex)
                {
                    break;
                }

            case 2:
                if (m_currentElement is ITextElement)
                {
                    ITextElement   textElement = m_currentElement as ITextElement;
                    InsertTextForm textFrm     = ElementPropetyImp.GetTextElementForm(textElement);
                    if (textFrm.ShowDialog() == DialogResult.OK)
                    {
                        ElementPropetyImp.SetTextElementByTextForm(textFrm, textElement);
                        //Refresh the PageLayout
                        this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, textElement, null);
                    }
                }
                else if (m_currentElement is IMapSurroundFrame)
                {
                    IMapSurroundFrame mapSurroundFrame = m_currentElement as IMapSurroundFrame;
                    IMapSurround      pMapSurround     = mapSurroundFrame.MapSurround;
                    //原始 envelope
                    IEnvelope originEnvelope = (mapSurroundFrame as IElement).Geometry.Envelope;
                    double    xmin           = originEnvelope.XMin;
                    double    ymin           = originEnvelope.YMin;

                    IStyleGalleryItem styleGalleryItem = null;
                    if (pMapSurround is IMarkerNorthArrow)
                    {
                        InsertNorthArrowForm symbolForm1 = new InsertNorthArrowForm(pMapSurround);
                        styleGalleryItem = symbolForm1.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);
                        symbolForm1.Dispose();
                    }
                    else if (pMapSurround is IScaleBar)
                    {
                        InsertScaleBarForm symbolForm2 = new InsertScaleBarForm(pMapSurround);
                        styleGalleryItem = symbolForm2.GetItem(esriSymbologyStyleClass.esriStyleClassScaleBars);
                        symbolForm2.Dispose();
                    }
                    //InsertNorthArrowForm symbolForm = new InsertNorthArrowForm(pMapSurround);
                    //IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);
                    //Release the form

                    if (styleGalleryItem == null)
                    {
                        return;
                    }

                    mapSurroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item;

                    //QI to IElement and set its geometry
                    IElement element = (IElement)mapSurroundFrame;

                    //Refresh the PageLayout
                    this.m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
                }

                break;

            default:
                break;
            }
        }