wufayun
路人甲
路人甲
  • 注册日期2004-06-28
  • 发帖数21
  • QQ
  • 铜币234枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:5000回复:7

怎么实现在PageLayout控件中添加了图例、指北针或比例尺等要素 ,用arcengine实现。

楼主#
更多 发布于:2005-09-16 10:58
<P>各位大侠,怎么实现在PageLayout控件中添加了图例、指北针或比例尺等要素 ,用arcengine实现。给个思路。</P>
<P>小弟先谢谢呢!!</P>
喜欢0 评分0
Yoyozwf
路人甲
路人甲
  • 注册日期2006-02-15
  • 发帖数39
  • QQ
  • 铜币207枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-03-20 18:05
<PRE><CODE><FONT color=#0000ff>Public Sub</FONT></CODE> AddMapSurrounds()
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMxDoc <CODE><FONT color=#0000ff>As</FONT></CODE> IMxDocument
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pActiveView <CODE><FONT color=#0000ff>As</FONT></CODE> IActiveView
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pEnv <CODE><FONT color=#0000ff>As</FONT></CODE> IEnvelope
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pID <CODE><FONT color=#0000ff>As New</FONT></CODE> UID
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMapSurround <CODE><FONT color=#0000ff>As</FONT></CODE> IMapSurround
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMarkerNorthArrow <CODE><FONT color=#0000ff>As</FONT></CODE> IMarkerNorthArrow
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pCharacterMarkerSymbol <CODE><FONT color=#0000ff>As</FONT></CODE> ICharacterMarkerSymbol
  
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMxDoc = Application.Document
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pActiveView = pMxDoc.PageLayout
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pEnv = <CODE><FONT color=#0000ff>New</FONT></CODE> Envelope
  
  <CODE><FONT color=#008000>'Add a north arrow</FONT></CODE>
  pEnv.PutCoords 0.2, 0.2, 1, 1
  pID.Value = "esriCarto.MarkerNorthArrow"
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMapSurround = CreateSurround(pID, pEnv, "North Arrow", pMxDoc.FocusMap, pMxDoc.PageLayout)
  <CODE><FONT color=#008000>'Change out the default north arrow</FONT></CODE>
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMarkerNorthArrow = pMapSurround <CODE><FONT color=#008000>'QI</FONT></CODE>
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pCharacterMarkerSymbol = pMarkerNorthArrow.MarkerSymbol <CODE><FONT color=#008000>'clones the symbol</FONT></CODE>
  pCharacterMarkerSymbol.CharacterIndex = 200 <CODE><FONT color=#008000>'change the symbol</FONT></CODE>
  pMarkerNorthArrow.MarkerSymbol = pCharacterMarkerSymbol <CODE><FONT color=#008000>'set it back</FONT></CODE>
  
  <CODE><FONT color=#008000>'Add a legend</FONT></CODE>
  <CODE><FONT color=#008000>'In this case just use the default legend</FONT></CODE>
  pEnv.PutCoords 1, 1, 3.4, 2.4
  pID.Value = "esriCarto.Legend"
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMapSurround = CreateSurround(pID, pEnv, "Legend", pMxDoc.FocusMap, pMxDoc.PageLayout)
  
  <CODE><FONT color=#008000>'Refresh the graphics</FONT></CODE>
  pActiveView.PartialRefresh esriViewGraphics, <CODE><FONT color=#0000ff>Nothing</FONT></CODE>, <CODE><FONT color=#0000ff>Nothing
End Sub


