AE+C#布置比例尺

            IMap pMap = this.axPageLayoutControl1.ActiveView.FocusMap;
            IGraphicsContainer pGraphicsContainer = axPageLayoutControl1.PageLayout as IGraphicsContainer;
            IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            UID pUID = new UIDClass();
            pUID.Value = "{6589F146-F7F7-11d2-B872-00600802E603}";
            IMapSurroundFrame pScaleLine = pMapFrame.CreateSurroundFrame(pUID, null);
            IEnvelope pMarkEnvelope = new EnvelopeClass();
            double xMin, yMin, xMax, yMax;

            IEnvelope pMapFrameEnvelope;
           
            pMapFrame.ExtentType = esriExtentTypeEnum.esriExtentScale;
            IElement pMapFrameElement = pMapFrame as IElement;
            pMapFrameEnvelope = pMapFrameElement.Geometry.Envelope;
            pMapFrameEnvelope.QueryCoords(out xMin, out yMin, out xMax, out yMax);
            pMarkEnvelope.PutCoords(xMax - 6, yMin + 1, xMax, yMin + 3);

            IStyleSelector pStyleselector;
            pStyleselector = new ScaleBarSelectorClass();
            bool ok;
            ok = pStyleselector.DoModal(0);
            if (!ok) return;

            IScaleBar pScarbar = pStyleselector.GetStyle(0) as IScaleBar;
            pScarbar.BarHeight = 1;
            pScarbar.Division = 0;
            pScarbar.Subdivisions = 0;
            pScarbar.UnitLabelGap = 0;
            pScarbar.UnitLabel = "千米";
            pScarbar.Units = esriUnits.esriMeters;
            pScarbar.LabelPosition = esriVertPosEnum.esriBelow;

            ITextSymbol pTextsymbol = new TextSymbolClass();
            pTextsymbol.Size = 1;
            stdole.StdFont pFont = new stdole.StdFontClass();
            pFont.Size = 1;
            pFont.Name = "Arial";
            pTextsymbol.Font = pFont as stdole.IFontDisp;


            pTextsymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            pScarbar.UnitLabelSymbol = pTextsymbol;
            pScarbar.LabelSymbol = pTextsymbol;

            INumericFormat pNumericFormat = new NumericFormatClass();
            pNumericFormat.AlignmentWidth = 0;
            pNumericFormat.RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfSignificantDigits;
            pNumericFormat.RoundingValue = 0;
            pNumericFormat.UseSeparator = true;
            pNumericFormat.ShowPlusSign = false;

            INumberFormat pNumberFormat = pNumericFormat as INumberFormat;
            pScarbar.NumberFormat = pNumberFormat;

            IMapSurround pMapSurround = pScarbar as IMapSurround;
            pScaleLine.MapSurround = pMapSurround;


            this.axPageLayoutControl1.AddElement(pScaleLine as IElement, pMarkEnvelope, Type.Missing, Type.Missing, 0);
            this.axPageLayoutControl1.Refresh();

posted on 2009-02-24 16:29  liuating  阅读(1425)  评论(0编辑  收藏  举报