Ejemplo n.º 1
0
        public override void OnClick()
        {
            int num = -1;

            if (this._context.Hook is IPageLayoutControl)
            {
                num = (this._context.Hook as IPageLayoutControl).hWnd;
            }
            else if (this._context.Hook is IMapControl2)
            {
                num = (this._context.Hook as IMapControl2).hWnd;
            }
            else if (this._context.Hook is IApplication)
            {
                if ((this._context.Hook as IApplication).Hook is IPageLayoutControl)
                {
                    num = ((this._context.Hook as IApplication).Hook as IPageLayoutControl).hWnd;
                }
                else if ((this._context.Hook as IApplication).Hook is IMapControl2)
                {
                    num = ((this._context.Hook as IApplication).Hook as IMapControl2).hWnd;
                }
            }
            if (num != -1)
            {
                DataGraphicsElement  element   = new DataGraphicsElement();
                INewElementOperation operation = new NewElementOperation
                {
                    ActiveView = this._context.ActiveView,
                    Element    = element
                };
                this._context.OperationStack.Do(operation);
            }
        }
Ejemplo n.º 2
0
        public static IElement CreateElement(IPageLayout ipageLayout_0)
        {
            int         num;
            double      num1;
            double      num2;
            ITextSymbol symbol;
            esriTextHorizontalAlignment horizontalAlignment;
            esriTextVerticalAlignment   verticalAlignment;
            IScaleText  scaleTextClass;
            UID         uIDClass;
            IMapFrame   mapFrame;
            IEnvelope   envelopeClass;
            IEnvelope   envelope;
            ILegend     legendClass2;
            IScaleBar   hollowScaleBarClass;
            double      num3;
            double      num4;
            INorthArrow markerNorthArrowClass;
            IPoint      position         = ElementWizardHelp.GetPosition(ipageLayout_0, out num, out num1, out num2);
            IElement    textElementClass = null;

            switch (ElementWizardHelp.m_ElementType)
            {
            case ElementType.ConstantText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = ElementWizardHelp.m_Text;
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.SingleText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = string.Concat("=", ElementWizardHelp.m_Text);
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.MultiText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = string.Concat("M=", ElementWizardHelp.m_Text);
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.JoinTable:
            {
                textElementClass = (new JionTab()).CreateJionTab(ipageLayout_0 as IActiveView, position);
                return(textElementClass);
            }

            case ElementType.ScaleText:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    scaleTextClass = new ScaleTextClass();
                }
                else
                {
                    scaleTextClass = ElementWizardHelp.m_pStyle as IScaleText;
                }
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.ScaleText"
                };
                mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                scaleTextClass.MapUnits  = mapFrame.Map.DistanceUnits;
                scaleTextClass.PageUnits = ipageLayout_0.Page.Units;
                scaleTextClass.Style     = esriScaleTextStyleEnum.esriScaleTextAbsolute;
                INumberFormat numberFormat = scaleTextClass.NumberFormat;
                if (numberFormat is INumericFormat)
                {
                    (numberFormat as INumericFormat).RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfDecimals;
                    (numberFormat as INumericFormat).UseSeparator   = false;
                    (numberFormat as INumericFormat).RoundingValue  = 0;
                    scaleTextClass.NumberFormat = numberFormat;
                }
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, scaleTextClass) as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                scaleTextClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.CustomLegend:
            {
                CustomLegend customLegend = new CustomLegend()
                {
                    LegendInfo = ElementWizardHelp.m_pLegendInfo
                };
                customLegend.Init(ipageLayout_0 as IActiveView, position);
                textElementClass = customLegend;
                return(textElementClass);
            }

            case ElementType.Legend:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    legendClass2 = new LegendClass_2();
                }
                else
                {
                    legendClass2 = ElementWizardHelp.m_pStyle as ILegend;
                }
                legendClass2.AutoAdd        = true;
                legendClass2.AutoReorder    = true;
                legendClass2.AutoVisibility = true;
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.Legend"
                };
                mapFrame         = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, legendClass2) as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                legendClass2.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.Picture:
            {
                string lower = System.IO.Path.GetExtension(ElementWizardHelp.m_PictureFileName).ToLower();
                textElementClass = null;
                string str = lower;
                if (string.IsNullOrEmpty(str))
                {
                    textElementClass = new PngPictureElementClass();
                    (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                    (textElementClass as IPictureElement).MaintainAspectRatio = true;
                    num3 = 0;
                    num4 = 0;
                    (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                    num3 = num3 * 0.0353;
                    num4 = num4 * 0.0353;
                    (textElementClass as IElementProperties2).AutoTransform = true;
                    envelopeClass = new EnvelopeClass();
                    envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                    textElementClass.Geometry = envelopeClass;
                    return(textElementClass);
                }
                else if (str == ".bmp")
                {
                    textElementClass = new BmpPictureElementClass();
                }
                else if (str == ".jpg")
                {
                    textElementClass = new JpgPictureElementClass();
                }
                else if (str == ".gif")
                {
                    textElementClass = new GifPictureElementClass();
                }
                else if (str == ".tif")
                {
                    textElementClass = new TifPictureElementClass();
                }
                else
                {
                    if (str != ".emf")
                    {
                        textElementClass = new PngPictureElementClass();
                        (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                        (textElementClass as IPictureElement).MaintainAspectRatio = true;
                        num3 = 0;
                        num4 = 0;
                        (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                        num3 = num3 * 0.0353;
                        num4 = num4 * 0.0353;
                        (textElementClass as IElementProperties2).AutoTransform = true;
                        envelopeClass = new EnvelopeClass();
                        envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                        textElementClass.Geometry = envelopeClass;
                        return(textElementClass);
                    }
                    textElementClass = new EmfPictureElementClass();
                }
                (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                (textElementClass as IPictureElement).MaintainAspectRatio = true;
                num3 = 0;
                num4 = 0;
                (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                num3 = num3 * 0.0353;
                num4 = num4 * 0.0353;
                (textElementClass as IElementProperties2).AutoTransform = true;
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.OLE:
            {
                int screenDisplay = (ipageLayout_0 as IActiveView).ScreenDisplay.hWnd;
                Common.ExtendClass.IOleFrame oleFrame = new OleFrame();
                if (!oleFrame.CreateOleClientItem((ipageLayout_0 as IActiveView).ScreenDisplay, screenDisplay))
                {
                    return(textElementClass);
                }
                textElementClass = oleFrame as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                textElementClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.ScaleBar:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    hollowScaleBarClass = new HollowScaleBarClass();
                }
                else
                {
                    hollowScaleBarClass = ElementWizardHelp.m_pStyle as IScaleBar;
                }
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.ScaleBar"
                };
                mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                hollowScaleBarClass.Units = mapFrame.Map.DistanceUnits;
                textElementClass          = mapFrame.CreateSurroundFrame(uIDClass, hollowScaleBarClass) as IElement;
                envelopeClass             = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                hollowScaleBarClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.North:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    markerNorthArrowClass = new MarkerNorthArrowClass();
                }
                else
                {
                    markerNorthArrowClass = ElementWizardHelp.m_pStyle as INorthArrow;
                }
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 3, position.Y + 3);
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.MarkerNorthArrow"
                };
                mapFrame         = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, markerNorthArrowClass) as IElement;
                envelope         = new EnvelopeClass();
                markerNorthArrowClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.GraphicElement:
            {
                return(textElementClass);
            }

            case ElementType.DataGraphicElement:
            {
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 8, position.Y + 8);
                textElementClass = new DataGraphicsElement()
                {
                    Geometry = envelopeClass
                };
                return(textElementClass);
            }

            default:
            {
                return(textElementClass);
            }
            }
        }