Private Function</FONT></CODE> CreateSurround(pID <CODE><FONT color=#0000ff>As</FONT></CODE> UID, pEnv <CODE><FONT color=#0000ff>As</FONT></CODE> IEnvelope, strName <CODE><FONT color=#0000ff>As String</FONT></CODE>, _
                           pMap <CODE><FONT color=#0000ff>As</FONT></CODE> IMap, pPageLayout <CODE><FONT color=#0000ff>As</FONT></CODE> IPageLayout) <CODE><FONT color=#0000ff>As</FONT></CODE> IMapSurround
  
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pGraphicsContainer <CODE><FONT color=#0000ff>As</FONT></CODE> IGraphicsContainer
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pActiveView <CODE><FONT color=#0000ff>As</FONT></CODE> IActiveView
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMapSurroundFrame <CODE><FONT color=#0000ff>As</FONT></CODE> IMapSurroundFrame
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMapSurround <CODE><FONT color=#0000ff>As</FONT></CODE> IMapSurround
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pMapFrame <CODE><FONT color=#0000ff>As</FONT></CODE> IMapFrame
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> pElement <CODE><FONT color=#0000ff>As</FONT></CODE> IElement
  
  <CODE><FONT color=#008000>'MapSurrounds are held in a MapSurroundFrame</FONT></CODE>
  <CODE><FONT color=#008000>'MapSurroundFrames are related to MapFrames</FONT></CODE>
  <CODE><FONT color=#008000>'MapFrames hold Maps</FONT></CODE>
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pGraphicsContainer = pPageLayout
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMapFrame = pGraphicsContainer.FindFrame(pMap)
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pID, <CODE><FONT color=#0000ff>Nothing</FONT></CODE>)
  pMapSurroundFrame.MapSurround.Name = strName

  <CODE><FONT color=#008000>'Set the geometry of the MapSurroundFrame to give it a location</FONT></CODE>
  <CODE><FONT color=#008000>'Activate it and add it to the PageLayout's graphics container</FONT></CODE>
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pElement = pMapSurroundFrame
  <CODE><FONT color=#0000ff>Set</FONT></CODE> pActiveView = pPageLayout
  pElement.Geometry = pEnv
  pElement.Activate pActiveView.ScreenDisplay


  <CODE><FONT color=#008000>'Allow the legend frame size to be altered after the legend has been</FONT></CODE>
  <CODE><FONT color=#008000>'added to the GraphicsContainer </FONT></CODE>
  <CODE><FONT color=#0000ff>Dim</FONT></CODE> PTrack <CODE><FONT color=#0000ff>As</FONT></CODE> ITrackCancel
  <CODE><FONT color=#0000ff>Set</FONT></CODE> PTrack = <CODE><FONT color=#0000ff>New</FONT></CODE> CancelTracker
  pElement.Draw pActiveView.ScreenDisplay, PTrack

  pGraphicsContainer.AddElement pElement, 0
  <CODE><FONT color=#008000>'Re-apply the change to the Legend MapSurroundFrame Geometry </FONT></CODE>
  pElement.Geometry = pEnv
  
  <CODE><FONT color=#0000ff>Set</FONT></CODE> CreateSurround = pMapSurroundFrame.MapSurround
<CODE><FONT color=#0000ff>End Function</FONT></CODE>
</PRE>
举报 回复(0) 喜欢(0)     评分
nickbo
路人甲
路人甲
  • 注册日期2005-07-27
  • 发帖数6
  • QQ
  • 铜币150枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-06-15 21:52
<P>不错  谢谢</P>
举报 回复(0) 喜欢(0)     评分
HazyHu
路人甲
路人甲
  • 注册日期2005-08-15
  • 发帖数18
  • QQ
  • 铜币221枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-07-26 10:55
<P>有没有添加scalebar的代码阿?</P>
举报 回复(0) 喜欢(0)     评分
semon1981
路人甲
路人甲
  • 注册日期2006-06-04
  • 发帖数28
  • QQ
  • 铜币198枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-08-02 13:57
<P>//根据UID创建Scale Bar<BR>                UID uID = new UID();<BR>                uID.Value = "esriCarto.ScaleBar";<BR>                IMapSurroundFrame iMapSurFrame = iMapFrame.CreateSurroundFrame(uID, null);</P>
<P>                ISymbolBackground iSymBackg = new SymbolBackgroundClass();<BR>                IFillSymbol iFillSym = new SimpleFillSymbol();<BR>                ILineSymbol iLineSym = new SimpleLineSymbol();<BR>                IRgbColor iRgb = new RgbColorClass();<BR>                iRgb.Red = m_oldLineClr.R;<BR>                iRgb.Green = m_oldLineClr.G;<BR>                iRgb.Blue = m_oldLineClr.B;</P>
<P>                IColor iClr = iRgb;<BR>                iLineSym.Color = iClr;<BR>                iRgb.Red = m_oldFillClr.R;<BR>                iRgb.Green = m_oldFillClr.G;<BR>                iRgb.Blue = m_oldFillClr.B;<BR>                iFillSym.Color = iClr;<BR>                iFillSym.Outline = iLineSym;<BR>                iSymBackg.FillSymbol = iFillSym;<BR>                iMapSurFrame.Background = iSymBackg;</P>
<P>                IElement iElement = iMapSurFrame as IElement;<BR>                iElement.Geometry = iEnv;</P>
<P>                IMapSurround iMapSur = iMapSurFrame.MapSurround;<BR>                //创建一个single alternating scale bar<BR>                IScaleBar iScaleBar = new AlternatingScaleBar();<BR>                iMapSur = iScaleBar;</P>
<P>                //设置Scale Bar的属性,如分割单位、数字显示的位置、label和label显示位置等<BR>                iScaleBar.Division = decimal.ToDouble(DivisionSize.Value);<BR>                iScaleBar.DivisionsBeforeZero = 0;<BR>                iScaleBar.Divisions = decimal.ToInt16(DivisionsSize.Value);<BR>                iScaleBar.Subdivisions = decimal.ToInt16(SubDivisionsSize.Value);<BR>                iScaleBar.Units = (esriUnits)(UnitsCbx.SelectedIndex);<BR>                iScaleBar.UnitLabel = UnitsCbx.Text;<BR>                iScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterBar;<BR>                iScaleBar.LabelPosition = esriVertPosEnum.esriAbove;<BR>                iScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint;</P>
<P>                iMapSurFrame.MapSurround = iMapSur;<BR>                iElement = iMapSurFrame as IElement;<BR>                iView.GraphicsContainer.AddElement(iElement, 0);</P>
举报 回复(0) 喜欢(0)     评分
semon1981
路人甲
路人甲
  • 注册日期2006-06-04
  • 发帖数28
  • QQ
  • 铜币198枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2006-08-02 13:58
<P>//根据UID创建Scale Bar<BR>                UID uID = new UID();<BR>                uID.Value = "esriCarto.ScaleBar";<BR>                IMapSurroundFrame iMapSurFrame = iMapFrame.CreateSurroundFrame(uID, null);</P>
<P>                ISymbolBackground iSymBackg = new SymbolBackgroundClass();<BR>                IFillSymbol iFillSym = new SimpleFillSymbol();<BR>                ILineSymbol iLineSym = new SimpleLineSymbol();<BR>                IRgbColor iRgb = new RgbColorClass();<BR>                iRgb.Red = m_oldLineClr.R;<BR>                iRgb.Green = m_oldLineClr.G;<BR>                iRgb.Blue = m_oldLineClr.B;</P>
<P>                IColor iClr = iRgb;<BR>                iLineSym.Color = iClr;<BR>                iRgb.Red = m_oldFillClr.R;<BR>                iRgb.Green = m_oldFillClr.G;<BR>                iRgb.Blue = m_oldFillClr.B;<BR>                iFillSym.Color = iClr;<BR>                iFillSym.Outline = iLineSym;<BR>                iSymBackg.FillSymbol = iFillSym;<BR>                iMapSurFrame.Background = iSymBackg;</P>
<P>                IElement iElement = iMapSurFrame as IElement;<BR>                iElement.Geometry = iEnv;</P>
<P>                IMapSurround iMapSur = iMapSurFrame.MapSurround;<BR>                //创建一个single alternating scale bar<BR>                IScaleBar iScaleBar = new AlternatingScaleBar();<BR>                iMapSur = iScaleBar;</P>
<P>                //设置Scale Bar的属性,如分割单位、数字显示的位置、label和label显示位置等<BR>                iScaleBar.Division = decimal.ToDouble(DivisionSize.Value);<BR>                iScaleBar.DivisionsBeforeZero = 0;<BR>                iScaleBar.Divisions = decimal.ToInt16(DivisionsSize.Value);<BR>                iScaleBar.Subdivisions = decimal.ToInt16(SubDivisionsSize.Value);<BR>                iScaleBar.Units = (esriUnits)(UnitsCbx.SelectedIndex);<BR>                iScaleBar.UnitLabel = UnitsCbx.Text;<BR>                iScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterBar;<BR>                iScaleBar.LabelPosition = esriVertPosEnum.esriAbove;<BR>                iScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint;</P>
<P>                iMapSurFrame.MapSurround = iMapSur;<BR>                iElement = iMapSurFrame as IElement;<BR>                iView.GraphicsContainer.AddElement(iElement, 0);</P>
举报 回复(0) 喜欢(0)     评分
semon1981
路人甲
路人甲
  • 注册日期2006-06-04
  • 发帖数28
  • QQ
  • 铜币198枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2006-08-02 14:05
<P>//根据UID创建Scale Bar<BR>                UID uID = new UID();<BR>                uID.Value = "esriCarto.ScaleBar";<BR>                IMapSurroundFrame iMapSurFrame = iMapFrame.CreateSurroundFrame(uID, null);</P>
<P>                ISymbolBackground iSymBackg = new SymbolBackgroundClass();<BR>                IFillSymbol iFillSym = new SimpleFillSymbol();<BR>                ILineSymbol iLineSym = new SimpleLineSymbol();<BR>                IRgbColor iRgb = new RgbColorClass();<BR>                iRgb.Red = m_oldLineClr.R;<BR>                iRgb.Green = m_oldLineClr.G;<BR>                iRgb.Blue = m_oldLineClr.B;</P>
<P>                IColor iClr = iRgb;<BR>                iLineSym.Color = iClr;<BR>                iRgb.Red = m_oldFillClr.R;<BR>                iRgb.Green = m_oldFillClr.G;<BR>                iRgb.Blue = m_oldFillClr.B;<BR>                iFillSym.Color = iClr;<BR>                iFillSym.Outline = iLineSym;<BR>                iSymBackg.FillSymbol = iFillSym;<BR>                iMapSurFrame.Background = iSymBackg;</P>
<P>                IElement iElement = iMapSurFrame as IElement;<BR>                iElement.Geometry = iEnv;</P>
<P>                IMapSurround iMapSur = iMapSurFrame.MapSurround;<BR>                //创建一个single alternating scale bar<BR>                IScaleBar iScaleBar = new AlternatingScaleBar();<BR>                iMapSur = iScaleBar;</P>
<P>                //设置Scale Bar的属性,如分割单位、数字显示的位置、label和label显示位置等<BR>                iScaleBar.Division = decimal.ToDouble(DivisionSize.Value);<BR>                iScaleBar.DivisionsBeforeZero = 0;<BR>                iScaleBar.Divisions = decimal.ToInt16(DivisionsSize.Value);<BR>                iScaleBar.Subdivisions = decimal.ToInt16(SubDivisionsSize.Value);<BR>                iScaleBar.Units = (esriUnits)(UnitsCbx.SelectedIndex);<BR>                iScaleBar.UnitLabel = UnitsCbx.Text;<BR>                iScaleBar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterBar;<BR>                iScaleBar.LabelPosition = esriVertPosEnum.esriAbove;<BR>                iScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint;</P>
<P>                iMapSurFrame.MapSurround = iMapSur;<BR>                iElement = iMapSurFrame as IElement;<BR>                iView.GraphicsContainer.AddElement(iElement, 0);</P>
举报 回复(0) 喜欢(0)     评分
hikeryu
路人甲
路人甲
  • 注册日期2008-01-03
  • 发帖数18
  • QQ
  • 铜币159枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2009-08-15 09:17
<P>这些代码帮助里头都有</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部