private void method_0() { IScaleBar pScaleBar = MapCartoTemplateLib.ScaleBarFormatPropertyPage.m_pScaleBar; this.txtDivisions.Text = pScaleBar.Divisions.ToString(); this.txtsubDivisions.Text = pScaleBar.Subdivisions.ToString(); this.chkDivisionsBeforeZero.Checked = pScaleBar.DivisionsBeforeZero == 1; this.cboResizeHint.SelectedIndex = (int)pScaleBar.ResizeHint; this.cboUnits.SelectedIndex = (int)pScaleBar.Units; this.cboLabelPosition.SelectedIndex = (int)pScaleBar.UnitLabelPosition; this.txtLabel.Text = pScaleBar.UnitLabel; this.txtGap.Text = pScaleBar.UnitLabelGap.ToString("#.##"); }
private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e) { button2.Enabled = true; m_pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; if (m_pStyleGalleryItem == null) { return; } //获取新的指北针 this.PreviewImage(); IScaleBar pScaleBar = m_pStyleGalleryItem.Item as IScaleBar; txtBoxUnit.Text = pScaleBar.Units.ToString(); }
private void cboUnits_SelectedIndexChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = MapCartoTemplateLib.ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.Units = (esriUnits)this.cboUnits.SelectedIndex; this.method_1(); } catch { } } }
private void txtDivisions_EditValueChanged(object sender, EventArgs e) { if (this.m_CanDo) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.Divisions = short.Parse(this.txtDivisions.Text); this.ValueChanged(); } catch { } } }
private void cboUnits_SelectedIndexChanged(object sender, EventArgs e) { if (this.m_CanDo) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.Units = (esriUnits)this.cboUnits.SelectedIndex; this.ValueChanged(); } catch { } } }
private void txtLabelGap_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = MapCartoTemplateLib.ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.LabelGap = double.Parse(this.txtLabelGap.Text); this.method_2(); } catch { } } }
private void txtLabelGap_EditValueChanged(object sender, EventArgs e) { if (this.m_CanDo) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.LabelGap = double.Parse(this.txtLabelGap.Text); this.ValueChanged(); } catch { } } }
private void txtLabel_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.UnitLabel = this.txtLabel.Text; this.method_1(); } catch { } } }
private void txtsubDivisions_EditValueChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.Subdivisions = short.Parse(this.txtsubDivisions.Text); this.method_1(); } catch { } } }
private void cboLabelPosition_SelectedIndexChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.UnitLabelPosition = (esriScaleBarPos)this.cboLabelPosition.SelectedIndex; this.method_1(); } catch { } } }
private void cboResizeHint_SelectedIndexChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { pScaleBar.ResizeHint = (esriScaleBarResizeHint)this.cboResizeHint.SelectedIndex; this.method_1(); } catch { } } }
private void cboStyle_SelectedIndexChanged(object sender, EventArgs e) { if (this.m_CanDo) { IStyleGalleryItem selectStyleGalleryItem = this.cboStyle.GetSelectStyleGalleryItem(); if (selectStyleGalleryItem == null) { m_pScaleBar = null; } else { m_pScaleBar = (selectStyleGalleryItem.Item as IClone).Clone() as IScaleBar; } this.m_CanDo = false; this.Init(); this.m_CanDo = true; this.ValueChanged(); } }
private void cboStyle_SelectedIndexChanged(object sender, EventArgs e) { if (this.bool_0) { IStyleGalleryItem selectStyleGalleryItem = this.cboStyle.GetSelectStyleGalleryItem(); if (selectStyleGalleryItem == null) { m_pScaleBar = null; } else { m_pScaleBar = (selectStyleGalleryItem.Item as IClone).Clone() as IScaleBar; } this.bool_0 = false; this.method_0(); this.bool_0 = true; this.method_4(); } }
public override IElement GetElement(IPageLayout ipageLayout_0) { if (base.m_pElement == null) { this.CreateElement(ipageLayout_0); } if (base.m_pElement == null) { return(null); } IPoint position = this.GetPosition(ipageLayout_0); IEnvelope bounds = new EnvelopeClass(); base.m_pElement.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, bounds); if ((base.m_pElement as IMapSurroundFrame).MapSurround is IScaleBar) { base.m_pElement = this.CreateElement(ipageLayout_0); IScaleBar mapSurround = (base.m_pElement as IMapSurroundFrame).MapSurround as IScaleBar; switch (base.ElementLocation.LocationType) { case LocationType.LeftUpper: case LocationType.LeftCenter: case LocationType.LeftLower: position.X -= bounds.Height; break; case LocationType.LowerLeft: case LocationType.LowerCenter: case LocationType.LowerRight: position.Y -= bounds.Height; break; } } if (!bounds.IsEmpty) { IEnvelope envelope2 = new EnvelopeClass(); envelope2.PutCoords(position.X, position.Y, position.X + bounds.Width, position.Y + bounds.Height); base.m_pElement.Geometry = envelope2; } return(base.m_pElement); }
// 比例尺 public void AddScalebar(AxPageLayoutControl axPageLayout) { //删除已经存在的比例尺 IElement pelement = axPageLayout.FindElementByName("AlternatingScaleBar"); if (pelement != null) { axPageLayout.ActiveView.GraphicsContainer.DeleteElement(pelement); } IGraphicsContainer container = axPageLayout.PageLayout as IGraphicsContainer; IActiveView activeView = axPageLayout.PageLayout as IActiveView; // 获得MapFrame IFrameElement frameElement = container.FindFrame(activeView.FocusMap); IMapFrame mapFrame = frameElement as IMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UID uid = new UIDClass(); uid.Value = "esriCarto.AlternatingScaleBar"; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null); //设置MapSurroundFrame中比例尺的样式 IMapSurround mapSurround = mapSurroundFrame.MapSurround; IScaleBar markerScaleBar = ((IScaleBar)mapSurround); markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); //QI,确定mapSurroundFrame的位置 IElement element = mapSurroundFrame as IElement; IEnvelope envelope = new EnvelopeClass(); double x = 12; double y = 5; envelope.PutCoords(x, y, x + 1, y + 1); element.Geometry = envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element, 0); activeView.Refresh(); }
private void chkDivisionsBeforeZero_CheckedChanged(object sender, EventArgs e) { if (this.bool_0) { IScaleBar pScaleBar = ScaleBarFormatPropertyPage.m_pScaleBar; try { if (this.chkDivisionsBeforeZero.Checked) { pScaleBar.DivisionsBeforeZero = 1; } else { pScaleBar.DivisionsBeforeZero = 0; } this.method_1(); } catch { } } }
/// <summary> /// Changs the scale bar unit. /// </summary> private void ChangScaleBarUnit() { if (this._styleGalleryItem != null) { IMapSurround mapSurround = this._styleGalleryItem.Item as IMapSurround; if (mapSurround != null) { IScaleBar scaleBar = mapSurround as IScaleBar; if (scaleBar != null) { if (this.cmbScaleBarUnit.SelectedIndex == 0) { scaleBar.Units = esriUnits.esriMeters; } else { scaleBar.Units = esriUnits.esriKilometers; } } } } }
public static void AddScalebar(AxPageLayoutControl pageLayoutControl, IEnvelope envelope) { IUID uid = new UIDClass() { Value = "esriCarto.AlternatingScaleBar" }; IFrameElement frameElement = (pageLayoutControl.PageLayout as IGraphicsContainer) .FindFrame(pageLayoutControl.ActiveView.FocusMap); IMapFrame mapFrame = frameElement as IMapFrame; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as UID, null); // Dynamic Cast IElement element = mapSurroundFrame as IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(pageLayoutControl.ActiveView.ScreenDisplay); (pageLayoutControl.PageLayout as IGraphicsContainer).AddElement(element, 0); IMapSurround mapSurround = mapSurroundFrame.MapSurround; IScaleBar markerScaleBar = (IScaleBar)(mapSurround); markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); }
public override void OnMouseUp(int Button, int Shift, int X, int Y) { if (m_InUse == false) { return; } if (GetCapture() == m_HookHelper.ActiveView.ScreenDisplay.hWnd) { ReleaseCapture(); } if (m_Feedback == null) { m_Feedback = null; m_InUse = false; return; } IEnvelope envelope = m_Feedback.Stop(); if ((envelope.IsEmpty) || (envelope.Width == 0) || (envelope.Height == 0)) { m_Feedback = null; m_InUse = false; return; } frmSymbolSelector symbolForm = new frmSymbolSelector(); IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassScaleBars, null); symbolForm.Dispose(); if (symbolForm.DialogResult != DialogResult.OK) { return; } if (styleGalleryItem == null) { return; } IMapFrame mapFrame = (IMapFrame)m_HookHelper.ActiveView.GraphicsContainer.FindFrame(m_HookHelper.ActiveView.FocusMap); UID vUid = new UIDClass(); vUid.Value = "{6589F143-F7F7-11d2-B872-00600802E603}"; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(vUid, (IMapSurround)styleGalleryItem.Item); if (mapSurroundFrame.MapSurround is IScaleBar) { IScaleBar pScalbeBar = (IScaleBar)mapSurroundFrame.MapSurround; pScalbeBar.Units = mapFrame.Map.MapUnits; switch (pScalbeBar.Units) { case esriUnits.esriMeters: pScalbeBar.UnitLabel = "米"; break; case esriUnits.esriKilometers: pScalbeBar.UnitLabel = "公里"; break; case esriUnits.esriMiles: pScalbeBar.UnitLabel = "英里"; break; case esriUnits.esriDecimalDegrees: pScalbeBar.UnitLabel = "度"; break; } } IElement element = (IElement)mapSurroundFrame; element.Geometry = envelope; IElementProperties3 pep = element as IElementProperties3; pep.Name = "比例尺"; IGraphicsContainerSelect pGraphicsSel = m_HookHelper.ActiveView.GraphicsContainer as IGraphicsContainerSelect; pGraphicsSel.UnselectAllElements(); pGraphicsSel.SelectElement(element); m_HookHelper.ActiveView.GraphicsContainer.AddElement(element, 0); m_HookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); m_Feedback = null; m_InUse = false; }
private void SetMapFrame()//设置地图基本信息,如比例尺,图例等: { IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)this.axPageLayoutControl1.ActiveView; pGraphicsContainer.Reset(); IElementProperties pElementProperties = (IElementProperties)pGraphicsContainer.Next(); while (pElementProperties != null) { if (pElementProperties is ITextElement) //设置文本 { ITextElement ptextElement = new TextElementClass(); ptextElement = (ITextElement)pElementProperties; if (ptextElement.Text.Trim() == "双击添加标题" || ptextElement.Symbol.Size > 25) { ptextElement.Text = m_textTitle; } if (ptextElement.Text.Trim().Contains("坐标系")) { ptextElement.Text = "坐标系:" + m_textProject + "\r" + "高程系:" + m_textElevation; } if (ptextElement.Text.Trim().Contains("制作者")) { ptextElement.Text = "制图人:" + m_textName + "\r" + "制作时间:" + m_textDate; } } if (pElementProperties.Type == "Map Surround Frame") { IMapSurroundFrame pMapSurrounFrame = pElementProperties as IMapSurroundFrame; IElement pElement = (IElement)pElementProperties; if (pMapSurrounFrame.MapSurround.Name.Trim() == "Legend") { ILegend pLegend = pMapSurrounFrame.MapSurround as ILegend; pLegend.Map = m_Map; // IMapSurround pMapSurround = pMapSurrounFrame.MapSurround; //pElement = pMapSurrounFrame.MapSurround as IElement; // pMapSurround.Map = m_Map; // m_Map.AddMapSurround(pMapSurround); } if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Stepped Scale Line" || pMapSurrounFrame.MapSurround.Name == "Scale Line" || pMapSurrounFrame.MapSurround.Name == "Hollow Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Single Division Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Double Alternating Scale Bar") { // m_Map.MapScale = 5000; IScaleBar pScaleBar = pMapSurrounFrame.MapSurround as IScaleBar; pScaleBar.Map = m_Map; pScaleBar.Units = m_Map.MapUnits; pScaleBar.UseMapSettings(); pElement = pMapSurrounFrame.MapSurround as IElement; } if (pMapSurrounFrame.MapSurround.Name == "Scale Text") { IScaleText pScaleText = pMapSurrounFrame.MapSurround as IScaleText; pScaleText.Map = m_Map; } if (pMapSurrounFrame.MapSurround.Name == "North Arrow") { INorthArrow pNorthArrow = pMapSurrounFrame.MapSurround as INorthArrow; pNorthArrow.Map = m_Map; } } if (pElementProperties.Type == "Data Frame") { IFrameElement pFrameElement = pElementProperties as IFrameElement; IMapFrame pMapframe = pFrameElement as IMapFrame; // pMapframe.ExtentType = esriExtentTypeEnum.esriExtentBounds; IMapGrids pmapGrids = pMapframe as IMapGrids; IMapGrid pMapGrid = null; for (int i = 0; i < pmapGrids.MapGridCount; i++) { pMapGrid = pmapGrids.get_MapGrid(i); //用户要求显示与否 pMapGrid.Visible = true; } } pElementProperties = (IElementProperties)pGraphicsContainer.Next(); } if (axPageLayoutControl1.Page.Orientation == 2) { IPaper paper; paper = new PaperClass(); //create a paper object IPrinter printer; printer = new EmfPrinterClass(); //create a printer object paper.Attach(pageSetupDialog1.PrinterSettings.GetHdevmode(pageSetupDialog1.PageSettings).ToInt32(), pageSetupDialog1.PrinterSettings.GetHdevnames().ToInt32()); paper.Orientation = 2; printer.Paper = paper; axPageLayoutControl1.Printer = printer; pageSetupDialog1.PageSettings.Landscape = true; pageSetupDialog1.AllowOrientation = true; } if (axPageLayoutControl1.Page.Orientation == 1 && axPageLayoutControl1.Printer.Paper.Orientation == 2) { IPaper paper; paper = new PaperClass(); //create a paper object IPrinter printer; printer = new EmfPrinterClass(); //create a printer object paper.Attach(pageSetupDialog1.PrinterSettings.GetHdevmode(pageSetupDialog1.PageSettings).ToInt32(), pageSetupDialog1.PrinterSettings.GetHdevnames().ToInt32()); paper.Orientation = 1; printer.Paper = paper; axPageLayoutControl1.Printer = printer; pageSetupDialog1.PageSettings.Landscape = false; pageSetupDialog1.AllowOrientation = true; } }
private void axPageLayoutControl1_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e) { if (m_element != null) { IElementProperties pElementProp = m_element as IElementProperties; if (pElementProp.Type == "Text") { ITextElement pTextElement = pElementProp as ITextElement; frmTextSymbol frmText = new frmTextSymbol(ref pTextElement); frmText.ShowDialog(); pElementProp = pTextElement as IElementProperties; m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null); m_pageLayoutControl.ActiveView.Refresh(); } else if (pElementProp.Type == "Map Surround Frame") { IMapSurroundFrame pMapSurrounFrame = pElementProp as IMapSurroundFrame; if (pMapSurrounFrame.MapSurround.Name == "Legend") { frmLegendWizard frmLegedWizard = new frmLegendWizard(m_Map, m_pageLayoutControl, pMapSurrounFrame); frmLegedWizard.ShowDialog(); //修改图例属性 } else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Hollow Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Double lternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Scale Line" || pMapSurrounFrame.MapSurround.Name == "Single Division Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Stepped Scale Line") { ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; frmLegendItemSymbol frmScaleBar = new frmLegendItemSymbol(); IStyleGalleryItem pstyGallertItem = frmScaleBar.GetItem(styleClass);//获取样式 IScaleBar pscaleBar = pMapSurrounFrame.MapSurround as IScaleBar; esriUnits punits = pscaleBar.Units; if (pstyGallertItem != null) { pscaleBar = (IScaleBar)pstyGallertItem.Item; } else { return; } pscaleBar.Map = m_pageLayoutControl.ActiveView.FocusMap; //重新设置比例尺依附的地图及单位 pscaleBar.Units = punits; pscaleBar.UseMapSettings(); pscaleBar.Refresh(); pMapSurrounFrame.MapSurround = pscaleBar as IMapSurround; //旧的比例尺样式转换为新的比例尺样式 m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); //刷新 } else if (pMapSurrounFrame.MapSurround.Name == "Scale Text") { frmLegendItemSymbol frmTextScal = new frmLegendItemSymbol(); IStyleGalleryItem pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts); IScaleText pScaleText = pMapSurrounFrame.MapSurround as IScaleText; esriUnits pUnits = pScaleText.MapUnits; if (pStyGalleryItem != null) { pScaleText = (IScaleText)pStyGalleryItem.Item; } else { return; } pScaleText.Map = m_pageLayoutControl.ActiveView.FocusMap; pScaleText.MapUnits = pScaleText.MapUnits; pMapSurrounFrame.MapSurround = pScaleText as IMapSurround; m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); } else if (pMapSurrounFrame.MapSurround.Name.Trim() == "North Arrow") { INorthArrow northArrow = pMapSurrounFrame.MapSurround as INorthArrow; frmNorthArrowSymbol frmNorthArrow = new frmNorthArrowSymbol(); IStyleGalleryItem pstyGallertItem = frmNorthArrow.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);; if (pstyGallertItem != null) { northArrow = (INorthArrow)pstyGallertItem.Item; northArrow.CalibrationAngle = frmNorthArrow.Angle(); } else { return; } pMapSurrounFrame.MapSurround = (IMapSurround)northArrow; m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); } } } }
public void AddScalebar(IPageLayout pageLayout, IMap map, double posX, double posY, double division, string strMapUnits, short srtDivisions) { try { if (pageLayout == null || map == null) { return; } IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(posX - (division * 2), posY, posX, posY + (division * 0.5)); // Specify the location and size of the scalebar ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "esriCarto.AlternatingScaleBar"; // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location // Activate it and add it to the PageLayout's graphics container IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; // Dynamic Cast IActiveView activeView = pageLayout as IActiveView; // Dynamic Cast IFrameElement frameElement = graphicsContainer.FindFrame(map); IMapFrame mapFrame = frameElement as IMapFrame; // Dynamic Cast IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast IElement element = mapSurroundFrame as IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(activeView.ScreenDisplay); graphicsContainer.AddElement(element, 0); IMapSurround mapSurround = mapSurroundFrame.MapSurround; IScaleBar markerScaleBar = ((IScaleBar)(mapSurround)); markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); markerScaleBar.Divisions = srtDivisions; markerScaleBar.DivisionsBeforeZero = 0; markerScaleBar.Subdivisions = 0; markerScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarMajorDivisions; if (strMapUnits == "Feet") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet; } //Default Settings else if (strMapUnits == "Miles") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriMiles; } else if (strMapUnits == "Meters") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriMeters; } else if (strMapUnits == "Kilometers") { markerScaleBar.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriKilometers; } else { return; } } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
//创建比例尺 private void CreateScale() { if (StyleGalleryItem == null) { return; } IGraphicsContainer pGraphicsContainer = m_hookHelper.ActiveView.GraphicsContainer; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(m_hookHelper.ActiveView.FocusMap) as IMapFrame; if (pMapFrame == null) { return; } if (StyleGalleryItem.Item is IScaleBar) { IScaleBar pScaleBar = (IScaleBar)StyleGalleryItem.Item; pScaleBar.Refresh(); IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass(); pMapSurroundFrame.MapFrame = pMapFrame; pMapSurroundFrame.MapSurround = (IMapSurround)pScaleBar; IElement pElement = (IElement)pMapSurroundFrame; //添加和指北针一样大小的窗口 double pScaleBarSize = 15; //显示结果大小 IActiveView pActiveView = m_hookHelper.ActiveView; IPageLayout pPageLayout = (IPageLayout)pActiveView; IPage pPage = pPageLayout.Page; double pWidth = pPage.PrintableBounds.XMin + 2; double pHeigth = pPage.PrintableBounds.YMin + 2; IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(pWidth, pHeigth, pWidth + 10, pHeigth + 1); pElement.Geometry = (IGeometry)pEnv; //Add the element to the graphics container pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0); //Refresh m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null); } else if (StyleGalleryItem.Item is IScaleText) { IScaleText pScaleText = (IScaleText)StyleGalleryItem.Item; pScaleText.Refresh(); IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass(); pMapSurroundFrame.MapFrame = pMapFrame; pMapSurroundFrame.MapSurround = (IMapSurround)pScaleText; IElement pElement = (IElement)pMapSurroundFrame; //显示结果大小 IActiveView pActiveView = m_hookHelper.ActiveView; IPageLayout pPageLayout = (IPageLayout)pActiveView; IPage pPage = pPageLayout.Page; double pWidth = pPage.PrintableBounds.XMin + 2; double pHeigth = pPage.PrintableBounds.YMin + 2; IEnvelope pEnv = new EnvelopeClass(); pEnv.PutCoords(pWidth, pHeigth, pWidth + 10, pHeigth + 1); pElement.Geometry = (IGeometry)pEnv; //Add the element to the graphics container pGraphicsContainer.AddElement((IElement)pMapSurroundFrame, 0); //Refresh m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pMapSurroundFrame, null); } }
private static void old_acctor_mc() { m_pScaleBar = null; }