using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace Construction.BatchCreateMap { public delegate void ProgressEvent(string eventName, int curentStep); public class WellCalibrate { public void CalculateByFile(string layerFile, string wellFile, string outFile, ProgressEvent callback = null, double factor = 2.5, string faultLayer = "", double coutourStep = 5.0, int contourMark = 5, bool withName=true) { //string strLayerFile = "C:\\GeoIntelligent\\测试\\构造图.dfg"; //string strWellFile = "C:\\GeoIntelligent\\测试\\校正井.csv"; //string strOutFile = "C:\\GeoIntelligent\\测试\\构造图_IDW.dfg"; //callback = TestProgress; IntPtr pEvent = IntPtr.Zero; if (callback != null) { pEvent = Marshal.GetFunctionPointerForDelegate(callback); } // pEvent = Marshal.GetFunctionPointerForDelegate(callback); WellCalibrate.CalculateByFile(layerFile, wellFile, outFile, pEvent, 2.5, faultLayer, coutourStep, contourMark, true); } public void CalculateByMesh(IntPtr pMesh, IntPtr pWellDataX, IntPtr pWellDataY, IntPtr pWellDataZ , int wellCount, string outFile, ProgressEvent callback = null, double factor = 2.5) { callback = TestProgress; IntPtr pEvent = IntPtr.Zero; if (callback != null) { pEvent = Marshal.GetFunctionPointerForDelegate(callback); } pEvent = Marshal.GetFunctionPointerForDelegate(callback); CalculateByMesh(pMesh, pWellDataX, pWellDataY, pWellDataZ, wellCount, outFile, pEvent, 2.5); } private void TestProgress(string eventName, int step) { string str = string.Format("{0},{1}", eventName, step); } #if DEBUG //const string DLL_FILE = @"C:\GeoIntelligent\Code\dirgdf\bin\Debug\WellCalibrate.dll"; const string DLL_FILE = "WellCalibrate.dll"; #else //const string DRAWLIB = "DrawLib.dll"; const string DLL_FILE = "WellCalibrate.dll"; #endif [DllImport(DLL_FILE, EntryPoint = "CalculateByFile", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] public static extern int CalculateByFile(string layerFile, string wellFile, string outFile, IntPtr callback, double factor, string faultLayer, double contourStep, int countourMarkStep, bool withName); [DllImport(DLL_FILE, EntryPoint = "CalculateByMesh", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] public static extern int CalculateByMesh(IntPtr pMesh, IntPtr pWellDataX, IntPtr pWellDataY, IntPtr pWellDataZ , int wellCount, string outFile, IntPtr callback, double factor); } }