?? formtest.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 窗體設(shè)計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <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>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </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>
// /// 應(yīng)用程序的主入口點(diǎn)。
// /// </summary>
// [STAThread]
// static void Main()
// {
// Application.Run(new FormTest());
// }
private void FormTest_Load(object sender, System.EventArgs e)
{
//建立SuperWorkspace 與SuperMap之間的聯(lián)系
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是系統(tǒng)屬性名,因此SuperWorkspace原有的Handle屬性被更名為CtlHandle
SuperMapLib.soDataSource objDs; //數(shù)據(jù)源對象,指向打開的數(shù)據(jù)源
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("統(tǒng)一編號"));
}
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); //提取所選對象的屬性數(shù)據(jù)
string str="";
for (int i=1 ;i<=objRd.FieldCount;i++)
{
str+=objRd.GetFieldInfo(i).Name ; //得到屬性名
str+=":"+objRd.GetFieldValue(i).ToString()+"\n"; //得到屬性值
}
MessageBox.Show(str,"查找的紀(jì)錄為:");
objSelection=null;
objRd=null;
}
private void FormTest_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.axSuperMap1.Close();
this.axSuperMap1.Disconnect();
this.axSuperWorkspace1.Close();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -