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

📄 formtest.cs

📁 剖面生成器
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using SuperMapLib;

namespace ProfileCtrl
{
	/// <summary>
	///主窗体
	/// </summary>
	public class FormTest : System.Windows.Forms.Form
	{		
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton toolBarButton8;
		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.ToolBarButton toolBarButton5;
		private System.Windows.Forms.ToolBarButton toolBarButton6;
		private System.Windows.Forms.ToolBarButton toolBarButton7;
		private AxSuperMapLib.AxSuperMap axSuperMap1;
		private AxSuperMapLib.AxSuperWorkspace axSuperWorkspace1;
		private System.Windows.Forms.ToolBarButton toolBarButton9;
		private System.ComponentModel.IContainer components;

		public FormTest()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			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(FormTest));
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
			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.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton6 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton7 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButton9 = new System.Windows.Forms.ToolBarButton();
			this.axSuperMap1 = new AxSuperMapLib.AxSuperMap();
			this.axSuperWorkspace1 = new AxSuperMapLib.AxSuperWorkspace();
			((System.ComponentModel.ISupportInitialize)(this.axSuperMap1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.axSuperWorkspace1)).BeginInit();
			this.SuspendLayout();
			// 
			// imageList1
			// 
			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.Transparent;
			// 
			// toolBar1
			// 
			this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton8,
																						this.toolBarButton1,
																						this.toolBarButton2,
																						this.toolBarButton3,
																						this.toolBarButton4,
																						this.toolBarButton5,
																						this.toolBarButton6,
																						this.toolBarButton7,
																						this.toolBarButton9});
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(448, 41);
			this.toolBar1.TabIndex = 3;
			this.toolBar1.Wrappable = false;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton8
			// 
			this.toolBarButton8.ImageIndex = 7;
			this.toolBarButton8.Text = "自动";
			this.toolBarButton8.ToolTipText = "生成概化剖面图";
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.Text = "手工";
			this.toolBarButton1.ToolTipText = "手工绘制生成剖面图";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 1;
			this.toolBarButton2.Text = "放大";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 2;
			this.toolBarButton3.Text = "缩小";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 3;
			this.toolBarButton4.Text = "自由";
			// 
			// toolBarButton5
			// 
			this.toolBarButton5.ImageIndex = 4;
			this.toolBarButton5.Text = "漫游";
			// 
			// toolBarButton6
			// 
			this.toolBarButton6.ImageIndex = 5;
			this.toolBarButton6.Text = "全图";
			// 
			// toolBarButton7
			// 
			this.toolBarButton7.ImageIndex = 6;
			this.toolBarButton7.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
			this.toolBarButton7.Text = "属性";
			// 
			// toolBarButton9
			// 
			this.toolBarButton9.Text = "模型";
			this.toolBarButton9.ToolTipText = "读取对比模型";
			// 
			// axSuperMap1
			// 
			this.axSuperMap1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.axSuperMap1.Enabled = true;
			this.axSuperMap1.Location = new System.Drawing.Point(0, 41);
			this.axSuperMap1.Name = "axSuperMap1";
			this.axSuperMap1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSuperMap1.OcxState")));
			this.axSuperMap1.Size = new System.Drawing.Size(448, 276);
			this.axSuperMap1.TabIndex = 4;
			this.axSuperMap1.GeometrySelected += new AxSuperMapLib._DSuperMapEvents_GeometrySelectedEventHandler(this.axSuperMap1_GeometrySelected);
			// 
			// axSuperWorkspace1
			// 
			this.axSuperWorkspace1.Enabled = true;
			this.axSuperWorkspace1.Location = new System.Drawing.Point(200, 128);
			this.axSuperWorkspace1.Name = "axSuperWorkspace1";
			this.axSuperWorkspace1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSuperWorkspace1.OcxState")));
			this.axSuperWorkspace1.Size = new System.Drawing.Size(32, 32);
			this.axSuperWorkspace1.TabIndex = 5;
			// 
			// FormTest
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(448, 317);
			this.Controls.Add(this.axSuperWorkspace1);
			this.Controls.Add(this.axSuperMap1);
			this.Controls.Add(this.toolBar1);
			this.Name = "FormTest";
			this.Text = "测试窗体";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FormTest_Closing);
			this.Load += new System.EventHandler(this.FormTest_Load);
			((System.ComponentModel.ISupportInitialize)(this.axSuperMap1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.axSuperWorkspace1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private void FormTest_Load(object sender, System.EventArgs e)
		{
			//建立SuperWorkspace 与SuperMap之间的联系

			this.axSuperMap1.Connect (this.axSuperWorkspace1.CtlHandle);
//			axSuperMap1.Dock = DockStyle.Fill;
			axSuperMap1.BorderStyle = 1;	 //固定单个边框			
			axSuperMap1.Appearance = 1;	//三维窗口效果
			SuperMapLib.soFillStyleLib objFill = axSuperWorkspace1.Resources.FillStyleLib;
			objFill.RemoveAll();
			objFill.Import("Gwater.bru",true);


			//在Visual Studio.NET中,Handle是系统属性名,因此SuperWorkspace原有的Handle属性被更名为CtlHandle

 			SuperMapLib.soDataSource objDs; //数据源对象,指向打开的数据源

			SuperMapLib.soDatasets objDts;

			objDs=this.axSuperWorkspace1.OpenDataSource("zkfbt.sdb","zkfbt",SuperMapLib.seEngineType.sceSDB,true);
			
			if(objDs != null)

			{

				objDts=objDs.Datasets;

				this.axSuperMap1.Layers.AddDataset (objDts[1],true);

				this.axSuperMap1.CtlRefresh();

				objDs=null;

				objDts=null;

			}

			axSuperMap1.Action = seAction.scaSelect;
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(e.Button.Text)
			{
				case "自动":
					DrawProfile(true);
					break;
				case "模型":
//					ProfileCtrl.LoadPlug loadPlug=new ProfileCtrl.LoadPlug (@"E:\程序\程序vsnet70\newprofilectrl\plugs\");
//					loadPlug.ShowDialog();
					break;
				default:					
					break;
			}
		}

		private void DrawProfile(bool isSum)
		{
			int intZKCount = axSuperMap1.selection.Count;
			if(intZKCount<2)
			{
				MessageBox.Show("生成剖面图到少需要选择两个钻孔!");
				return;
			}
			soRecordset objRecordset = axSuperMap1.selection.ToRecordset(false);			
			ArrayList arrListZK = new ArrayList();			
			for(int i=1;i<=intZKCount;i++)
			{	
				objRecordset.SeekID(axSuperMap1.selection[i]);				
				arrListZK.Add(objRecordset.GetFieldValue("统一编号"));
			}	
			ProfileCtrl.Profile proflie = new ProfileCtrl.Profile();
			proflie.ShowInTaskbar = false;
			proflie.SuperWorkspace = this.axSuperWorkspace1;
			proflie.WindowState = FormWindowState.Maximized;
			proflie.ArrList = arrListZK;
			proflie.IsSum = isSum;
			if(proflie.DrawProfile())
			{
				proflie.ShowDialog(this);
			}
			proflie.Dispose();
		}

		private void axSuperMap1_GeometrySelected(object sender, AxSuperMapLib._DSuperMapEvents_GeometrySelectedEvent e)
		{
			if(!this.toolBarButton7.Pushed) return;	//属性按钮没有按下,退出

			SuperMapLib.soSelection objSelection;

			SuperMapLib.soRecordset objRd;

			objSelection=this.axSuperMap1.selection;

			objRd=objSelection.ToRecordset(false); //提取所选对象的属性数据

			string str="";

			for (int i=1 ;i<=objRd.FieldCount;i++)

			{

				str+=objRd.GetFieldInfo(i).Name ; //得到属性名

				str+=":"+objRd.GetFieldValue(i).ToString()+"\n"; //得到属性值


			}

			MessageBox.Show(str,"查找的纪录为:");

			objSelection=null;

			objRd=null;
		}

		private void FormTest_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			this.axSuperMap1.Close();

			this.axSuperMap1.Disconnect();

			this.axSuperWorkspace1.Close();
		}
	}
}

⌨️ 快捷键说明

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