文档库 最新最全的文档下载
当前位置:文档库 › ResForm宏程序岩性抽稀

ResForm宏程序岩性抽稀

void buttonHelp_Click(object sender, EventArgs e)
{
string strReadme = "此程序实现岩性抽稀功能,将厚度小于指定数值的岩性合并为上一个岩性";
MessageBox.Show(strReadme);
}
void comboBoxLitho_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox comboBoxLitho = (ComboBox)sender;
GroupBox groupBox1 = (GroupBox)comboBoxLitho.Parent;
DataGridView dataGridViewShowLitho = (DataGridView)groupBox1.Controls["dataGridViewShowLitho"];

dataGridViewShowLitho.Rows.Clear();
SLithoTrace litho_Trace ;
string[] strRow = new string[4];
if(comboBoxLitho.SelectedIndex > -1)
{
litho_Trace = comboBoxLitho.SelectedItem;
foreach(LithoLayer ss in litho_Trace )
{
strRow[0] = ss.Top;
strRow[1] = ss.Bottom;
strRow[2] = ss.Thickness;
strRow[3] = ss.Litho;
dataGridViewShowLitho.Rows.Add(strRow);
}
MessageBox.Show("岩性浏览完成!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
void buttonExecute_Click(object sender, EventArgs e)
{
Button buttonExecute = (Button)sender;
Form mainForm = (Form)buttonExecute.Parent;
GroupBox groupBox1 = (GroupBox)mainForm.Controls["groupBox1"];
ComboBox comboBoxLitho = (ComboBox)groupBox1.Controls["comboBoxLitho"];
DataGridView dataGridViewNewLitho = (DataGridView)mainForm.Controls["dataGridViewNewLitho"];
TextBox textBoxValue = (TextBox)mainForm.Controls["textBoxValue"];

dataGridViewNewLitho.Rows.Clear();
float thick_value = float.Parse(textBoxValue.Text);
float litho_Thickness;
string[] strRow = new string[3];
// int ;//标记连续岩性厚度大于或者等于thick_value
int flat_small = 0;
int flat_big = 0;
SLithoTrace litho_Trace ;
ArrayList list_Litho = new ArrayList();
list_Litho.Clear();
if(comboBoxLitho.SelectedIndex > -1)
{
litho_Trace = comboBoxLitho.SelectedItem;
foreach(LithoLayer ss in litho_Trace )
{
list_Litho.Add(ss);
}
LithoLayer ss;
for(int i = 0 ; i < list_Litho.Count ; i++)
{
ss = (LithoLayer)list_Litho[i];
litho_Thickness = ss.Thickness;
if(thick_value <= litho_Thickness && flat_big == 1)
{
ss = (LithoLayer)list_Litho[i-1];
strRow[1] = ss.Bottom;
dataGridViewNewLitho.Rows.Add(strRow);
i--;
flat_big = 0;
continue;
}
if(thick_value > litho_Thickness && flat_small == 0)
{
if(flat_big == 1)
{
strRow[1] = ss.Bottom;
continue;
}
strRow[0] = ss.Top;
flat_small = 1;
}
if(thick_value <= litho_Thickness && flat_big == 0)
{
if(flat_small == 1)
{
strRow[1] = ss.Bottom;
strRow[2] = ss.Litho;
dataGridViewNewLitho.Rows.Add(strRow);
flat_small = 0;
continue;
}
strRow[0] = ss.Top;
strRow[2] = ss.Litho;
flat_big = 1;
}
}
strRow[1] = ss.Bottom;
dataGridViewNewLitho.Rows.Add(strRow);
}
list_Litho.Clear();
DialogResult res = MessageBox.Show("是否创建新岩性道并加载抽

稀后数据?\n点'是'创建并加载数据,点'否'取消加载;","信息提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(res == DialogResult.Yes)
{
SLithoTrace[] AllLitho = this.Channels.GetLithoTraces();
SLithoTrace new_LithoTrace = this.Channels.AddTrace(WellTraceTypes.Litho,"NEW_litho"+AllLitho.Length.ToString());
new_LithoTrace.Title = litho_Trace.Title;
new_LithoTrace.ColorColumnWidth = 0;
int dgvRowCount = dataGridViewNewLitho.GetCellCount(DataGridViewElementStates.None) / 3;
float lithotop;
float lithoBottom;
string lithoname1;
for(int i = 0 ; i < (dgvRowCount - 1); i++)
{
lithotop = dataGridViewNewLitho[0,i].Value;
lithoBottom = dataGridViewNewLitho[1,i].Value;
lithoname1 = dataGridViewNewLitho[2,i].Value;
new_LithoTrace.Add(lithotop ,lithoBottom ).Litho = lithoname1 ;
}
MessageBox.Show("岩性加载完成!");
}
else if(res == DialogResult.No)
{
return;
}
}
void main()
{
System.Windows.Forms.Form mainForm;
System.Windows.Forms.GroupBox groupBox1;
https://www.wendangku.net/doc/1b7537892.html,boBox comboBoxLitho;
https://www.wendangku.net/doc/1b7537892.html,bel label1;
System.Windows.Forms.DataGridView dataGridViewShowLitho;
System.Windows.Forms.DataGridView dataGridViewNewLitho;
System.Windows.Forms.Button buttonExecute;
System.Windows.Forms.Button buttonCancel;
System.Windows.Forms.Button buttonHelp;
https://www.wendangku.net/doc/1b7537892.html,bel label2;
System.Windows.Forms.TextBox textBoxValue;
https://www.wendangku.net/doc/1b7537892.html,bel label3;
System.Windows.Forms.DataGridViewTextBoxColumn DepthTop;
System.Windows.Forms.DataGridViewTextBoxColumn DepthBottom;
System.Windows.Forms.DataGridViewTextBoxColumn LithoThickness;
System.Windows.Forms.DataGridViewTextBoxColumn Litho1;
System.Windows.Forms.DataGridViewTextBoxColumn TopDepth;
System.Windows.Forms.DataGridViewTextBoxColumn BottomDepth;
System.Windows.Forms.DataGridViewTextBoxColumn LithoName1;

mainForm = new System.Windows.Forms.Form();
groupBox1 = new System.Windows.Forms.GroupBox();
label1 = new https://www.wendangku.net/doc/1b7537892.html,bel();
comboBoxLitho = new https://www.wendangku.net/doc/1b7537892.html,boBox();
dataGridViewShowLitho = new System.Windows.Forms.DataGridView();
dataGridViewNewLitho = new System.Windows.Forms.DataGridView();
buttonExecute = new System.Windows.Forms.Button();
buttonCancel = new System.Windows.Forms.Button();
buttonHelp = new System.Windows.Forms.Button();
label2 = new https://www.wendangku.net/doc/1b7537892.html,bel();
textBoxValue = new System.Windows.Forms.TextBox();
label3 = new https://www.wendangku.net/doc/1b7537892.html,bel();
DepthTop = new System.Windows.Forms.DataGridViewTextBoxColumn();
DepthBottom = new System.Windows.Forms.DataGridViewTextBoxColumn();
LithoThickness = new System.Windows.Forms.DataGridViewTextBoxColumn();
Litho1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
TopDepth = new System.Windows.Forms.DataGridViewTextBoxColumn();
BottomDepth = new System.Windows.Forms.DataGridViewTextBoxColumn();
LithoName1 = new Sy

stem.Windows.Forms.DataGridViewTextBoxColumn();
//
// groupBox1
//
groupBox1.Controls.Add(dataGridViewShowLitho);
groupBox1.Controls.Add(comboBoxLitho);
groupBox1.Controls.Add(label1);
groupBox1.Location = new System.Drawing.Point(8, 6);
https://www.wendangku.net/doc/1b7537892.html, = "groupBox1";
groupBox1.Size = new System.Drawing.Size(248, 389);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "选择岩性道";
//
// label1
//
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(17, 23);
https://www.wendangku.net/doc/1b7537892.html, = "label1";
label1.Size = new System.Drawing.Size(53, 12);
label1.TabIndex = 0;
label1.Text = "岩 性 道";
//
// comboBoxLitho
//
comboBoxLitho.FormattingEnabled = true;
comboBoxLitho.ItemHeight = 12;
comboBoxLitho.DropDownHeight = 60;
comboBoxLitho.Location = new System.Drawing.Point(87, 19);
https://www.wendangku.net/doc/1b7537892.html, = "comboBoxLitho";
comboBoxLitho.Size = new System.Drawing.Size(140, 20);
comboBoxLitho.TabIndex = 1;
comboBoxLitho.SelectedIndexChanged += new EventHandler(https://www.wendangku.net/doc/1b7537892.html,boBoxLitho_SelectedIndexChanged);
//
// dataGridViewShowLitho
//
dataGridViewShowLitho.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewShowLitho.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
DepthTop,
DepthBottom,
LithoThickness,
Litho1});
dataGridViewShowLitho.Location = new System.Drawing.Point(6, 53);
https://www.wendangku.net/doc/1b7537892.html, = "dataGridViewShowLitho";
dataGridViewShowLitho.RowTemplate.Height = 23;
dataGridViewShowLitho.Size = new System.Drawing.Size(236, 330);
dataGridViewShowLitho.TabIndex = 2;
//
// dataGridViewNewLitho
//
dataGridViewNewLitho.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewNewLitho.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
TopDepth,
BottomDepth,
LithoName1});
dataGridViewNewLitho.Location = new System.Drawing.Point(265, 64);
https://www.wendangku.net/doc/1b7537892.html, = "dataGridViewNewLitho";
dataGridViewNewLitho.RowTemplate.Height = 23;
dataGridViewNewLitho.Size = new System.Drawing.Size(242, 296);
dataGridViewNewLitho.TabIndex = 1;
//
// buttonExecute
//
buttonExecute.Location = new System.Drawing.Point(265, 371);
https://www.wendangku.net/doc/1b7537892.html, = "buttonExecute";
buttonExecute.Size = new System.Drawing.Size(49, 23);
buttonExecute.TabIndex = 2;
buttonExecute.Text = "抽稀";
https://www.wendangku.net/doc/1b7537892.html,eVisualStyleBackColor = true;
buttonExecute.Click += new EventHandler(this.buttonExecute_Click);
//
// buttonCancel
//
buttonCancel.Location = new System.Drawing.Point(351, 371);
https://www.wendangku.net/doc/1b7537892.html, = "buttonCancel";
buttonCancel.Size = new System.Drawing.Size(49, 23);
buttonCancel.TabIndex = 2;
buttonCancel.Text = "退出";
https://www.wendangku.net/doc/1b7537892.html,eVisualStyleBackColor = true;
buttonCancel.DialogResult = DialogResult.Cancel;
//
// buttonHelp
//

buttonHelp.Location = new System.Drawing.Point(437, 371);
https://www.wendangku.net/doc/1b7537892.html, = "buttonHelp";
buttonHelp.Size = new System.Drawing.Size(49, 23);
buttonHelp.TabIndex = 2;
buttonHelp.Text = "帮助";
https://www.wendangku.net/doc/1b7537892.html,eVisualStyleBackColor = true;
buttonHelp.Click += new EventHandler(this.buttonHelp_Click);
//
// label2
//
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(263, 39);
https://www.wendangku.net/doc/1b7537892.html, = "label2";
label2.Size = new System.Drawing.Size(95, 12);
label2.TabIndex = 3;
label2.Text = "岩性厚度小于(m)";
//
// textBoxValue
//
textBoxValue.Location = new System.Drawing.Point(360, 35);
https://www.wendangku.net/doc/1b7537892.html, = "textBoxValue";
textBoxValue.Size = new System.Drawing.Size(100, 21);
textBoxValue.TabIndex = 4;
textBoxValue.Text = "0.5";
//
// label3
//
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(263, 15);
https://www.wendangku.net/doc/1b7537892.html, = "label3";
label3.Size = new System.Drawing.Size(167, 12);
label3.TabIndex = 5;
label3.Text = "输入合并岩性厚度小于某值时:";
//
// DepthTop
//
DepthTop.HeaderText = "顶深";
https://www.wendangku.net/doc/1b7537892.html, = "DepthTop";
DepthTop.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
DepthTop.Width = 60;
//
// DepthBottom
//
DepthBottom.HeaderText = "底深";
https://www.wendangku.net/doc/1b7537892.html, = "DepthBottom";
DepthBottom.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
DepthBottom.Width = 60;
//
LithoThickness.HeaderText = "厚度";
https://www.wendangku.net/doc/1b7537892.html, = "DepthBottom";
LithoThickness.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
LithoThickness.Width = 60;
// Litho
//
Litho1.HeaderText = "岩性描述";
https://www.wendangku.net/doc/1b7537892.html, = "Litho";
//
// TopDepth
//
TopDepth.HeaderText = "顶深";
https://www.wendangku.net/doc/1b7537892.html, = "TopDepth";
TopDepth.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
TopDepth.Width = 60;
//
// BottomDepth
//
BottomDepth.HeaderText = "底深";
https://www.wendangku.net/doc/1b7537892.html, = "BottomDepth";
BottomDepth.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
BottomDepth.Width = 60;
//
// LithoName
//
LithoName1.HeaderText = "岩性描述";
https://www.wendangku.net/doc/1b7537892.html, = "LithoName";
//
// Form1
//
mainForm.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
mainForm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
mainForm.ClientSize = new System.Drawing.Size(516, 407);
mainForm.Controls.Add(label3);
mainForm.Controls.Add(textBoxValue);
mainForm.Controls.Add(label2);
mainForm.Controls.Add(buttonHelp);
mainForm.Controls.Add(buttonCancel);
mainForm.Controls.Add(buttonExecute);
mainForm.Controls.Add(dataGridViewNewLitho);
mainForm.Controls.Add(groupBox1);
mainForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
mainForm.MaximizeBox = false;
mainForm.MinimizeBox = false;
https://www.wendangku.net/doc/1b7537892.html, = "Form1";
mainForm.StartPosition = System.Windows.

Forms.FormStartPosition.CenterScreen;
mainForm.Text = "岩性抽稀";
mainForm.Load += new EventHandler(this.mainForm_Load);

mainForm.ShowDialog();
}
void mainForm_Load(object sender, EventArgs e)
{
Form mainForm = (Form)sender;
GroupBox groupBox1 = (GroupBox)mainForm.Controls["groupBox1"];
ComboBox comboBoxLitho = (ComboBox)groupBox1.Controls["comboBoxLitho"];
comboBoxLitho.Items.Clear();

SLithoTrace[] AllLitho = this.Channels.GetLithoTraces();
if(AllLitho.Length > 0 )
{
for(int i = 0 ; i < AllLitho.Length; i++)
{
comboBoxLitho.Items.Add(AllLitho[i]);
}
comboBoxLitho.DisplayMember = "Name";
}

}

相关文档