📄 form1.cs
字号:
/*
Copyright 1995-2005 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.Carto;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.PageLayoutControl;
namespace CopyFocusMap
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public System.Windows.Forms.ComboBox cboMaps;
public System.Windows.Forms.TextBox txbPath;
public System.Windows.Forms.Button cmdLoad;
public System.Windows.Forms.Label Label4;
public System.Windows.Forms.Button cmdZoomPage;
public System.Windows.Forms.Button cmdFullExtent;
public System.Windows.Forms.Label Label2;
public System.Windows.Forms.Label Label1;
private ESRI.ArcGIS.MapControl.AxMapControl axMapControl1;
private ESRI.ArcGIS.PageLayoutControl.AxPageLayoutControl axPageLayoutControl1;
private bool m_bUpdateFocusMap;
private bool m_bReplacedPageLayout;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private ESRI.ArcGIS.LicenseControl.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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.cboMaps = new System.Windows.Forms.ComboBox();
this.txbPath = new System.Windows.Forms.TextBox();
this.cmdLoad = new System.Windows.Forms.Button();
this.Label4 = new System.Windows.Forms.Label();
this.cmdZoomPage = new System.Windows.Forms.Button();
this.cmdFullExtent = new System.Windows.Forms.Button();
this.Label2 = new System.Windows.Forms.Label();
this.Label1 = new System.Windows.Forms.Label();
this.axMapControl1 = new ESRI.ArcGIS.MapControl.AxMapControl();
this.axPageLayoutControl1 = new ESRI.ArcGIS.PageLayoutControl.AxPageLayoutControl();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.axLicenseControl1 = new ESRI.ArcGIS.LicenseControl.AxLicenseControl();
((System.ComponentModel.ISupportInitialize)(this.axMapControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axPageLayoutControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axLicenseControl1)).BeginInit();
this.SuspendLayout();
//
// cboMaps
//
this.cboMaps.BackColor = System.Drawing.SystemColors.Window;
this.cboMaps.Cursor = System.Windows.Forms.Cursors.Default;
this.cboMaps.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cboMaps.ForeColor = System.Drawing.SystemColors.WindowText;
this.cboMaps.Location = new System.Drawing.Point(72, 48);
this.cboMaps.Name = "cboMaps";
this.cboMaps.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cboMaps.Size = new System.Drawing.Size(161, 22);
this.cboMaps.TabIndex = 11;
this.cboMaps.SelectedIndexChanged += new System.EventHandler(this.cboMaps_SelectedIndexChanged);
//
// txbPath
//
this.txbPath.AcceptsReturn = true;
this.txbPath.AutoSize = false;
this.txbPath.BackColor = System.Drawing.SystemColors.Window;
this.txbPath.Cursor = System.Windows.Forms.Cursors.IBeam;
this.txbPath.Enabled = false;
this.txbPath.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.txbPath.ForeColor = System.Drawing.SystemColors.WindowText;
this.txbPath.Location = new System.Drawing.Point(136, 8);
this.txbPath.MaxLength = 0;
this.txbPath.Name = "txbPath";
this.txbPath.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txbPath.Size = new System.Drawing.Size(369, 19);
this.txbPath.TabIndex = 10;
this.txbPath.Text = "";
//
// cmdLoad
//
this.cmdLoad.BackColor = System.Drawing.SystemColors.Control;
this.cmdLoad.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdLoad.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cmdLoad.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdLoad.Location = new System.Drawing.Point(8, 8);
this.cmdLoad.Name = "cmdLoad";
this.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdLoad.Size = new System.Drawing.Size(121, 25);
this.cmdLoad.TabIndex = 9;
this.cmdLoad.Text = "Load Map Document";
this.cmdLoad.Click += new System.EventHandler(this.cmdLoad_Click);
//
// Label4
//
this.Label4.BackColor = System.Drawing.SystemColors.Control;
this.Label4.Cursor = System.Windows.Forms.Cursors.Default;
this.Label4.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Label4.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label4.Location = new System.Drawing.Point(8, 48);
this.Label4.Name = "Label4";
this.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label4.Size = new System.Drawing.Size(65, 17);
this.Label4.TabIndex = 12;
this.Label4.Text = "Focus Map:";
//
// cmdZoomPage
//
this.cmdZoomPage.BackColor = System.Drawing.SystemColors.Control;
this.cmdZoomPage.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdZoomPage.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cmdZoomPage.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdZoomPage.Location = new System.Drawing.Point(12, 352);
this.cmdZoomPage.Name = "cmdZoomPage";
this.cmdZoomPage.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdZoomPage.Size = new System.Drawing.Size(97, 25);
this.cmdZoomPage.TabIndex = 16;
this.cmdZoomPage.Text = "Zoom to Page";
this.cmdZoomPage.Click += new System.EventHandler(this.cmdZoomPage_Click);
//
// cmdFullExtent
//
this.cmdFullExtent.BackColor = System.Drawing.SystemColors.Control;
this.cmdFullExtent.Cursor = System.Windows.Forms.Cursors.Default;
this.cmdFullExtent.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.cmdFullExtent.ForeColor = System.Drawing.SystemColors.ControlText;
this.cmdFullExtent.Location = new System.Drawing.Point(356, 352);
this.cmdFullExtent.Name = "cmdFullExtent";
this.cmdFullExtent.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.cmdFullExtent.Size = new System.Drawing.Size(153, 25);
this.cmdFullExtent.TabIndex = 13;
this.cmdFullExtent.Text = "Zoom to Full Data Extent";
this.cmdFullExtent.Click += new System.EventHandler(this.cmdFullExtent_Click);
//
// Label2
//
this.Label2.BackColor = System.Drawing.SystemColors.Control;
this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
this.Label2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label2.Location = new System.Drawing.Point(124, 352);
this.Label2.Name = "Label2";
this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label2.Size = new System.Drawing.Size(257, 17);
this.Label2.TabIndex = 15;
this.Label2.Text = "Right mouse button to pan page or data.";
//
// Label1
//
this.Label1.BackColor = System.Drawing.SystemColors.Control;
this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
this.Label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.Label1.Location = new System.Drawing.Point(124, 368);
this.Label1.Name = "Label1";
this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.Label1.Size = new System.Drawing.Size(249, 17);
this.Label1.TabIndex = 14;
this.Label1.Text = "Left mouse button to zoom in on page or data.";
//
// axMapControl1
//
this.axMapControl1.Location = new System.Drawing.Point(240, 32);
this.axMapControl1.Name = "axMapControl1";
this.axMapControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMapControl1.OcxState")));
this.axMapControl1.Size = new System.Drawing.Size(272, 312);
this.axMapControl1.TabIndex = 17;
this.axMapControl1.OnMouseDown += new ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEventHandler(this.axMapControl1_OnMouseDown);
this.axMapControl1.OnAfterScreenDraw += new ESRI.ArcGIS.MapControl.IMapControlEvents2_OnAfterScreenDrawEventHandler(this.axMapControl1_OnAfterScreenDraw);
this.axMapControl1.OnBeforeScreenDraw += new ESRI.ArcGIS.MapControl.IMapControlEvents2_OnBeforeScreenDrawEventHandler(this.axMapControl1_OnBeforeScreenDraw);
//
// axPageLayoutControl1
//
this.axPageLayoutControl1.Location = new System.Drawing.Point(8, 80);
this.axPageLayoutControl1.Name = "axPageLayoutControl1";
this.axPageLayoutControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axPageLayoutControl1.OcxState")));
this.axPageLayoutControl1.Size = new System.Drawing.Size(224, 264);
this.axPageLayoutControl1.TabIndex = 18;
this.axPageLayoutControl1.OnMouseDown += new ESRI.ArcGIS.PageLayoutControl.IPageLayoutControlEvents_OnMouseDownEventHandler(this.axPageLayoutControl1_OnMouseDown);
this.axPageLayoutControl1.OnPageLayoutReplaced += new ESRI.ArcGIS.PageLayoutControl.IPageLayoutControlEvents_OnPageLayoutReplacedEventHandler(this.axPageLayoutControl1_OnPageLayoutReplaced);
this.axPageLayoutControl1.OnAfterScreenDraw += new ESRI.ArcGIS.PageLayoutControl.IPageLayoutControlEvents_OnAfterScreenDrawEventHandler(this.axPageLayoutControl1_OnAfterScreenDraw);
this.axPageLayoutControl1.OnFocusMapChanged += new System.EventHandler(this.axPageLayoutControl1_OnFocusMapChanged);
this.axPageLayoutControl1.OnBeforeScreenDraw += new ESRI.ArcGIS.PageLayoutControl.IPageLayoutControlEvents_OnBeforeScreenDrawEventHandler(this.axPageLayoutControl1_OnBeforeScreenDraw);
//
// axLicenseControl1
//
this.axLicenseControl1.Enabled = true;
this.axLicenseControl1.Location = new System.Drawing.Point(144, 104);
this.axLicenseControl1.Name = "axLicenseControl1";
this.axLicenseControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axLicenseControl1.OcxState")));
this.axLicenseControl1.Size = new System.Drawing.Size(200, 50);
this.axLicenseControl1.TabIndex = 19;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -