添加一个加载图片的自定义标签工具(已完成)
2015-06-11 12:06:16 访问(1833) 赞(0) 踩(0)
public Form1()
{
InitializeComponent();
//添加为自定义加载点工具
MapInfo.Tools.MapTool ptMapTool = new MapInfo.Tools.CustomPointMapTool(false, this.mapControl1.Tools.FeatureViewer, this.mapControl1.Handle.ToInt32(), this.mapControl1.Tools, this.mapControl1.Tools.MouseToolProperties, this.mapControl1.Tools.MapToolProperties);
//使用自定义光标
ptMapTool.UseDefaultCursor = false;
//ptMapTool.Cursor = new System.Windows.Forms.Cursor(@"C:\Program Files\Common Files\MapInfo\MapXtreme\6.1\WebResources\MapInfoWebRectangleSelection.cur");
this.mapControl1.Tools.Add("CustomAddBitmapPointTool", ptMapTool);
this.mapControl1.Tools.Used += new MapInfo.Tools.ToolUsedEventHandler(ToolUsed);
MapInfo.Data.TableInfo ti = MapInfo.Data.TableInfoFactory.CreateTemp("Temp");
MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
FeatureLayer fl = new FeatureLayer(table);
this.mapControl1.Map.Layers.Add(fl);
}
private void ToolUsed(object sender, MapInfo.Tools.ToolUsedEventArgs e)
{
if (e.ToolName == "CustomAddBitmapPointTool")
{
MapInfo.Styles.BitmapPointStyle bitmappointstyle = new MapInfo.Styles.BitmapPointStyle("GLOB1-32.bmp", MapInfo.Styles.BitmapStyles.None, new Color(), 30);
MapInfo.Geometry.Point point = new MapInfo.Geometry.Point(this.mapControl1.Map.GetDisplayCoordSys(), e.MapCoordinate.x, e.MapCoordinate.y);
MapInfo.Data.Feature ftr = new MapInfo.Data.Feature(point, bitmappointstyle);
MapInfo.Data.Table tab = MapInfo.Engine.Session.Current.Catalog.GetTable("Temp");
tab.InsertFeature(ftr);
}
}
标签:
添加一个加载图片的自定义标签工具(已完成) 


上一条:
下一条:
相关评论
发表评论