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.

142 lines
4.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Generic;
using System.IO;
namespace GeoSigma.UCDraw.WellAndSection
{
public partial class FrmNewWellPole : Form
{
public string mWellName;
public string mTemplatefileNamePath;
public float mTop;
public float mBottom;
public float mRatio;
string mTemplatePath;
class CTempfileInfo
{
public string fileName {get; set;}
}
List<CTempfileInfo> mTempFileList = new List<CTempfileInfo>();
class CRatioInfo
{
public string text { get; set; }
public float value { get; set; }
}
List<CRatioInfo> mRatioList = new List<CRatioInfo>();
public FrmNewWellPole()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
if(comboxTemplate.SelectedItem is CTempfileInfo selectTemp)
{
if (selectTemp.fileName != "")
mTemplatefileNamePath = mTemplatePath + selectTemp.fileName;
else
mTemplatefileNamePath = "";
}
if(comBoxRatio.SelectedItem is CRatioInfo tratio)
{
mRatio = tratio.value;
}
mWellName = textBoxWellName.Text;
float fv = 0;
if(float.TryParse(textBoxWellTop.Text, out fv))
{
mTop = fv;
}
if (float.TryParse(textBoxWellBottom.Text, out fv))
{
mBottom = fv;
}
}
private void FrmNewWellPole_Shown(object sender, EventArgs e)
{
mTop = 0;
mBottom = 1000;
mRatio = 200;
this.textBoxWellName.Text = "新井";
this.textBoxWellTop.Text = "0";
this.textBoxWellBottom.Text = "1000";
CRatioInfo tratioInfo = new CRatioInfo();
tratioInfo.text = "1:50"; tratioInfo.value = 50;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:100"; tratioInfo.value = 100;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:200"; tratioInfo.value = 200;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:500"; tratioInfo.value = 500;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:1000"; tratioInfo.value = 1000;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:2000"; tratioInfo.value = 2000;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:5000"; tratioInfo.value = 5000;
mRatioList.Add(tratioInfo);
tratioInfo = new CRatioInfo();
tratioInfo.text = "1:10000"; tratioInfo.value = 10000;
mRatioList.Add(tratioInfo);
this.comBoxRatio.DataSource = mRatioList;
this.comBoxRatio.DisplayMember = "text";
this.comBoxRatio.ValueMember = "value";
this.comBoxRatio.SelectedIndex = 2;
CTempfileInfo tfile = new CTempfileInfo();
tfile.fileName = "";
mTempFileList.Add(tfile); //增加一个空的名称
mTemplatePath = AppDomain.CurrentDomain.BaseDirectory + "Templates\\WellPole\\";
if( Directory.Exists(mTemplatePath))
{
try
{
var fileNames = Directory.GetFiles(mTemplatePath)
.Select(Path.GetFileName)
.OrderBy(name => name)
.ToArray();
foreach( var fileName in fileNames)
{
string tname = fileName.ToLower();
String tstr1 = tname.Length > 4 ? tname.Substring(tname.Length - 4) : "";
if (tstr1 == ".pcg")
{
CTempfileInfo tfile1 = new CTempfileInfo();
tfile1.fileName = fileName;
mTempFileList.Add(tfile1);
}
}
}
catch (Exception ex)
{
}
}
this.comboxTemplate.DataSource = mTempFileList;
this.comboxTemplate.DisplayMember = "fileName";
this.comboxTemplate.SelectedIndex = 0;
}
}
}