📄 form1.cs
字号:
/*
Copyright 1995-2004 ESRI
All rights reserved under the copyright laws of the United States.
You may freely redistribute and use this sample code, with or without modification.
Disclaimer: THE SAMPLE CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESRI OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ARISING IN ANY
WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
For additional information contact: Environmental Systems Research Institute, Inc.
Attn: Contracts Dept.
380 New York Street
Redlands, California, U.S.A. 92373
Email: contracts@esri.com
*/
using System;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.CartoUI ;
using ESRI.ArcGIS.Utility;
using ESRI.ArcGIS.Geodatabase ;
using ESRI.ArcGIS.DataSourcesGDB ;
using ESRI.ArcGIS.DataSourcesFile;
namespace StatusBar
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private ESRI.ArcGIS.Controls.AxToolbarControl axToolbarControl1;
private System.Windows.Forms.StatusBar statusBar1;
private IAoInitialize m_AoInitialize = new AoInitializeClass();
private string sMapUnits;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Splitter splitter2;
private System.Windows.Forms.Panel panel2;
private ESRI.ArcGIS.Controls.AxTOCControl toc;
private ESRI.ArcGIS.Controls.AxMapControl map_eye;
private System.Windows.Forms.Splitter splitter1;
private ESRI.ArcGIS.Controls.AxMapControl m_map;
private AxLicenseControl axLicenseControl1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.axToolbarControl1 = new ESRI.ArcGIS.Controls.AxToolbarControl();
this.m_map = new ESRI.ArcGIS.Controls.AxMapControl();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.panel1 = new System.Windows.Forms.Panel();
this.toc = new ESRI.ArcGIS.Controls.AxTOCControl();
this.splitter2 = new System.Windows.Forms.Splitter();
this.panel2 = new System.Windows.Forms.Panel();
this.map_eye = new ESRI.ArcGIS.Controls.AxMapControl();
this.splitter1 = new System.Windows.Forms.Splitter();
this.axLicenseControl1 = new ESRI.ArcGIS.Controls.AxLicenseControl();
((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_map)).BeginInit();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.toc)).BeginInit();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.map_eye)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit();
this.SuspendLayout();
//
// axToolbarControl1
//
this.axToolbarControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axToolbarControl1.Location = new System.Drawing.Point(0, 0);
this.axToolbarControl1.Name = "axToolbarControl1";
this.axToolbarControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axToolbarControl1.OcxState")));
this.axToolbarControl1.Size = new System.Drawing.Size(712, 28);
this.axToolbarControl1.TabIndex = 0;
this.axToolbarControl1.OnMouseMove += new ESRI.ArcGIS.Controls.IToolbarControlEvents_Ax_OnMouseMoveEventHandler(this.axToolbarControl1_OnMouseMove);
//
// m_map
//
this.m_map.Location = new System.Drawing.Point(200, 26);
this.m_map.Name = "m_map";
this.m_map.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("m_map.OcxState")));
this.m_map.Size = new System.Drawing.Size(528, 456);
this.m_map.TabIndex = 1;
this.m_map.OnMouseMove += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseMoveEventHandler(this.m_map_OnMouseMove);
this.m_map.OnMapReplaced += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMapReplacedEventHandler(this.m_map_OnMapReplaced);
this.m_map.OnExtentUpdated += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnExtentUpdatedEventHandler(this.m_map_OnExtentUpdated);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 486);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(712, 23);
this.statusBar1.TabIndex = 2;
this.statusBar1.Text = "statusBar1";
//
// panel1
//
this.panel1.Controls.Add(this.toc);
this.panel1.Controls.Add(this.splitter2);
this.panel1.Controls.Add(this.panel2);
this.panel1.Location = new System.Drawing.Point(0, 26);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 454);
this.panel1.TabIndex = 3;
//
// toc
//
this.toc.Dock = System.Windows.Forms.DockStyle.Fill;
this.toc.Location = new System.Drawing.Point(0, 0);
this.toc.Name = "toc";
this.toc.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("toc.OcxState")));
this.toc.Size = new System.Drawing.Size(200, 267);
this.toc.TabIndex = 2;
//
// splitter2
//
this.splitter2.Cursor = System.Windows.Forms.Cursors.HSplit;
this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitter2.Location = new System.Drawing.Point(0, 267);
this.splitter2.Name = "splitter2";
this.splitter2.Size = new System.Drawing.Size(200, 3);
this.splitter2.TabIndex = 1;
this.splitter2.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.map_eye);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Location = new System.Drawing.Point(0, 270);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 184);
this.panel2.TabIndex = 0;
//
// map_eye
//
this.map_eye.Dock = System.Windows.Forms.DockStyle.Fill;
this.map_eye.Location = new System.Drawing.Point(0, 0);
this.map_eye.Name = "map_eye";
this.map_eye.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("map_eye.OcxState")));
this.map_eye.Size = new System.Drawing.Size(200, 184);
this.map_eye.TabIndex = 0;
this.map_eye.OnMouseDown += new ESRI.ArcGIS.Controls.IMapControlEvents2_Ax_OnMouseDownEventHandler(this.map_eye_OnMouseDown);
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(0, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 486);
this.splitter1.TabIndex = 4;
this.splitter1.TabStop = false;
//
// axLicenseControl1
//
this.axLicenseControl1.Enabled = true;
this.axLicenseControl1.Location = new System.Drawing.Point(529, 168);
this.axLicenseControl1.Name = "axLicenseControl1";
this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
this.axLicenseControl1.Size = new System.Drawing.Size(32, 32);
this.axLicenseControl1.TabIndex = 5;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(712, 509);
this.Controls.Add(this.axLicenseControl1);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.m_map);
this.Controls.Add(this.axToolbarControl1);
this.Name = "Form1";
this.Text = "Form1";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.axToolbarControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m_map)).EndInit();
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.toc)).EndInit();
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.map_eye)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//Create a new AoInitialize object
if (m_AoInitialize == null)
{
System.Windows.Forms.MessageBox.Show("Unable to initialize. This application cannot run!");
this.Close();
}
//Determine if the product is available
esriLicenseStatus licenseStatus = (esriLicenseStatus) m_AoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine);
if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
{
licenseStatus = (esriLicenseStatus) m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
{
System.Windows.Forms.MessageBox.Show("The initialization failed. This application cannot run!");
this.Close();
}
}
else
{
System.Windows.Forms.MessageBox.Show("The ArcGIS Engine product is unavailable. This application cannot run!");
this.Close();
}
sMapUnits = "Unknown";
//Set StatusBar properties
StatusBarPanel panel1 = new StatusBarPanel();
StatusBarPanel panel2 = new StatusBarPanel();
statusBar1.Panels.Add(panel1);
statusBar1.Panels.Add(panel2);
statusBar1.Panels[0].Style = StatusBarPanelStyle.Text;
statusBar1.Panels[1].Style = StatusBarPanelStyle.Text;
statusBar1.Panels[0].BorderStyle = StatusBarPanelBorderStyle.Sunken;
statusBar1.Panels[1].BorderStyle = StatusBarPanelBorderStyle.Sunken;
statusBar1.Panels[0].Width = (m_map.Width) / 5 * 3;
statusBar1.Panels[1].Width = (m_map.Width) / 5 * 2;
statusBar1.Panels[0].Text = "";
statusBar1.Panels[1].Text = "";
statusBar1.ShowPanels = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -