824 lines
22 KiB
C#
824 lines
22 KiB
C#
|
|
using System;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.IO;
|
||
|
|
using System.Threading;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
|
||
|
|
namespace LP;
|
||
|
|
|
||
|
|
public class FormDiMianQingJiao : Form
|
||
|
|
{
|
||
|
|
private delegate void delegateFormSetTitle(Form form, string value);
|
||
|
|
|
||
|
|
private delegate void delegateComboBoxItemsClear(ComboBox comboBox);
|
||
|
|
|
||
|
|
private delegate void delegateComboBoxAdd(ComboBox comboBox, string value);
|
||
|
|
|
||
|
|
private delegate void delegateComboBoxSetSelectedIndex(ComboBox comboBox, int value);
|
||
|
|
|
||
|
|
private delegate void delegateListBoxItemsClear(ListBox listBox);
|
||
|
|
|
||
|
|
private delegate void delegateListBoxAdd(ListBox listBox, string value);
|
||
|
|
|
||
|
|
private delegate void delegateListBoxSelectedIndex(ListBox listBox, int value);
|
||
|
|
|
||
|
|
private delegate void delegateTextBoxSetText(TextBox textBox, string value);
|
||
|
|
|
||
|
|
private delegate void delegateButtonEnabled(Button button, bool value);
|
||
|
|
|
||
|
|
private delegate void delegateFormHide(Form form);
|
||
|
|
|
||
|
|
public FormDesktop desktop = null;
|
||
|
|
|
||
|
|
public string mTitle = "";
|
||
|
|
|
||
|
|
public XianLuData mXianLuData = null;
|
||
|
|
|
||
|
|
public TaskData mTaskData = null;
|
||
|
|
|
||
|
|
private int mXianLuID = 0;
|
||
|
|
|
||
|
|
public string mNameXianLu = "";
|
||
|
|
|
||
|
|
private string mNameTask = "";
|
||
|
|
|
||
|
|
public int mIndexControl_XianLuName = -1;
|
||
|
|
|
||
|
|
public int mIndex_ListXianLuData = -1;
|
||
|
|
|
||
|
|
public string[] mFileCurrentArr = null;
|
||
|
|
|
||
|
|
public string mFileName = "";
|
||
|
|
|
||
|
|
private bool mAfterInit = false;
|
||
|
|
|
||
|
|
private bool mReady_XianLuName = false;
|
||
|
|
|
||
|
|
private bool mReady_CurrentFile = false;
|
||
|
|
|
||
|
|
private bool mBusy_ButtonOK = false;
|
||
|
|
|
||
|
|
private IContainer components = null;
|
||
|
|
|
||
|
|
private Button buttonCancel;
|
||
|
|
|
||
|
|
private Button buttonSelect;
|
||
|
|
|
||
|
|
private Button buttonOK;
|
||
|
|
|
||
|
|
private TextBox textBox_GC_FileName;
|
||
|
|
|
||
|
|
private ComboBox comboBox_XianLuName;
|
||
|
|
|
||
|
|
private Label label2;
|
||
|
|
|
||
|
|
private Label label1;
|
||
|
|
|
||
|
|
public bool Ready_XianLuName
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
return mReady_XianLuName;
|
||
|
|
}
|
||
|
|
set
|
||
|
|
{
|
||
|
|
mReady_XianLuName = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool Ready_CurrentFile
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
return mReady_CurrentFile;
|
||
|
|
}
|
||
|
|
set
|
||
|
|
{
|
||
|
|
mReady_CurrentFile = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool Busy_ButtonOK
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
return mBusy_ButtonOK;
|
||
|
|
}
|
||
|
|
set
|
||
|
|
{
|
||
|
|
mBusy_ButtonOK = value;
|
||
|
|
MyButtonEnabled(buttonCancel, !value);
|
||
|
|
MyButtonEnabled(buttonSelect, !value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public FormDiMianQingJiao()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
if (mXianLuData == null)
|
||
|
|
{
|
||
|
|
mXianLuData = new XianLuData();
|
||
|
|
}
|
||
|
|
if (mTaskData == null)
|
||
|
|
{
|
||
|
|
mTaskData = new TaskData();
|
||
|
|
}
|
||
|
|
mNameTask = "地面倾角计算";
|
||
|
|
mTitle = "地面倾角计算";
|
||
|
|
mIndexControl_XianLuName = -1;
|
||
|
|
mIndex_ListXianLuData = -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void FormDiMianQingJiao_Load(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
mAfterInit = false;
|
||
|
|
Busy_ButtonOK = false;
|
||
|
|
MyFormSetTitle(this, "");
|
||
|
|
bool ready_CurrentFile = (Ready_XianLuName = false);
|
||
|
|
Ready_CurrentFile = ready_CurrentFile;
|
||
|
|
base.DialogResult = DialogResult.None;
|
||
|
|
MyInput_TaskData();
|
||
|
|
MyInput_List_XianLuData();
|
||
|
|
mAfterInit = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void FormDiMianQingJiao_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyInput_TaskData()
|
||
|
|
{
|
||
|
|
mTaskData.copyFrom_TaskData(desktop.mDlg_CanShuJiSuan.mtData);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyOutput_TaskData()
|
||
|
|
{
|
||
|
|
desktop.mDlg_CanShuJiSuan.mtData.copyFrom_TaskData(mTaskData);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyInput_List_XianLuData()
|
||
|
|
{
|
||
|
|
MyComboBoxItemsClear(comboBox_XianLuName);
|
||
|
|
if (desktop.mXL == null || desktop.mXL.mListXianLuData == null)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
for (int i = 0; i < desktop.mXL.mListXianLuData.Count; i++)
|
||
|
|
{
|
||
|
|
MyComboBoxAdd(comboBox_XianLuName, desktop.mXL.mListXianLuData[i].mName_XianLu);
|
||
|
|
}
|
||
|
|
if (mIndexControl_XianLuName < 0)
|
||
|
|
{
|
||
|
|
mIndexControl_XianLuName = 0;
|
||
|
|
}
|
||
|
|
if (mIndexControl_XianLuName >= 0 && mIndexControl_XianLuName < comboBox_XianLuName.Items.Count)
|
||
|
|
{
|
||
|
|
MyComboBoxSetSelectedIndex(comboBox_XianLuName, mIndexControl_XianLuName);
|
||
|
|
mNameXianLu = comboBox_XianLuName.SelectedItem.ToString();
|
||
|
|
for (int j = 0; j < desktop.mXL.mListXianLuData.Count; j++)
|
||
|
|
{
|
||
|
|
if (mNameXianLu.Equals(desktop.mXL.mListXianLuData[j].mName_XianLu))
|
||
|
|
{
|
||
|
|
mXianLuData.CopyFrom_XianLuData(desktop.mXL.mListXianLuData[j]);
|
||
|
|
mXianLuID = mXianLuData.mID_XianLu;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Ready_XianLuName = true;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
mNameXianLu = "";
|
||
|
|
mXianLuID = 0;
|
||
|
|
Ready_XianLuName = false;
|
||
|
|
}
|
||
|
|
string text = textBox_GC_FileName.Text.Trim();
|
||
|
|
string[] separator = new string[4] { "\r", "\n", " ", ";" };
|
||
|
|
string[] array = null;
|
||
|
|
if (string.IsNullOrEmpty(text))
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
array = text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||
|
|
bool flag = true;
|
||
|
|
for (int k = 0; k < array.Length; k++)
|
||
|
|
{
|
||
|
|
if (!File.Exists(array[k]))
|
||
|
|
{
|
||
|
|
flag = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (array.Length != 0)
|
||
|
|
{
|
||
|
|
mFileCurrentArr = new string[array.Length];
|
||
|
|
for (int l = 0; l < array.Length; l++)
|
||
|
|
{
|
||
|
|
mFileCurrentArr[l] = array[l].Trim();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (flag)
|
||
|
|
{
|
||
|
|
Ready_CurrentFile = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Destroy()
|
||
|
|
{
|
||
|
|
if (mXianLuData != null)
|
||
|
|
{
|
||
|
|
mXianLuData.Destroy();
|
||
|
|
}
|
||
|
|
mXianLuData = null;
|
||
|
|
if (mTaskData != null)
|
||
|
|
{
|
||
|
|
mTaskData.Destroy();
|
||
|
|
}
|
||
|
|
mTaskData = null;
|
||
|
|
if (mFileCurrentArr != null)
|
||
|
|
{
|
||
|
|
for (int i = 0; i < mFileCurrentArr.Length; i++)
|
||
|
|
{
|
||
|
|
mFileCurrentArr[i] = "";
|
||
|
|
}
|
||
|
|
mFileCurrentArr = null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void buttonOK_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "");
|
||
|
|
if (Busy_ButtonOK)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
Busy_ButtonOK = true;
|
||
|
|
if (!Ready_XianLuName)
|
||
|
|
{
|
||
|
|
if (comboBox_XianLuName.Items.Count > 0)
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "请选择线路,然后点击按钮“" + buttonOK.Text + "”。");
|
||
|
|
}
|
||
|
|
if (comboBox_XianLuName.Items.Count == 0)
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "缺少线路数据。 请点击按钮“" + buttonCancel.Text + "”,退出对话框。");
|
||
|
|
}
|
||
|
|
comboBox_XianLuName.Focus();
|
||
|
|
Busy_ButtonOK = false;
|
||
|
|
}
|
||
|
|
else if (!Ready_CurrentFile)
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "请选择高程文件,点击按钮“" + buttonOK.Text + "”。");
|
||
|
|
buttonSelect.Focus();
|
||
|
|
Busy_ButtonOK = false;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Thread thread = new Thread(MyCompute);
|
||
|
|
thread.Start();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private bool IsRepeatTask()
|
||
|
|
{
|
||
|
|
bool result = false;
|
||
|
|
for (int i = 0; i < desktop.mTask.mListDetails.Count; i++)
|
||
|
|
{
|
||
|
|
if (mNameTask.Equals(desktop.mTask.mListDetails[i].mTaskData.mName_Task) && mXianLuID == desktop.mTask.mListDetails[i].mXianLuID_Detail)
|
||
|
|
{
|
||
|
|
result = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void MyRefresh_TaskData()
|
||
|
|
{
|
||
|
|
mTaskData.mID_Task = TaskData.mNextID_static;
|
||
|
|
mTaskData.mTypeCode_Task = 13;
|
||
|
|
mTaskData.mName_Task = mNameTask;
|
||
|
|
mTaskData.mXianLuID_Task = mXianLuData.mID_XianLu;
|
||
|
|
mTaskData.mXianLuName_Task = mXianLuData.mName_XianLu;
|
||
|
|
mTaskData.mXianLuJLZL_Task = mXianLuData.mJLZL_XianLu;
|
||
|
|
mTaskData.mDYDJ_Task = mXianLuData.mDYDJ_XianLu;
|
||
|
|
mTaskData.mPrepare13_DiMianQingJiao = 0;
|
||
|
|
mXianLuData.mPrepare3_DiMianQingJiao = 0;
|
||
|
|
for (int i = 0; i < desktop.mXL.mListXianLuData.Count; i++)
|
||
|
|
{
|
||
|
|
if (mXianLuID == desktop.mXL.mListXianLuData[i].mID_XianLu)
|
||
|
|
{
|
||
|
|
desktop.mXL.mListXianLuData[i].mPrepare3_DiMianQingJiao = 0;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
string text = "";
|
||
|
|
int num = 0;
|
||
|
|
for (int j = 0; j < mFileCurrentArr.Length; j++)
|
||
|
|
{
|
||
|
|
if (!string.IsNullOrEmpty(mFileCurrentArr[j]))
|
||
|
|
{
|
||
|
|
if (num > 0)
|
||
|
|
{
|
||
|
|
text += " ";
|
||
|
|
}
|
||
|
|
text += mFileCurrentArr[j];
|
||
|
|
num++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
mTaskData.mFName_Prepare = text;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void MyCompute()
|
||
|
|
{
|
||
|
|
string text = "";
|
||
|
|
MyFormSetTitle(this, "请稍候...");
|
||
|
|
text = Compute_DiMianQingJiao();
|
||
|
|
if (!text.Equals("OK"))
|
||
|
|
{
|
||
|
|
MyLog.AddLog("MyCompute() " + text);
|
||
|
|
}
|
||
|
|
Busy_ButtonOK = false;
|
||
|
|
base.DialogResult = DialogResult.OK;
|
||
|
|
MyFormHide(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
private string Compute_DiMianQingJiao()
|
||
|
|
{
|
||
|
|
string result = "OK";
|
||
|
|
byte[] array = new byte[100];
|
||
|
|
int num = 0;
|
||
|
|
int num2 = 0;
|
||
|
|
int num3 = 0;
|
||
|
|
int num4 = 0;
|
||
|
|
int num5 = 0;
|
||
|
|
int num6 = 0;
|
||
|
|
int num7 = 0;
|
||
|
|
double num8 = 0.0;
|
||
|
|
double num9 = 0.0;
|
||
|
|
double num10 = 0.0;
|
||
|
|
double num11 = 0.0;
|
||
|
|
double num12 = 0.0;
|
||
|
|
double[] array2 = new double[9];
|
||
|
|
double[] array3 = new double[9];
|
||
|
|
double[] array4 = new double[9];
|
||
|
|
double[] array5 = new double[9];
|
||
|
|
double num13 = 0.0;
|
||
|
|
double num14 = 0.0;
|
||
|
|
double num15 = 0.0;
|
||
|
|
double num16 = 0.0;
|
||
|
|
double num17 = 0.0;
|
||
|
|
int num18 = 0;
|
||
|
|
int num19 = 0;
|
||
|
|
int i = 0;
|
||
|
|
GanTas ganTas = null;
|
||
|
|
bool flag = false;
|
||
|
|
MyFormSetTitle(this, "请稍候......");
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (desktop.mXL.mListXianLuData == null)
|
||
|
|
{
|
||
|
|
return $"线路数据为空,mXianLuID={mXianLuID} mNameXianLu={mNameXianLu}";
|
||
|
|
}
|
||
|
|
for (num7 = 0; num7 < desktop.mXL.mListXianLuData.Count && (desktop.mXL.mListXianLuData[num7] == null || desktop.mXL.mListXianLuData[num7].mID_XianLu != mXianLuID); num7++)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
if (num7 >= desktop.mXL.mListXianLuData.Count)
|
||
|
|
{
|
||
|
|
return $"线路数据不匹配,mXianLuID={mXianLuID} mNameXianLu={mNameXianLu}";
|
||
|
|
}
|
||
|
|
ganTas = desktop.mXL.mListGanTas[num7];
|
||
|
|
num19 = desktop.mXL.mListGanTas[num7].mListGanTaData.Count;
|
||
|
|
if (string.IsNullOrEmpty(mFileName))
|
||
|
|
{
|
||
|
|
return "高程数据文件名mFileName为空。";
|
||
|
|
}
|
||
|
|
if (!File.Exists(mFileName))
|
||
|
|
{
|
||
|
|
return "文件未找到,mFileName=" + mFileName;
|
||
|
|
}
|
||
|
|
for (int j = 0; j < array.Length; j++)
|
||
|
|
{
|
||
|
|
array[j] = 0;
|
||
|
|
}
|
||
|
|
using (FileStream fileStream = new FileStream(mFileName, FileMode.Open, FileAccess.Read, FileShare.None))
|
||
|
|
{
|
||
|
|
fileStream.Seek(0L, SeekOrigin.Begin);
|
||
|
|
fileStream.Read(array, 0, 12);
|
||
|
|
num = array[0] * 256 + array[1];
|
||
|
|
num2 = array[2] * 256 + array[3];
|
||
|
|
num3 = array[4] * 256 + array[5];
|
||
|
|
num4 = array[6] * 256 + array[7];
|
||
|
|
num5 = array[8] * 256 + array[9];
|
||
|
|
num6 = array[10] * 256 + array[11];
|
||
|
|
fileStream.Close();
|
||
|
|
}
|
||
|
|
for (i = 0; i < ganTas.mListGanTaData.Count; i++)
|
||
|
|
{
|
||
|
|
num8 = ganTas.mListGanTaData[i].mJingDu_GanTa;
|
||
|
|
num10 = ganTas.mListGanTaData[i].mWeiDu_GanTa;
|
||
|
|
if (i == ganTas.mListGanTaData.Count - 1)
|
||
|
|
{
|
||
|
|
num9 = ganTas.mListGanTaData[i - 1].mJingDu_GanTa;
|
||
|
|
num11 = ganTas.mListGanTaData[i - 1].mWeiDu_GanTa;
|
||
|
|
}
|
||
|
|
else if (i < ganTas.mListGanTaData.Count - 1)
|
||
|
|
{
|
||
|
|
num9 = ganTas.mListGanTaData[i + 1].mJingDu_GanTa;
|
||
|
|
num11 = ganTas.mListGanTaData[i + 1].mWeiDu_GanTa;
|
||
|
|
}
|
||
|
|
num12 = Math.Atan((num11 - num10) / (num9 - num8));
|
||
|
|
array2[0] = num8 - 200.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[1] = num8 - 150.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[2] = num8 - 100.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[3] = num8 - 50.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[4] = num8;
|
||
|
|
array2[5] = num8 + 50.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[6] = num8 + 100.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[7] = num8 + 150.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array2[8] = num8 + 200.0 * Math.Sin(num12) / 100000.0;
|
||
|
|
array3[0] = num10 + 200.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[1] = num10 + 150.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[2] = num10 + 100.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[3] = num10 + 50.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[4] = num10;
|
||
|
|
array3[5] = num10 - 50.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[6] = num10 - 100.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[7] = num10 - 150.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
array3[8] = num10 - 200.0 * Math.Cos(num12) / 100000.0;
|
||
|
|
flag = false;
|
||
|
|
for (int k = 0; k < 9; k++)
|
||
|
|
{
|
||
|
|
num16 = array2[k] - (double)num;
|
||
|
|
num17 = array3[k] - (double)num3;
|
||
|
|
double num20 = num16 / (double)(num2 - num) * (double)num5;
|
||
|
|
num15 = (1.0 - num17 / (double)(num4 - num3)) * (double)num6;
|
||
|
|
num18 = (int)num15 * num5 + (int)num20;
|
||
|
|
for (int l = 0; l < array.Length; l++)
|
||
|
|
{
|
||
|
|
array[l] = 0;
|
||
|
|
}
|
||
|
|
try
|
||
|
|
{
|
||
|
|
using FileStream fileStream2 = new FileStream(mFileName, FileMode.Open, FileAccess.Read, FileShare.None);
|
||
|
|
fileStream2.Seek(12 + num18 * 2, SeekOrigin.Begin);
|
||
|
|
fileStream2.Read(array, 0, 2);
|
||
|
|
array4[k] = array[0] * 256 + array[1];
|
||
|
|
fileStream2.Close();
|
||
|
|
}
|
||
|
|
catch (Exception)
|
||
|
|
{
|
||
|
|
flag = true;
|
||
|
|
}
|
||
|
|
if (flag)
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!flag)
|
||
|
|
{
|
||
|
|
num13 = (num14 = 0.0);
|
||
|
|
for (int m = 0; m <= 3; m++)
|
||
|
|
{
|
||
|
|
array5[m] = Math.Atan((array4[4] - array4[m]) / 50.0);
|
||
|
|
num13 += array5[m];
|
||
|
|
}
|
||
|
|
num13 = num13 / 4.0 * 180.0 / Math.PI;
|
||
|
|
for (int n = 5; n <= 8; n++)
|
||
|
|
{
|
||
|
|
array5[n] = Math.Atan((array4[4] - array4[n]) / 50.0);
|
||
|
|
num14 += array5[n];
|
||
|
|
}
|
||
|
|
num14 = num14 / 4.0 * 180.0 / Math.PI;
|
||
|
|
ganTas.mListGanTaData[i].mDMQJ1_GanTa = num13;
|
||
|
|
ganTas.mListGanTaData[i].mDMQJ2_GanTa = num14;
|
||
|
|
MyFormSetTitle(this, $"请稍候......({i + 1}/{num19})");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
desktop.mXL.mListXianLuData[num7].mPrepare3_DiMianQingJiao = 1;
|
||
|
|
desktop.mDlg_CanShuJiSuan.mMsg = $"{num19}杆塔地面倾角";
|
||
|
|
}
|
||
|
|
catch (Exception ex2)
|
||
|
|
{
|
||
|
|
result = $"Compute_DiMianQingJiao() t={i} N={num19} ex={ex2.Message}";
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "");
|
||
|
|
MyButtonEnabled(buttonCancel, value: false);
|
||
|
|
Thread thread = new Thread(MyCancel);
|
||
|
|
thread.Start();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void MyCancel()
|
||
|
|
{
|
||
|
|
MyFormSetTitle(this, "取消—");
|
||
|
|
MyFormSetTitle(this, "取消———");
|
||
|
|
base.DialogResult = DialogResult.Cancel;
|
||
|
|
MyFormHide(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void buttonSelect_Click(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
|
|
openFileDialog.InitialDirectory = Application.StartupPath;
|
||
|
|
openFileDialog.Filter = "所有文件*.*|*.*|Excel文件(*.csv)|*.csv|Txt文件(*.txt)|*.txt";
|
||
|
|
openFileDialog.FilterIndex = 1;
|
||
|
|
openFileDialog.Multiselect = true;
|
||
|
|
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
|
||
|
|
{
|
||
|
|
mFileName = openFileDialog.FileName;
|
||
|
|
MyTextBoxSetText(textBox_GC_FileName, mFileName);
|
||
|
|
Ready_CurrentFile = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void comboBox_XianLuName_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
if (!mAfterInit || Busy_ButtonOK)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
int selectedIndex = ((ComboBox)sender).SelectedIndex;
|
||
|
|
mIndexControl_XianLuName = selectedIndex;
|
||
|
|
mNameXianLu = ((ComboBox)sender).SelectedItem.ToString().Trim();
|
||
|
|
for (int i = 0; i < desktop.mXL.mListXianLuData.Count; i++)
|
||
|
|
{
|
||
|
|
if (mNameXianLu.Equals(desktop.mXL.mListXianLuData[i].mName_XianLu))
|
||
|
|
{
|
||
|
|
mIndex_ListXianLuData = i;
|
||
|
|
mXianLuData.CopyFrom_XianLuData(desktop.mXL.mListXianLuData[i]);
|
||
|
|
mXianLuID = mXianLuData.mID_XianLu;
|
||
|
|
Ready_XianLuName = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void textBox_GC_FileName_Leave(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
if (!mAfterInit || Busy_ButtonOK)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
Ready_CurrentFile = false;
|
||
|
|
string text = textBox_GC_FileName.Text.Trim();
|
||
|
|
string[] separator = new string[4] { "\r", "\n", " ", ";" };
|
||
|
|
if (string.IsNullOrEmpty(text))
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
string[] array = text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||
|
|
bool ready_CurrentFile = true;
|
||
|
|
for (int i = 0; i < array.Length; i++)
|
||
|
|
{
|
||
|
|
if (!File.Exists(array[i]))
|
||
|
|
{
|
||
|
|
ready_CurrentFile = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (array.Length != 0)
|
||
|
|
{
|
||
|
|
mFileCurrentArr = new string[array.Length];
|
||
|
|
for (int j = 0; j < array.Length; j++)
|
||
|
|
{
|
||
|
|
mFileCurrentArr[j] = array[j].Trim();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
Ready_CurrentFile = ready_CurrentFile;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyFormSetTitle(Form form, string value)
|
||
|
|
{
|
||
|
|
if (form.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateFormSetTitle method = MyFormSetTitle;
|
||
|
|
form.Invoke(method, form, value);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (string.IsNullOrEmpty(value))
|
||
|
|
{
|
||
|
|
form.Text = mTitle;
|
||
|
|
}
|
||
|
|
if (!string.IsNullOrEmpty(value))
|
||
|
|
{
|
||
|
|
form.Text = mTitle + " " + value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyComboBoxItemsClear(ComboBox comboBox)
|
||
|
|
{
|
||
|
|
if (comboBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateComboBoxItemsClear method = MyComboBoxItemsClear;
|
||
|
|
comboBox.Invoke(method, comboBox);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
comboBox.Items.Clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyComboBoxAdd(ComboBox comboBox, string value)
|
||
|
|
{
|
||
|
|
if (comboBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateComboBoxAdd method = MyComboBoxAdd;
|
||
|
|
comboBox.Invoke(method, comboBox, value);
|
||
|
|
}
|
||
|
|
else if (!string.IsNullOrEmpty(value))
|
||
|
|
{
|
||
|
|
comboBox.Items.Add(value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyComboBoxSetSelectedIndex(ComboBox comboBox, int value)
|
||
|
|
{
|
||
|
|
if (comboBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateComboBoxSetSelectedIndex method = MyComboBoxSetSelectedIndex;
|
||
|
|
comboBox.Invoke(method, comboBox, value);
|
||
|
|
}
|
||
|
|
else if (value >= 0 && value < comboBox.Items.Count)
|
||
|
|
{
|
||
|
|
comboBox.SelectedIndex = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyListBoxItemsClear(ListBox listBox)
|
||
|
|
{
|
||
|
|
if (listBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateListBoxItemsClear method = MyListBoxItemsClear;
|
||
|
|
listBox.Invoke(method, listBox);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
listBox.Items.Clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyListBoxAdd(ListBox listBox, string value)
|
||
|
|
{
|
||
|
|
if (listBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateListBoxAdd method = MyListBoxAdd;
|
||
|
|
listBox.Invoke(method, listBox, value);
|
||
|
|
}
|
||
|
|
else if (!string.IsNullOrEmpty(value))
|
||
|
|
{
|
||
|
|
listBox.Items.Add(value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyListBoxSelectedIndex(ListBox listBox, int value)
|
||
|
|
{
|
||
|
|
if (listBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateListBoxSelectedIndex method = MyListBoxSelectedIndex;
|
||
|
|
listBox.Invoke(method, listBox, value);
|
||
|
|
}
|
||
|
|
else if (value >= 0 && value < listBox.Items.Count)
|
||
|
|
{
|
||
|
|
listBox.SelectedIndex = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyTextBoxSetText(TextBox textBox, string value)
|
||
|
|
{
|
||
|
|
if (textBox.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateTextBoxSetText method = MyTextBoxSetText;
|
||
|
|
textBox.Invoke(method, textBox, value);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
textBox.Text = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyButtonEnabled(Button button, bool value)
|
||
|
|
{
|
||
|
|
if (button.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateButtonEnabled method = MyButtonEnabled;
|
||
|
|
button.Invoke(method, button, value);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
button.Enabled = value;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void MyFormHide(Form form)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (form.InvokeRequired)
|
||
|
|
{
|
||
|
|
delegateFormHide method = MyFormHide;
|
||
|
|
form.Invoke(method, form);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
form.Hide();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void Dispose(bool disposing)
|
||
|
|
{
|
||
|
|
if (disposing && components != null)
|
||
|
|
{
|
||
|
|
components.Dispose();
|
||
|
|
}
|
||
|
|
base.Dispose(disposing);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void InitializeComponent()
|
||
|
|
{
|
||
|
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||
|
|
this.buttonSelect = new System.Windows.Forms.Button();
|
||
|
|
this.buttonOK = new System.Windows.Forms.Button();
|
||
|
|
this.textBox_GC_FileName = new System.Windows.Forms.TextBox();
|
||
|
|
this.comboBox_XianLuName = new System.Windows.Forms.ComboBox();
|
||
|
|
this.label2 = new System.Windows.Forms.Label();
|
||
|
|
this.label1 = new System.Windows.Forms.Label();
|
||
|
|
base.SuspendLayout();
|
||
|
|
this.buttonCancel.Location = new System.Drawing.Point(267, 184);
|
||
|
|
this.buttonCancel.Name = "buttonCancel";
|
||
|
|
this.buttonCancel.Size = new System.Drawing.Size(108, 28);
|
||
|
|
this.buttonCancel.TabIndex = 4;
|
||
|
|
this.buttonCancel.Text = "取消";
|
||
|
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||
|
|
this.buttonCancel.Click += new System.EventHandler(buttonCancel_Click);
|
||
|
|
this.buttonSelect.Location = new System.Drawing.Point(326, 134);
|
||
|
|
this.buttonSelect.Name = "buttonSelect";
|
||
|
|
this.buttonSelect.Size = new System.Drawing.Size(49, 28);
|
||
|
|
this.buttonSelect.TabIndex = 2;
|
||
|
|
this.buttonSelect.Text = "选择";
|
||
|
|
this.buttonSelect.UseVisualStyleBackColor = true;
|
||
|
|
this.buttonSelect.Click += new System.EventHandler(buttonSelect_Click);
|
||
|
|
this.buttonOK.Location = new System.Drawing.Point(132, 184);
|
||
|
|
this.buttonOK.Name = "buttonOK";
|
||
|
|
this.buttonOK.Size = new System.Drawing.Size(108, 28);
|
||
|
|
this.buttonOK.TabIndex = 3;
|
||
|
|
this.buttonOK.Text = "确定";
|
||
|
|
this.buttonOK.UseVisualStyleBackColor = true;
|
||
|
|
this.buttonOK.Click += new System.EventHandler(buttonOK_Click);
|
||
|
|
this.textBox_GC_FileName.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
||
|
|
this.textBox_GC_FileName.Location = new System.Drawing.Point(19, 136);
|
||
|
|
this.textBox_GC_FileName.Name = "textBox_GC_FileName";
|
||
|
|
this.textBox_GC_FileName.Size = new System.Drawing.Size(290, 26);
|
||
|
|
this.textBox_GC_FileName.TabIndex = 1;
|
||
|
|
this.textBox_GC_FileName.Leave += new System.EventHandler(textBox_GC_FileName_Leave);
|
||
|
|
this.comboBox_XianLuName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||
|
|
this.comboBox_XianLuName.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
||
|
|
this.comboBox_XianLuName.FormattingEnabled = true;
|
||
|
|
this.comboBox_XianLuName.Location = new System.Drawing.Point(19, 43);
|
||
|
|
this.comboBox_XianLuName.Name = "comboBox_XianLuName";
|
||
|
|
this.comboBox_XianLuName.Size = new System.Drawing.Size(356, 20);
|
||
|
|
this.comboBox_XianLuName.TabIndex = 0;
|
||
|
|
this.comboBox_XianLuName.SelectedIndexChanged += new System.EventHandler(comboBox_XianLuName_SelectedIndexChanged);
|
||
|
|
this.label2.AutoSize = true;
|
||
|
|
this.label2.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
||
|
|
this.label2.Location = new System.Drawing.Point(19, 104);
|
||
|
|
this.label2.Name = "label2";
|
||
|
|
this.label2.Size = new System.Drawing.Size(104, 16);
|
||
|
|
this.label2.TabIndex = 57;
|
||
|
|
this.label2.Text = "高程数据文件";
|
||
|
|
this.label1.AutoSize = true;
|
||
|
|
this.label1.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
||
|
|
this.label1.Location = new System.Drawing.Point(19, 18);
|
||
|
|
this.label1.Name = "label1";
|
||
|
|
this.label1.Size = new System.Drawing.Size(72, 16);
|
||
|
|
this.label1.TabIndex = 58;
|
||
|
|
this.label1.Text = "线路名称";
|
||
|
|
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
|
||
|
|
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||
|
|
base.ClientSize = new System.Drawing.Size(394, 231);
|
||
|
|
base.Controls.Add(this.buttonCancel);
|
||
|
|
base.Controls.Add(this.buttonSelect);
|
||
|
|
base.Controls.Add(this.buttonOK);
|
||
|
|
base.Controls.Add(this.textBox_GC_FileName);
|
||
|
|
base.Controls.Add(this.comboBox_XianLuName);
|
||
|
|
base.Controls.Add(this.label2);
|
||
|
|
base.Controls.Add(this.label1);
|
||
|
|
base.Name = "FormDiMianQingJiao";
|
||
|
|
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||
|
|
this.Text = "FormDiMianQingJiao";
|
||
|
|
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormDiMianQingJiao_FormClosing);
|
||
|
|
base.Load += new System.EventHandler(FormDiMianQingJiao_Load);
|
||
|
|
base.ResumeLayout(false);
|
||
|
|
base.PerformLayout();
|
||
|
|
}
|
||
|
|
}
|