public override IElement CreateElement(IPageLayout ipageLayout_0)
        {
            if (this.PitcuteFile == null)
            {
                return(null);
            }
            string   str      = System.IO.Path.GetExtension(this.PitcuteFile).ToLower();
            IElement element2 = null;
            string   str2     = str;

            switch (str2)
            {
            case null:
                break;

            case ".bmp":
                element2 = new BmpPictureElementClass();
                goto Label_009C;

            case ".jpg":
                element2 = new JpgPictureElementClass();
                goto Label_009C;

            case ".gif":
                element2 = new GifPictureElementClass();
                goto Label_009C;

            default:
                if (str2 != ".tif")
                {
                    if (str2 != ".emf")
                    {
                        break;
                    }
                    element2 = new EmfPictureElementClass();
                }
                else
                {
                    element2 = new TifPictureElementClass();
                }
                goto Label_009C;
            }
            element2 = new PngPictureElementClass();
Label_009C:
            (element2 as IPictureElement).ImportPictureFromFile(this.PitcuteFile);
            (element2 as IPictureElement).MaintainAspectRatio = true;
            double widthPoints  = 0.0;
            double heightPoints = 0.0;

            (element2 as IPictureElement2).QueryIntrinsicSize(ref widthPoints, ref heightPoints);
            widthPoints  *= 0.0353;
            heightPoints *= 0.0353;
            (element2 as IElementProperties2).AutoTransform = true;
            IPoint    position = this.GetPosition(ipageLayout_0);
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(position.X, position.Y, position.X + widthPoints, position.Y + heightPoints);
            element2.Geometry = envelope;
            this.Element      = element2;
            return(element2);
        }
Beispiel #2
0
        private void InsertPicture()
        {
            try
            {
                OpenFileDialog filedlg = new OpenFileDialog();
                filedlg.Filter = "图像文件 (*.jpg;*.bmp;*.gif;*.tif;*.emf)|*.jpg;*.bmp;*.gif;*.tif;*.emf";
                filedlg.Title  = "选择图像文件";

                if (filedlg.ShowDialog() == DialogResult.OK)
                {
                    string sPath = filedlg.FileName;
                    int    pos   = sPath.LastIndexOf('.');
                    string sExt  = sPath.Substring(pos + 1);

                    IPictureElement3 pPicElement = null;
                    switch (sExt.ToLower())
                    {
                    case "jpg":
                        pPicElement = new JpgPictureElementClass();
                        break;

                    case "bmp":
                        pPicElement = new BmpPictureElementClass();
                        break;

                    case "gif":
                        pPicElement = new GifPictureElementClass();
                        break;

                    case "tif":
                        pPicElement = new TifPictureElementClass();
                        break;

                    case "emf":
                        pPicElement = new EmfPictureElementClass();
                        break;

                    default:
                        break;
                    }
                    if (pPicElement == null)
                    {
                        return;
                    }
                    pPicElement.ImportPictureFromFile(sPath);
                    pPicElement.SavePictureInDocument = true;
                    pPicElement.MaintainAspectRatio   = true;

                    IElementProperties pElementProp = (IElementProperties)pPicElement;
                    pElementProp.Name = sPath;

                    double picWidth = 0, picHeight = 0;
                    pPicElement.QueryIntrinsicSize(ref picWidth, ref picHeight);  //得到图片的象素点

                    //象素点转换成厘米
                    picWidth  = picWidth / 37.79;
                    picHeight = picHeight / 37.79;

                    //将厘米转换为当前Page单位
                    ConvertUnit(m_pHookHelper.PageLayout.Page.Units, ref picWidth, ref picHeight);

                    IPolygon         pPoly     = new PolygonClass();
                    IPointCollection pPntCln   = (IPointCollection)pPoly;
                    object           obj       = System.Type.Missing;
                    IPoint           pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(picWidth, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(picWidth, picHeight);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, picHeight);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    pTmpPoint = new PointClass();
                    pTmpPoint.PutCoords(0, 0);
                    pPntCln.AddPoint(pTmpPoint, ref obj, ref obj);

                    double pageWidth, pageHeight;
                    m_pHookHelper.PageLayout.Page.QuerySize(out pageWidth, out pageHeight);

                    ITransform2D pTrans = (ITransform2D)pPoly;
                    pTrans.Move(pageWidth / 2 - picWidth / 2, pageHeight / 2 - picHeight / 2);

                    IElement pElement = null;
                    pElement          = (IElement)pPicElement;
                    pElement.Geometry = pPoly;

                    IGraphicsContainer       pContainer   = (IGraphicsContainer)m_pHookHelper.PageLayout;
                    IGraphicsContainerSelect pGraphicsSel = pContainer as IGraphicsContainerSelect;
                    pGraphicsSel.UnselectAllElements();
                    pGraphicsSel.SelectElement(pElement);
                    pContainer.AddElement(pElement, 0);
                    m_pHookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("插入图片失败:" + ex.Message, "提示");
            }
        }
Beispiel #3
0
        private void AddPictureElement(string strFileName)
        {
            IPictureElement2 pictureElement = null;
            string           suffix         = strFileName.Substring(strFileName.Length - 3, 3).ToLower();

            switch (suffix)
            {
            case "jpg":
                pictureElement = new JpgPictureElementClass();
                break;

            case "gif":
                pictureElement = new GifPictureElementClass();
                break;

            case "tif":
                pictureElement = new TifPictureElementClass();
                break;

            case "emf":
                pictureElement = new EmfPictureElementClass();
                break;

            case "bmp":
                pictureElement = new BmpPictureElementClass();
                break;

            case "png":
                pictureElement = new PngPictureElementClass();
                break;

            default:
                return;
            }
            try
            {
                pictureElement.ImportPictureFromFile(strFileName);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            IElement    iElement      = (IElement)pictureElement;
            IActiveView iActiveView   = this.m_pMapControl.ActiveView;
            double      pictureWidth  = 0;
            double      pictureHeight = 0;

            pictureElement.QueryIntrinsicSize(ref pictureWidth, ref pictureHeight);


            IEnvelope env  = this.m_pMapControl.ActiveView.Extent;
            tagRECT   rect = new tagRECT();

            m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(env, ref rect,
                                                                                       (int)esriDisplayTransformationEnum.esriTransformToDevice);

            Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left,
                                                rect.bottom - rect.top);

            int x = (rectangle.Left + rectangle.Right) / 2;
            int y = (rectangle.Top + rectangle.Height) / 2;
            /* IPoint point = iActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);*/
            IEnvelope envelope = new EnvelopeClass();

            envelope.PutCoords(point.X, point.Y,
                               point.X + (int)(pictureWidth / 72 * iActiveView.ScreenDisplay.DisplayTransformation.ScaleRatio),
                               point.Y + (int)(pictureHeight / 72 * iActiveView.ScreenDisplay.DisplayTransformation.ScaleRatio));

            iElement.Geometry = envelope;
            IBoundsProperties bp = iElement as IBoundsProperties;

            bp.FixedAspectRatio = true;
            pictureElement.MaintainAspectRatio = true;
            pGraphicsContainer = this.m_pMapControl.ActiveView as IGraphicsContainer;
            pGraphicsContainer.AddElement(iElement, 0);
            this.m_pMapControl.ActiveView.Refresh();
        }
Beispiel #4
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);
            }
            }
        }