[ArcEngine地图制图系列]—添加地图标题
来源:互联网 发布:数据分析是怎么接兼职 编辑:程序博客网 时间:2024/04/30 17:55
添加地图标题的核心代码如下
private IHookHelper m_hookHelper = null;
private IPageLayoutControl2 axPageControl;
private TitleForm frmTitle; //设置标题样式的窗体
private string title = "";
private System.Drawing.Font font ;
private System.Drawing.Color color ;
/// <summary>
/// Occurs when this command is clicked/// </summary>
public override void OnClick()
{
// TODO: Add AddTitleCommand.OnClick implementation
IEnvelope pEnvelope = PageManager.GetEnvelopeInPage2(axPageControl, 0.5, 0.9, 2, 1);
if (pEnvelope.IsEmpty || pEnvelope == null || pEnvelope.Width == 0 || pEnvelope.Height == 0)
{
return;
}
else
{
if (frmTitle == null || frmTitle.IsDisposed == true)
{
frmTitle = new TitleForm();
frmTitle.GetTitleText += new TitleForm.GetTitleTextEventHandler(frmTitle_GetTitleText);
}
frmTitle.ShowDialog();
AddTitle(axPageControl.ActiveView, pEnvelope, this.title,this.font,this.color);
pEnvelope = null;
}
}
#endregion
//设置标题样式的委托函数
private void frmTitle_GetTitleText(ref string newName, ref System.Drawing.Font newFont, ref System.Drawing.Color newColor)
{
this.title = newName;
this.font = newFont;
this.color = newColor;
}
private void AddTitle(IActiveView pActiveView, IEnvelope pEnv,string myTitle, System.Drawing.Font myFont,System.Drawing.Color myColor)
{
try
{
IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axPageControl.PageLayout;
//设置文本格式
ITextSymbol pTextSymbol = new TextSymbolClass();
//StdFont myFont = new stdole.StdFontClass();
//myFont.Name = "宋体";
pTextSymbol.Font = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(myFont) as IFontDisp; ;
//pTextSymbol.Size = pSize;
pTextSymbol.Color = ColorUtilty.GetRgbColor(myColor.R, myColor.G, myColor.B); ;
pTextSymbol.Angle = 0;
pTextSymbol.RightToLeft = false;//文本由左向右排列
pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;//垂直方向基线对齐
pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;//文本两端对齐
pTextSymbol.Text = myTitle;
ITextElement pTextElement = new TextElementClass();
pTextElement.Symbol = pTextSymbol;
pTextElement.Text = pTextSymbol.Text;
IElement pElement = axPageControl.FindElementByName("Title");//获取PageLayout中的元素
if (pElement != null)
{
pGraphicsContainer.DeleteElement(pElement); //删除已经存在标题
}
IElementProperties pElePro = null;
pElement = (IElement)pTextElement;
pElement.Geometry = (IGeometry)pEnv.UpperLeft;
pElePro = pElement as IElementProperties;
pElePro.Name = "Title";
pGraphicsContainer.AddElement(pElement, 0);
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
0 0
- [ArcEngine地图制图系列]—添加地图标题
- [ArcEngine地图制图系列]—添加比例尺
- [ArcEngine地图制图系列]—添加图例
- [ArcEngine地图制图系列]—添加网格
- [ArcEngine地图制图系列]—添加地图指北针
- [ArcEngine地图制图系列]—添加比例文本
- 【地图整饰】ArcMap添加地图标题及ArcEngine实现
- 地图制图
- ArcGIS制图技巧系列(3)—让地图更有立体感
- 地图打印资源 ArcEngine
- 【地图整饰】ArcMap添加图框及ArcEngine实现
- 074_《计算机地图制图》
- ArcEngine添加标题
- 开放式地图制图课程——OGC学习秘籍
- 开放式地图制图课程——OGC学习秘籍
- ArcEngine地图漫游的实现
- ArcEngine实现动态加载地图
- arcengine 两地图进行联动
- css3属性
- CDA数据分析师协会等级认证证书
- 在Mockplus中使用收藏功能,提高工作效率
- JAVA定时器 配置org.springframework.scheduling.quartz.CronTriggerBean
- [软件人生]各大学的软件工程硕士
- [ArcEngine地图制图系列]—添加地图标题
- Palindrome Number
- android 分辨率及密度详细
- aaa
- 自动化测试与持续集成方案--Android crash 收集
- 为什么不能用 memcached 存储 Session
- getFields()和getDeclaredFields()
- (eclipse,myeclipse)Invalid derived query! No property delete found for type
- iOS中将汉字转换成拼音