You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
4.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Construction.BatchCreateMap;
namespace TestIDWSharp
{
public partial class Form1 : Form
{
ProgressEvent progressEvent;
public Form1()
{
InitializeComponent();
progressEvent = DoProgress;
}
private void button1_Click(object sender, EventArgs e)
{
WellCalibrate calibrate = new WellCalibrate();
Console.WriteLine("afsfds");
//string strGrid = @"C:\GeoIntelligent\Test\工区10.8\middle\interpret_depthlayer\s21_bak.dfd";
//string strWell = @"C:\GeoIntelligent\Test\工区10.8\middle\interpret_depthlayer\s21wells.csv";
//string strOut = @"C:\GeoIntelligent\Test\工区10.8\middle\interpret_depthlayer\s21.dfd";
string strGrid = @"C:\GeoIntelligent\Test\测\middle\interpret_depthlayer\1.dfd";
string strWell = @"C:\GeoIntelligent\Test\测\middle\interpret_depthlayer\1wells.csv";
string strOut = @"C:\GeoIntelligent\Test\测\middle\interpret_depthlayer\1_adjust.dfd";
//calibrate.CalculateByFile(strGrid, strWell, strGrid);
//calibrate.CalculateByFile(strGrid, strWell, strOut, null, 2.0, "断层", 5.0, 5,true);
calibrate.CalculateByFile(strGrid, strWell, strOut, null, 2.0, "断层", 5.0, 5, true);
}
/// <summary>
/// 网格化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void btnOK_Click(object sender, EventArgs e)
{
string strXyz = this.txtXyz.Text;
string strBorder = this.txtBorder.Text;
string strFault = this.txtFault.Text;
string strResult = this.txtResult.Text;
int nGridX = Convert.ToInt32(this.txtGridX.Text);
double dSmooth = Convert.ToDouble(this.txtSmooth.Text);
int nInsertTimes = Convert.ToInt32(txtInsertTimes.Text);
double dSearchDistance = Convert.ToDouble(txtSearchDistance.Text);
strXyz = @"D:\temp\新建文件夹\新建项目\Interpret\TimeLayer\S22a.xyz_Grid.xyz";
strBorder = @"D:\temp\新建文件夹\新建项目\Interpret\Boundary\s22a.dfd";
// strBorder = string.Empty;
strFault = @"D:\temp\新建文件夹\新建项目\Interpret\Fault\S22a.dfd";
//strFault = string.Empty;
strResult = @"D:\temp\新建文件夹\新建项目\middle\interpret_timelayer\s22a.dfd";
nGridX = 50;
dSmooth = 1;
//nInsertTimes = 1;
strBorder = String.IsNullOrEmpty(strBorder) ? "NULL" : strBorder;
//DateTime timeStart = DateTime.Now;
IntPtr pEvent = IntPtr.Zero;
pEvent = Marshal.GetFunctionPointerForDelegate(progressEvent);
this.btnOK.Text = "正在执行";
this.btnOK.Enabled = false;
await Task.Run(() =>
{
try
{
int nSmoothTimes = 3;
ModelCreateIDW.IDWModelCreate(strXyz, strBorder, strFault, strResult,
nGridX, dSmooth, nSmoothTimes, pEvent, nInsertTimes, 1, 5);
//MessageBox.Show(strXyz);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
});
//t.Start();
//t.Wait();
this.btnOK.Text = "执行";
this.btnOK.Enabled = true;
this.progressBar1.Value = 0;
//TimeSpan timeSpan = (DateTime.Now - timeStart);
MessageBox.Show("完成:");// + timeSpan.TotalSeconds);
}
private void DoProgress(string funName, int step)
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() =>
{
try {
this.progressBar1.Value = step;
this.progressBar1.Update();
}catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}));
}
else
{
this.progressBar1.Value = step;
this.progressBar1.Update();
}
}
}
}