📄 form_main.cs
字号:
this.menuItem_ClearLayers,
this.menuItem_Quit});
this.menuItem_Data.Text = "数据(&D)";
//
// menuItem_AddData
//
this.menuItem_AddData.Index = 0;
this.menuItem_AddData.Text = "加载Shpfiles";
this.menuItem_AddData.Click += new System.EventHandler(this.menuItem_AddData_Click);
//
// menuItem_SDEConect
//
this.menuItem_SDEConect.Index = 1;
this.menuItem_SDEConect.Text = "连接SDE";
this.menuItem_SDEConect.Click += new System.EventHandler(this.menuItem_SDEConect_Click);
//
// menuItem_Export
//
this.menuItem_Export.Index = 2;
this.menuItem_Export.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem_ExportSelectionSet,
this.menuItem_ExportView});
this.menuItem_Export.Text = "数据导出";
//
// menuItem_ExportSelectionSet
//
this.menuItem_ExportSelectionSet.Index = 0;
this.menuItem_ExportSelectionSet.Text = "要素选择集";
this.menuItem_ExportSelectionSet.Click += new System.EventHandler(this.menuItem_ExportSelectionSet_Click);
//
// menuItem_ExportView
//
this.menuItem_ExportView.Index = 1;
this.menuItem_ExportView.Text = "视图范围要素";
this.menuItem_ExportView.Click += new System.EventHandler(this.menuItem_ExportView_Click);
//
// menuItem_ClearLayers
//
this.menuItem_ClearLayers.Enabled = false;
this.menuItem_ClearLayers.Index = 3;
this.menuItem_ClearLayers.Text = "移除所有图层";
this.menuItem_ClearLayers.Click += new System.EventHandler(this.menuItem_ClearLayers_Click);
//
// menuItem_Quit
//
this.menuItem_Quit.Index = 4;
this.menuItem_Quit.Text = "退出(&Q)";
this.menuItem_Quit.Click += new System.EventHandler(this.menuItem_Quit_Click);
//
// menuItem_Query
//
this.menuItem_Query.Index = 1;
this.menuItem_Query.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1_Atrribute});
this.menuItem_Query.Text = "查询(&Q)";
//
// menuItem1_Atrribute
//
this.menuItem1_Atrribute.Index = 0;
this.menuItem1_Atrribute.Text = "属性查询(&A)";
this.menuItem1_Atrribute.Click += new System.EventHandler(this.menuItem1_Atrribute_Click);
//
// menuItem_Editor
//
this.menuItem_Editor.Index = 2;
this.menuItem_Editor.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem_StartEdit,
this.menuItem_SaveEdit,
this.menuItem_StopEdit});
this.menuItem_Editor.Text = "编辑器(&E)";
//
// menuItem_StartEdit
//
this.menuItem_StartEdit.Enabled = false;
this.menuItem_StartEdit.Index = 0;
this.menuItem_StartEdit.Text = "开始编辑(&E)";
this.menuItem_StartEdit.Click += new System.EventHandler(this.menuItem_StartEdit_Click);
//
// menuItem_SaveEdit
//
this.menuItem_SaveEdit.Enabled = false;
this.menuItem_SaveEdit.Index = 1;
this.menuItem_SaveEdit.Text = "保存编辑(&S)";
this.menuItem_SaveEdit.Click += new System.EventHandler(this.menuItem_SaveEdit_Click);
//
// menuItem_StopEdit
//
this.menuItem_StopEdit.Enabled = false;
this.menuItem_StopEdit.Index = 2;
this.menuItem_StopEdit.Text = "停止编辑(&O)";
this.menuItem_StopEdit.Click += new System.EventHandler(this.menuItem_StopEdit_Click);
//
// comboBox_MapScale
//
this.comboBox_MapScale.Enabled = false;
this.comboBox_MapScale.Items.AddRange(new object[] {
"1:1000",
"1:10000",
"1:24000",
"1:100000",
"1:250000",
"1:500000",
"1:750000",
"1:1000000",
"1:3000000",
"1:5000000"});
this.comboBox_MapScale.Location = new System.Drawing.Point(584, 8);
this.comboBox_MapScale.Name = "comboBox_MapScale";
this.comboBox_MapScale.Size = new System.Drawing.Size(136, 20);
this.comboBox_MapScale.TabIndex = 10;
this.comboBox_MapScale.Text = "地图比例尺";
this.comboBox_MapScale.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboBox_MapScale_KeyPress);
this.comboBox_MapScale.SelectedIndexChanged += new System.EventHandler(this.comboBox_MapScale_SelectedIndexChanged);
//
// statusBar_Info
//
this.statusBar_Info.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.statusBar_Info.Location = new System.Drawing.Point(0, 465);
this.statusBar_Info.Name = "statusBar_Info";
this.statusBar_Info.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel_Tip,
this.statusBarPanel_MousePoint});
this.statusBar_Info.ShowPanels = true;
this.statusBar_Info.Size = new System.Drawing.Size(728, 32);
this.statusBar_Info.TabIndex = 11;
this.statusBar_Info.Text = "statusBar1";
//
// statusBarPanel_Tip
//
this.statusBarPanel_Tip.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel_Tip.Text = " Welcome";
this.statusBarPanel_Tip.Width = 356;
//
// statusBarPanel_MousePoint
//
this.statusBarPanel_MousePoint.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel_MousePoint.Width = 356;
//
// comboBox_Target
//
this.comboBox_Target.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox_Target.Enabled = false;
this.comboBox_Target.Location = new System.Drawing.Point(472, 8);
this.comboBox_Target.Name = "comboBox_Target";
this.comboBox_Target.Size = new System.Drawing.Size(112, 20);
this.comboBox_Target.TabIndex = 12;
this.comboBox_Target.SelectedIndexChanged += new System.EventHandler(this.comboBox_Target_SelectedIndexChanged);
//
// comboBox_EditTask
//
this.comboBox_EditTask.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox_EditTask.Enabled = false;
this.comboBox_EditTask.Items.AddRange(new object[] {
"新建要素",
"修改要素"});
this.comboBox_EditTask.Location = new System.Drawing.Point(392, 8);
this.comboBox_EditTask.Name = "comboBox_EditTask";
this.comboBox_EditTask.Size = new System.Drawing.Size(80, 20);
this.comboBox_EditTask.TabIndex = 13;
this.comboBox_EditTask.SelectedIndexChanged += new System.EventHandler(this.comboBox_EditTask_SelectedIndexChanged);
//
// Form_Main
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(728, 497);
this.Controls.Add(this.comboBox_EditTask);
this.Controls.Add(this.comboBox_Target);
this.Controls.Add(this.statusBar_Info);
this.Controls.Add(this.comboBox_MapScale);
this.Controls.Add(this.toolBar_Standard);
this.Controls.Add(this.MainMap);
this.Menu = this.mainMenu1;
this.Name = "Form_Main";
this.Text = "GIS";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form_Main_Closing);
this.Load += new System.EventHandler(this.Form_Main_Load);
((System.ComponentModel.ISupportInitialize)(this.MainMap)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel_Tip)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel_MousePoint)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form_Main());
}
private void Form_Main_Load(object sender, System.EventArgs e) //窗体加载
{
}
private void Form_Main_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗体关闭
{
// 窗体关闭时,如果程序还处于编辑状态则结束编辑
if (InEdit())
StopEditing();
// //窗体关闭时,释放对象
// ESRI.ArcGIS.Utility.COMSupport.AOUninitialize.Shutdown();
}
//********************************** 浏览、查询和编辑工具栏 ********************************************
private void toolBar_Standard_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch (toolBar_Standard.Buttons.IndexOf(e.Button))
{
case 0 : //加载数据
if(AddData()==1) //数据加载成功
{
this.comboBox_MapScale.Text="1:" + Convert.ToString((int)MainMap.Map.MapScale);
comboBox_MapScale.Enabled=true; //地图比例尺设定可用
menuItem_StartEdit.Enabled=true; //开始编辑菜单可用
menuItem_ClearLayers.Enabled=true; //移除所有图层菜单可用
}
toolBarButton_AddData.Pushed=false;
break;
case 1 : //放大
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
toolBarButton_ZoomIn.Pushed=false;
return;
}
toolBarButton_ZoomOut.Pushed=false;
toolBarButton_Pan.Pushed=false;
toolBarButton_Select.Pushed=false;
toolBarButton_Sketch.Pushed=false;
ZoomIn m_ZoomIn=new ZoomIn();
m_ZoomIn.OnCreate(this.MainMap);
this.MainMap.CurrentTool=m_ZoomIn;
break;
case 2 : //缩小
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
toolBarButton_ZoomOut.Pushed=false;
return;
}
toolBarButton_ZoomIn.Pushed=false;
toolBarButton_Pan.Pushed=false;
toolBarButton_Select.Pushed=false;
toolBarButton_Sketch.Pushed=false;
ZoomOut m_ZoomOut=new ZoomOut();
m_ZoomOut.OnCreate(this.MainMap);
this.MainMap.CurrentTool=m_ZoomOut;
break;
case 3 : //平移
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
toolBarButton_Pan.Pushed=false;
return;
}
toolBarButton_ZoomIn.Pushed=false;
toolBarButton_ZoomOut.Pushed=false;
toolBarButton_Select.Pushed=false;
toolBarButton_Sketch.Pushed=false;
Pan m_Pan=new Pan();
m_Pan.OnCreate(this.MainMap);
this.MainMap.CurrentTool=m_Pan;
break;
case 4 : //全局
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
return;
};
MainMap.ActiveView.Extent=MainMap.FullExtent;
MainMap.ActiveView.Refresh();
break;
case 5 : //选择要素
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
toolBarButton_Select.Pushed=false;
return;
}
toolBarButton_ZoomIn.Pushed=false;
toolBarButton_ZoomOut.Pushed=false;
toolBarButton_Pan.Pushed=false;
toolBarButton_Sketch.Pushed=false;
SelectFeature m_SelectFeature=new SelectFeature();
m_SelectFeature.OnCreate(this.MainMap);
this.MainMap.CurrentTool=m_SelectFeature;
break;
case 7: //信息查询
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
return;
}
//未实现
break;
case 8: //属性查询
if(MainMap.LayerCount==0)
{
System.Windows.Forms.MessageBox.Show("请先加载数据!");
return;
}
Cstest1.WindowsForm.Form_Query FormQuery=new Cstest1.WindowsForm.Form_Query(this.MainMap);
FormQuery.FormBorderStyle=FormBorderStyle.Fixed3D;
FormQuery.MaximizeBox=false;
FormQuery.MinimizeBox=false;
FormQuery.Show();
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -