📄 form1.cs
字号:
this.Separator_2,
this.toolBarButton9,
this.toolBarButton10,
this.toolBarButton11,
this.toolBarButton12,
this.Separator_3,
this.toolBarTest});
this.toolBar1.DropDownArrows = true;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(696, 28);
this.toolBar1.TabIndex = 2;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.Tag = "Pan";
this.toolBarButton1.ToolTipText = "漫游";
//
// toolBarButton2
//
this.toolBarButton2.Tag = "ZoomIn";
this.toolBarButton2.ToolTipText = "放大";
//
// toolBarButton3
//
this.toolBarButton3.Tag = "ZoomOut";
this.toolBarButton3.ToolTipText = "缩小";
//
// toolBarButton4
//
this.toolBarButton4.Tag = "ZoomUser";
this.toolBarButton4.ToolTipText = "用户缩放";
//
// Separator_1
//
this.Separator_1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
this.Separator_1.Tag = "Separator";
//
// toolBarButton5
//
this.toolBarButton5.Tag = "layerDlg";
this.toolBarButton5.ToolTipText = "显示图层";
//
// toolBarButton6
//
this.toolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
this.toolBarButton6.Tag = "UserDist";
this.toolBarButton6.ToolTipText = "测距";
//
// toolBarButton7
//
this.toolBarButton7.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
this.toolBarButton7.Tag = "UserInfo";
this.toolBarButton7.ToolTipText = "信息";
//
// toolBarButton8
//
this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
this.toolBarButton8.Tag = "UserLabel";
this.toolBarButton8.ToolTipText = "标签";
//
// Separator_2
//
this.Separator_2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarTest
//
this.toolBarTest.Tag = "Test";
this.toolBarTest.ToolTipText = "用于测试使用";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 461);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2,
this.statusBarPanel3});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(696, 24);
this.statusBar1.TabIndex = 6;
this.statusBar1.Text = "statusBar1";
//
// statusBarPanel1
//
this.statusBarPanel1.Width = 150;
//
// statusBarPanel2
//
this.statusBarPanel2.Width = 150;
//
// statusBarPanel3
//
this.statusBarPanel3.Width = 300;
//
// toolBarButton9
//
this.toolBarButton9.Tag = "Select";
this.toolBarButton9.ToolTipText = "Select";
//
// toolBarButton10
//
this.toolBarButton10.Tag = "Center";
this.toolBarButton10.ToolTipText = "Center";
//
// toolBarButton11
//
this.toolBarButton11.Tag = "NoSelect";
this.toolBarButton11.ToolTipText = "NoSelect";
//
// toolBarButton12
//
this.toolBarButton12.Tag = "Exit";
this.toolBarButton12.ToolTipText = "Exit";
//
// Separator_3
//
this.Separator_3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(696, 485);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Tools_Used(object sender,MapInfo.Tools.ToolUsedEventArgs e)
{
if (e.ToolName == "UserDist")
{
statusBarPanel1.Text = "点的数目为:" + distCount.ToString();
distxy[distCount,0] = (double)e.MapCoordinate.x;
distxy[distCount,1] = (double)e.MapCoordinate.y;
if (distCount==0)
statusBarPanel3.Text = "当前距离是: 0 Km";
if (distCount>0)
{
MapInfo.Geometry.DPoint pt1 = new MapInfo.Geometry.DPoint(distxy[distCount-1,0],distxy[distCount-1,1]);
MapInfo.Geometry.DPoint pt2 = new MapInfo.Geometry.DPoint(distxy[distCount,0],distxy[distCount,1]);
MapInfo.Geometry.CoordSys CoordSys = mapControl1.Map.GetDisplayCoordSys();
Dist = Dist + CoordSys.Distance(MapInfo.Geometry.DistanceType.Spherical, MapInfo.Geometry.DistanceUnit.Kilometer, pt1, pt2);
statusBarPanel2.Text = "Spherical距离";
statusBarPanel3.Text = "当前距离是: " + Dist.ToString() + " Km";
}
distCount++;
}
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch (e.Button.Tag.ToString())
{
case "Pan":
mapControl1.Tools.LeftButtonTool = "Pan";
break;
case "ZoomIn":
mapControl1.Tools.LeftButtonTool = "ZoomIn";
break;
case "ZoomOut":
mapControl1.Tools.LeftButtonTool = "ZoomOut";
break;
case "layerDlg":
MapInfo.Windows.Dialogs.LayerControlDlg lcd = new LayerControlDlg();
lcd.Map = mapControl1.Map;
lcd.ShowDialog();
break;
case "UserDist":
mapControl1.Tools.LeftButtonTool = "UserDist";
//使用项目中内嵌的光标资源。
mapControl1.Tools.MouseToolProperties.Cursor = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(this.GetType(), "DistanceCursor.cur"));
break;
case "UserInfo":
ISession session = MapInfo.Engine.Session.Current;
FeatureLayer lyr = new FeatureLayer(session.Catalog["SHENGHUI"]);
MapTool.SetInfoTipExpression(mapControl1.Tools.MapToolProperties,
lyr, "@TableAlias + char(13) + 'Centroid X:' + MI_CentroidX(obj) + 'Y:' + MI_CentroidY(obj)");
break;
case "Select":
mapControl1.Tools.LeftButtonTool = "Select";
break;
case "Center":
mapControl1.Tools.LeftButtonTool = "Center";
break;
case "NoSelect":
mapControl1.Tools.LeftButtonTool = "Arrow";
//使用Windows系统光标
mapControl1.Tools.MouseToolProperties.Cursor = System.Windows.Forms.Cursors.Arrow;
break;
case "Exit":
Application.Exit();
break;
case "Test":
break;
default:
break;
}
}
private void mapControl1_DoubleClick(object sender, System.EventArgs e)
{
distCount =0;
Dist = 0;
toolBarButton6.Pushed = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -