⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 提供了大量初学CSharp的示例
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ThematicMap
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button fullExt;
		private System.Windows.Forms.Button singleSmb;
		private System.Windows.Forms.Button valueMap;
		private System.Windows.Forms.Button stdDev;
		private System.Windows.Forms.Button dotDens;
		private ESRI.MapObjects2.Core.AxMap axMap1;
		private System.ComponentModel.IContainer components;


#region Globals
		private ESRI.MapObjects2.Core.MapLayer m_pCountiesLyr;
		private ESRI.MapObjects2.Core.MapLayer m_pCitiesLyr;
		private String m_dataPath = "D:/Program Files/ESRI/MapObjects2/Samples/Data/";
		private System.Windows.Forms.Timer timer1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBarButton toolBarButton1;
		private System.Windows.Forms.ToolBarButton toolBarButton2;
		private System.Windows.Forms.ToolBarButton toolBarButton3;
		private System.Windows.Forms.ToolBarButton toolBarButton4;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private String m_sNewline =  System.Environment.NewLine;
		private System.Windows.Forms.SaveFileDialog dlgSave;
		private System.Windows.Forms.CheckBox checkBox2;
		private ESRI.MapObjects2.Core.MapLayer layer;
		private ESRI.MapObjects2.Core.Line line;
		private ESRI.MapObjects2.Core.GeoDataset  gds;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private String path;
#endregion
		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			layer = new ESRI.MapObjects2.Core.MapLayerClass();
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.fullExt = new System.Windows.Forms.Button();
			this.singleSmb = new System.Windows.Forms.Button();
			this.valueMap = new System.Windows.Forms.Button();
			this.stdDev = new System.Windows.Forms.Button();
			this.dotDens = new System.Windows.Forms.Button();
			this.axMap1 = new ESRI.MapObjects2.Core.AxMap();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.dlgSave = new System.Windows.Forms.SaveFileDialog();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)(this.axMap1)).BeginInit();
			this.SuspendLayout();
			// 
			// fullExt
			// 
			this.fullExt.Location = new System.Drawing.Point(536, 32);
			this.fullExt.Name = "fullExt";
			this.fullExt.TabIndex = 1;
			this.fullExt.Text = "填充区域";
			this.fullExt.Click += new System.EventHandler(this.fullExt_Click);
			// 
			// singleSmb
			// 
			this.singleSmb.Location = new System.Drawing.Point(536, 72);
			this.singleSmb.Name = "singleSmb";
			this.singleSmb.TabIndex = 2;
			this.singleSmb.Text = "单一Symbol";
			this.singleSmb.Click += new System.EventHandler(this.singleSmb_Click);
			// 
			// valueMap
			// 
			this.valueMap.Location = new System.Drawing.Point(536, 112);
			this.valueMap.Name = "valueMap";
			this.valueMap.TabIndex = 3;
			this.valueMap.Text = "按值着色";
			this.valueMap.Click += new System.EventHandler(this.valueMap_Click);
			// 
			// stdDev
			// 
			this.stdDev.Location = new System.Drawing.Point(536, 151);
			this.stdDev.Name = "stdDev";
			this.stdDev.TabIndex = 4;
			this.stdDev.Text = "标准偏差";
			this.stdDev.Click += new System.EventHandler(this.stdDev_Click);
			// 
			// dotDens
			// 
			this.dotDens.Location = new System.Drawing.Point(536, 192);
			this.dotDens.Name = "dotDens";
			this.dotDens.TabIndex = 6;
			this.dotDens.Text = "点密度";
			this.dotDens.Click += new System.EventHandler(this.dotDens_Click);
			// 
			// axMap1
			// 
			this.axMap1.Location = new System.Drawing.Point(0, 32);
			this.axMap1.Name = "axMap1";
			this.axMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMap1.OcxState")));
			this.axMap1.Size = new System.Drawing.Size(512, 328);
			this.axMap1.TabIndex = 8;
			this.axMap1.MouseDownEvent += new ESRI.MapObjects2.Core.MouseDownEventHandler(this.axMap1_MouseDownEvent);
			this.axMap1.MouseMoveEvent += new ESRI.MapObjects2.Core.MouseMoveEventHandler(this.axMap1_MouseMoveEvent);
			// 
			// timer1
			// 
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// toolBar1
			// 
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton1,
																						this.toolBarButton2,
																						this.toolBarButton3,
																						this.toolBarButton4});
			this.toolBar1.ButtonSize = new System.Drawing.Size(39, 22);
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(632, 25);
			this.toolBar1.TabIndex = 9;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.ToolTipText = "Zoom In";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 1;
			this.toolBarButton2.ToolTipText = "Pan";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 2;
			this.toolBarButton3.ToolTipText = "Add Event";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 3;
			this.toolBarButton4.ToolTipText = "Select Events";
			// 
			// imageList1
			// 
			this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Teal;
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(537, 312);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(56, 24);
			this.checkBox1.TabIndex = 12;
			this.checkBox1.Text = "移动";
			this.checkBox1.Click += new System.EventHandler(this.checkBox1_Click);
			this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_Click);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(536, 232);
			this.button1.Name = "button1";
			this.button1.TabIndex = 13;
			this.button1.Text = "临时线条";
			this.button1.Click += new System.EventHandler(this.line_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(537, 274);
			this.button2.Name = "button2";
			this.button2.TabIndex = 14;
			this.button2.Text = "永久线条";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// dlgSave
			// 
			this.dlgSave.FileName = "xia";
			// 
			// checkBox2
			// 
			this.checkBox2.Location = new System.Drawing.Point(536, 344);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(80, 16);
			this.checkBox2.TabIndex = 15;
			this.checkBox2.Text = "路径偏移";
			this.checkBox2.Click += new System.EventHandler(this.checkBox2_CheckedChanged);
			this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(32, 384);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(248, 40);
			this.label1.TabIndex = 16;
			this.label1.Text = "label1";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(360, 384);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(232, 32);
			this.label2.TabIndex = 17;
			this.label2.Text = "label2";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(632, 437);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.label2,
																		  this.label1,
																		  this.checkBox2,
																		  this.button2,
																		  this.button1,
																		  this.checkBox1,
																		  this.toolBar1,
																		  this.axMap1,
																		  this.dotDens,
																		  this.stdDev,
																		  this.valueMap,
																		  this.singleSmb,
																		  this.fullExt});
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.axMap1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void fullExt_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.axMap1.Extent = this.axMap1.FullExtent;
			}
			catch (System.Runtime.InteropServices.COMException cm)
			{
				MessageBox.Show(cm.Message);
			}
			catch (System.Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void singleSmb_Click(object sender, System.EventArgs e)
		{
			try
			{
				System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
				this.m_pCitiesLyr.Visible = false;
				this.m_pCountiesLyr.Renderer = null;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -