1071 lines
30 KiB
C#
1071 lines
30 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace LP;
|
|
|
|
public class FormDiShanMiDu : 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 string mYanXian_QuYu = "";
|
|
|
|
public int mIndexControl_YanXian_QuYu = -1;
|
|
|
|
private bool mAfterInit = false;
|
|
|
|
private bool mReady_XianLuName = false;
|
|
|
|
private bool mReady_CurrentFile = false;
|
|
|
|
private bool mReady_YanXian_QuYu = false;
|
|
|
|
private bool mBusy_ButtonOK = false;
|
|
|
|
private string mThisImageFileName = "";
|
|
|
|
private string mTargetImageFileName = "";
|
|
|
|
private string mPythonEXE_FileName = "";
|
|
|
|
private IContainer components = null;
|
|
|
|
private Button buttonCancel;
|
|
|
|
private Button buttonSelect;
|
|
|
|
private Button buttonOK;
|
|
|
|
private TextBox textBox_DS_FileName;
|
|
|
|
private ComboBox comboBox_XianLuName;
|
|
|
|
private Label label2;
|
|
|
|
private Label label1;
|
|
|
|
private Label label3;
|
|
|
|
private ComboBox comboBox_YanXian_QuYu;
|
|
|
|
private Label label4;
|
|
|
|
private TextBox textBox_NumberYears;
|
|
|
|
private PictureBox pictureBox1;
|
|
|
|
private Button buttonShow;
|
|
|
|
public string YanXian_QuYu
|
|
{
|
|
get
|
|
{
|
|
return mYanXian_QuYu;
|
|
}
|
|
set
|
|
{
|
|
mYanXian_QuYu = value;
|
|
mNameTask = "地闪密度-" + mYanXian_QuYu;
|
|
}
|
|
}
|
|
|
|
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 Ready_YanXian_QuYu
|
|
{
|
|
get
|
|
{
|
|
return mReady_YanXian_QuYu;
|
|
}
|
|
set
|
|
{
|
|
mReady_YanXian_QuYu = value;
|
|
}
|
|
}
|
|
|
|
public bool Busy_ButtonOK
|
|
{
|
|
get
|
|
{
|
|
return mBusy_ButtonOK;
|
|
}
|
|
set
|
|
{
|
|
mBusy_ButtonOK = value;
|
|
MyButtonEnabled(buttonCancel, !value);
|
|
MyButtonEnabled(buttonSelect, !value);
|
|
MyButtonEnabled(buttonOK, !value);
|
|
MyButtonEnabled(buttonShow, !value);
|
|
}
|
|
}
|
|
|
|
public FormDiShanMiDu()
|
|
{
|
|
InitializeComponent();
|
|
if (mXianLuData == null)
|
|
{
|
|
mXianLuData = new XianLuData();
|
|
}
|
|
if (mTaskData == null)
|
|
{
|
|
mTaskData = new TaskData();
|
|
}
|
|
mTitle = "地闪密度计算绘制";
|
|
mIndexControl_XianLuName = -1;
|
|
mIndex_ListXianLuData = -1;
|
|
mIndexControl_YanXian_QuYu = -1;
|
|
}
|
|
|
|
private void FormDiShanMiDu_Load(object sender, EventArgs e)
|
|
{
|
|
mAfterInit = false;
|
|
Busy_ButtonOK = false;
|
|
MyFormSetTitle(this, "");
|
|
bool flag = (Ready_XianLuName = false);
|
|
bool ready_YanXian_QuYu = (Ready_CurrentFile = flag);
|
|
Ready_YanXian_QuYu = ready_YanXian_QuYu;
|
|
base.DialogResult = DialogResult.None;
|
|
MyInput_TaskData();
|
|
MyInput_List_XianLuData();
|
|
bool visible = false;
|
|
textBox_NumberYears.Visible = visible;
|
|
textBox_DS_FileName.Visible = visible;
|
|
buttonSelect.Visible = visible;
|
|
comboBox_YanXian_QuYu.Visible = visible;
|
|
label2.Visible = visible;
|
|
label3.Visible = visible;
|
|
label4.Visible = visible;
|
|
mAfterInit = true;
|
|
}
|
|
|
|
private void FormDiShanMiDu_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;
|
|
}
|
|
MyComboBoxItemsClear(comboBox_YanXian_QuYu);
|
|
MyComboBoxAdd(comboBox_YanXian_QuYu, "沿线");
|
|
if (mIndexControl_YanXian_QuYu < 0)
|
|
{
|
|
mIndexControl_YanXian_QuYu = 0;
|
|
}
|
|
if (mIndexControl_YanXian_QuYu >= 0 && mIndexControl_YanXian_QuYu < comboBox_YanXian_QuYu.Items.Count)
|
|
{
|
|
MyComboBoxSetSelectedIndex(comboBox_YanXian_QuYu, mIndexControl_YanXian_QuYu);
|
|
YanXian_QuYu = comboBox_YanXian_QuYu.SelectedItem.ToString().Trim();
|
|
Ready_YanXian_QuYu = true;
|
|
}
|
|
string text = textBox_DS_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 MyRefresh_TaskData()
|
|
{
|
|
mTaskData.mID_Task = TaskData.mNextID_static;
|
|
mTaskData.mTypeCode_Task = 12;
|
|
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.mPrepare12_DiShanMiDu = 0;
|
|
mXianLuData.mPrepare2_DiShanMiDu = 0;
|
|
for (int i = 0; i < desktop.mXL.mListXianLuData.Count; i++)
|
|
{
|
|
if (mXianLuID == desktop.mXL.mListXianLuData[i].mID_XianLu)
|
|
{
|
|
desktop.mXL.mListXianLuData[i].mPrepare2_DiShanMiDu = 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 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
|
|
{
|
|
Thread thread = new Thread(MyCompute);
|
|
thread.Start();
|
|
}
|
|
}
|
|
|
|
private void MyCompute()
|
|
{
|
|
if (mIndex_ListXianLuData < 0 || mIndex_ListXianLuData >= desktop.mXL.mListXianLuData.Count)
|
|
{
|
|
MyFormSetTitle(this, "线路无效");
|
|
Busy_ButtonOK = false;
|
|
return;
|
|
}
|
|
if (mIndex_ListXianLuData >= desktop.mXL.mListGanTas.Count || desktop.mXL.mListGanTas[mIndex_ListXianLuData] == null || desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData == null)
|
|
{
|
|
MyFormSetTitle(this, "线路杆塔无效");
|
|
Busy_ButtonOK = false;
|
|
return;
|
|
}
|
|
int num = 0;
|
|
try
|
|
{
|
|
MyFormSetTitle(this, "地闪密度进度 = 0/6");
|
|
string text = Application.StartupPath + "\\地闪密度文件夹\\";
|
|
if (!Directory.Exists(text))
|
|
{
|
|
Directory.CreateDirectory(text);
|
|
}
|
|
mThisImageFileName = text + "lightning_density_map.png";
|
|
string text2 = Application.StartupPath + "\\地闪密度图形\\";
|
|
if (!Directory.Exists(text2))
|
|
{
|
|
Directory.CreateDirectory(text2);
|
|
}
|
|
mTargetImageFileName = text2 + desktop.mXL.mListXianLuData[mIndex_ListXianLuData].mName_XianLu + ".png";
|
|
if (File.Exists(mTargetImageFileName))
|
|
{
|
|
File.Delete(mTargetImageFileName);
|
|
}
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
XianLuData xianLuData = desktop.mXL.mListXianLuData[mIndex_ListXianLuData];
|
|
GanTaData ganTaData = desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData[0];
|
|
if (xianLuData.mJLZL_XianLu.Equals("直流"))
|
|
{
|
|
num2 = 3;
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(ganTaData.mTaXing_GanTa))
|
|
{
|
|
num3 = ((ganTaData.mTaXing_GanTa.IndexOf("35") >= 0) ? 35 : ((ganTaData.mTaXing_GanTa.IndexOf("66") >= 0) ? 66 : ((ganTaData.mTaXing_GanTa.IndexOf("110") >= 0) ? 110 : ((ganTaData.mTaXing_GanTa.IndexOf("220") >= 0) ? 220 : ((ganTaData.mTaXing_GanTa.IndexOf("330") >= 0) ? 330 : ((ganTaData.mTaXing_GanTa.IndexOf("500") >= 0) ? 500 : ((ganTaData.mTaXing_GanTa.IndexOf("750") >= 0) ? 750 : ((ganTaData.mTaXing_GanTa.IndexOf("800") >= 0) ? 800 : ((ganTaData.mTaXing_GanTa.IndexOf("1000") >= 0) ? 1000 : 0)))))))));
|
|
switch (num3)
|
|
{
|
|
case 35:
|
|
case 66:
|
|
case 110:
|
|
num2 = 1;
|
|
break;
|
|
case 220:
|
|
case 330:
|
|
num2 = 2;
|
|
break;
|
|
case 500:
|
|
case 750:
|
|
case 800:
|
|
case 1000:
|
|
num2 = 3;
|
|
break;
|
|
}
|
|
}
|
|
if (num3 == 0 || num2 == 0)
|
|
{
|
|
num3 = xianLuData.mDYDJ_XianLu;
|
|
switch (num3)
|
|
{
|
|
case 35:
|
|
case 66:
|
|
case 110:
|
|
num2 = 1;
|
|
break;
|
|
case 220:
|
|
case 330:
|
|
num2 = 2;
|
|
break;
|
|
case 500:
|
|
case 750:
|
|
case 800:
|
|
case 1000:
|
|
num2 = 3;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (num2 < 1 || num2 > 3)
|
|
{
|
|
num2 = 1;
|
|
num3 = 110;
|
|
}
|
|
int num4 = 0;
|
|
num4 = num2 switch
|
|
{
|
|
1 => 2,
|
|
2 => 3,
|
|
3 => 5,
|
|
_ => 2,
|
|
};
|
|
MyFormSetTitle(this, "地闪密度进度 = 1/6");
|
|
string text3 = "";
|
|
text3 = text + "杆塔坐标.csv";
|
|
using (StreamWriter streamWriter = new StreamWriter(text3, append: false, Encoding.Default))
|
|
{
|
|
streamWriter.WriteLine("电压等级,杆塔经度,杆塔纬度");
|
|
for (int i = 0; i < desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData.Count; i++)
|
|
{
|
|
ganTaData = desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData[i];
|
|
streamWriter.WriteLine($"{num3},{ganTaData.mJingDu_GanTa},{ganTaData.mWeiDu_GanTa}");
|
|
}
|
|
}
|
|
MyFormSetTitle(this, "地闪密度进度 = 2/6");
|
|
mPythonEXE_FileName = $"banjin{num2}.exe";
|
|
ProcessStartInfo processStartInfo = null;
|
|
Process process = null;
|
|
int num5 = 0;
|
|
processStartInfo = new ProcessStartInfo();
|
|
processStartInfo.FileName = mPythonEXE_FileName;
|
|
processStartInfo.Arguments = "";
|
|
processStartInfo.WorkingDirectory = text;
|
|
processStartInfo.UseShellExecute = true;
|
|
processStartInfo.CreateNoWindow = true;
|
|
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
try
|
|
{
|
|
process = Process.Start(processStartInfo);
|
|
process.WaitForExit();
|
|
}
|
|
catch (Win32Exception)
|
|
{
|
|
}
|
|
catch (InvalidOperationException)
|
|
{
|
|
}
|
|
num5 = process.ExitCode;
|
|
process = null;
|
|
processStartInfo = null;
|
|
if (num5 != 0)
|
|
{
|
|
MyFormSetTitle(this, $"程序banjin{num2}.exe返回值无效");
|
|
Busy_ButtonOK = false;
|
|
return;
|
|
}
|
|
MyFormSetTitle(this, "地闪密度进度 = 4/6");
|
|
text3 = text + "区域雷击统计_简版.csv";
|
|
try
|
|
{
|
|
if (File.Exists(mThisImageFileName))
|
|
{
|
|
File.Copy(mThisImageFileName, mTargetImageFileName, overwrite: true);
|
|
}
|
|
}
|
|
catch (Exception ex3)
|
|
{
|
|
MyLog.AddLog("FormDiShanMiDu.cs MyCompute() 图片处理异常 e=" + ex3.Message);
|
|
}
|
|
double num6 = 0.0;
|
|
string text4 = "";
|
|
string[] separator = new string[3] { "\r", "\n", "," };
|
|
string[] array = null;
|
|
List<double> list = null;
|
|
if (list == null)
|
|
{
|
|
list = new List<double>();
|
|
}
|
|
list.Clear();
|
|
num = 0;
|
|
using (FileStream fileStream = new FileStream(text3, FileMode.Open, FileAccess.Read, FileShare.None))
|
|
{
|
|
using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8))
|
|
{
|
|
while (!streamReader.EndOfStream)
|
|
{
|
|
text4 = streamReader.ReadLine().Trim();
|
|
if (string.IsNullOrEmpty(text4))
|
|
{
|
|
continue;
|
|
}
|
|
array = text4.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
|
if (array.Length < 7)
|
|
{
|
|
continue;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
num++;
|
|
continue;
|
|
}
|
|
try
|
|
{
|
|
num6 = Convert.ToDouble(array[6].Trim());
|
|
}
|
|
catch (Exception)
|
|
{
|
|
num6 = 0.0;
|
|
}
|
|
list.Add(num6);
|
|
num++;
|
|
}
|
|
streamReader.Close();
|
|
}
|
|
fileStream.Close();
|
|
}
|
|
MyFormSetTitle(this, "地闪密度进度 = 5/6");
|
|
if (list.Count == 0)
|
|
{
|
|
Busy_ButtonOK = false;
|
|
return;
|
|
}
|
|
num = 0;
|
|
for (int j = 0; j < desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData.Count; j++)
|
|
{
|
|
ganTaData = desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData[j];
|
|
if (ganTaData != null)
|
|
{
|
|
if (j / num4 < list.Count)
|
|
{
|
|
ganTaData.mDSMD_GanTa = list[j / num4];
|
|
num++;
|
|
}
|
|
else if (j / num4 >= list.Count)
|
|
{
|
|
ganTaData.mDSMD_GanTa = list[list.Count - 1];
|
|
num++;
|
|
}
|
|
}
|
|
}
|
|
MyFormSetTitle(this, "地闪密度进度 = 6/6");
|
|
list?.Clear();
|
|
list = null;
|
|
}
|
|
catch (Exception ex5)
|
|
{
|
|
MyLog.AddLog("FormDiShanMiDu.cs MyCompute() ex=" + ex5.Message);
|
|
}
|
|
MyFormSetTitle(this, $"完成地闪密度计算 杆塔数={desktop.mXL.mListGanTas[mIndex_ListXianLuData].mListGanTaData.Count} 设置地闪密度数目={num}");
|
|
Busy_ButtonOK = false;
|
|
}
|
|
|
|
private void MyThreadKill()
|
|
{
|
|
Thread.Sleep(10);
|
|
string value = Application.StartupPath + "\\地闪密度文件夹\\";
|
|
Process[] processes = Process.GetProcesses();
|
|
foreach (Process process in processes)
|
|
{
|
|
if (process.ProcessName.Trim().IndexOf("Figure 1") >= 0 && process.StartInfo.WorkingDirectory.StartsWith(value))
|
|
{
|
|
process.Kill();
|
|
}
|
|
}
|
|
Process[] processes2 = Process.GetProcesses();
|
|
foreach (Process process2 in processes2)
|
|
{
|
|
if (process2.MainWindowTitle.Trim().IndexOf("Figure 1") >= 0 && process2.StartInfo.WorkingDirectory.StartsWith(value) && !process2.CloseMainWindow())
|
|
{
|
|
process2.Kill();
|
|
}
|
|
}
|
|
Process[] processes3 = Process.GetProcesses();
|
|
foreach (Process process3 in processes3)
|
|
{
|
|
if (process3.ProcessName.Trim().IndexOf(mPythonEXE_FileName ?? "") >= 0 && process3.StartInfo.WorkingDirectory.StartsWith(value))
|
|
{
|
|
process3.Kill();
|
|
}
|
|
}
|
|
Process[] processes4 = Process.GetProcesses();
|
|
foreach (Process process4 in processes4)
|
|
{
|
|
if (process4.MainWindowTitle.Trim().IndexOf(mPythonEXE_FileName ?? "") >= 0 && process4.StartInfo.WorkingDirectory.StartsWith(value) && !process4.CloseMainWindow())
|
|
{
|
|
process4.Kill();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonShow_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(mTargetImageFileName) && File.Exists(mTargetImageFileName))
|
|
{
|
|
Image image = null;
|
|
image = Image.FromFile(mTargetImageFileName);
|
|
if (image != null)
|
|
{
|
|
pictureBox1.BackgroundImage = image;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
{
|
|
MyFormSetTitle(this, "");
|
|
MyButtonEnabled(buttonCancel, value: false);
|
|
pictureBox1.BackgroundImage = null;
|
|
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 = 2;
|
|
openFileDialog.Multiselect = true;
|
|
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
|
|
{
|
|
mFileName = openFileDialog.FileName;
|
|
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 comboBox_YanXian_QuYu_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (!mAfterInit || Busy_ButtonOK)
|
|
{
|
|
return;
|
|
}
|
|
int selectedIndex = ((ComboBox)sender).SelectedIndex;
|
|
mIndexControl_YanXian_QuYu = selectedIndex;
|
|
YanXian_QuYu = ((ComboBox)sender).SelectedItem.ToString().Trim();
|
|
for (int i = 0; i < comboBox_YanXian_QuYu.Items.Count; i++)
|
|
{
|
|
if (YanXian_QuYu.Equals(comboBox_YanXian_QuYu.Items[i].ToString()))
|
|
{
|
|
Ready_YanXian_QuYu = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void textBox_DS_FileName_Leave(object sender, EventArgs e)
|
|
{
|
|
if (!mAfterInit || Busy_ButtonOK)
|
|
{
|
|
return;
|
|
}
|
|
Ready_CurrentFile = false;
|
|
string text = textBox_DS_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_DS_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();
|
|
this.label3 = new System.Windows.Forms.Label();
|
|
this.comboBox_YanXian_QuYu = new System.Windows.Forms.ComboBox();
|
|
this.label4 = new System.Windows.Forms.Label();
|
|
this.textBox_NumberYears = new System.Windows.Forms.TextBox();
|
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
|
this.buttonShow = new System.Windows.Forms.Button();
|
|
((System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit();
|
|
base.SuspendLayout();
|
|
this.buttonCancel.Location = new System.Drawing.Point(448, 410);
|
|
this.buttonCancel.Name = "buttonCancel";
|
|
this.buttonCancel.Size = new System.Drawing.Size(108, 28);
|
|
this.buttonCancel.TabIndex = 63;
|
|
this.buttonCancel.Text = "取消";
|
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
this.buttonCancel.Click += new System.EventHandler(buttonCancel_Click);
|
|
this.buttonSelect.Location = new System.Drawing.Point(325, 178);
|
|
this.buttonSelect.Name = "buttonSelect";
|
|
this.buttonSelect.Size = new System.Drawing.Size(49, 28);
|
|
this.buttonSelect.TabIndex = 61;
|
|
this.buttonSelect.Text = "选择";
|
|
this.buttonSelect.UseVisualStyleBackColor = true;
|
|
this.buttonSelect.Click += new System.EventHandler(buttonSelect_Click);
|
|
this.buttonOK.Location = new System.Drawing.Point(18, 410);
|
|
this.buttonOK.Name = "buttonOK";
|
|
this.buttonOK.Size = new System.Drawing.Size(108, 28);
|
|
this.buttonOK.TabIndex = 62;
|
|
this.buttonOK.Text = "确定";
|
|
this.buttonOK.UseVisualStyleBackColor = true;
|
|
this.buttonOK.Click += new System.EventHandler(buttonOK_Click);
|
|
this.textBox_DS_FileName.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
|
this.textBox_DS_FileName.Location = new System.Drawing.Point(18, 179);
|
|
this.textBox_DS_FileName.Name = "textBox_DS_FileName";
|
|
this.textBox_DS_FileName.Size = new System.Drawing.Size(290, 26);
|
|
this.textBox_DS_FileName.TabIndex = 60;
|
|
this.textBox_DS_FileName.Leave += new System.EventHandler(textBox_DS_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(12, 30);
|
|
this.comboBox_XianLuName.Name = "comboBox_XianLuName";
|
|
this.comboBox_XianLuName.Size = new System.Drawing.Size(544, 20);
|
|
this.comboBox_XianLuName.TabIndex = 59;
|
|
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(15, 150);
|
|
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(15, 9);
|
|
this.label1.Name = "label1";
|
|
this.label1.Size = new System.Drawing.Size(72, 16);
|
|
this.label1.TabIndex = 58;
|
|
this.label1.Text = "线路名称";
|
|
this.label3.AutoSize = true;
|
|
this.label3.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
|
this.label3.Location = new System.Drawing.Point(18, 208);
|
|
this.label3.Name = "label3";
|
|
this.label3.Size = new System.Drawing.Size(72, 16);
|
|
this.label3.TabIndex = 58;
|
|
this.label3.Text = "计算类型";
|
|
this.comboBox_YanXian_QuYu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
this.comboBox_YanXian_QuYu.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
|
this.comboBox_YanXian_QuYu.FormattingEnabled = true;
|
|
this.comboBox_YanXian_QuYu.Location = new System.Drawing.Point(18, 233);
|
|
this.comboBox_YanXian_QuYu.Name = "comboBox_YanXian_QuYu";
|
|
this.comboBox_YanXian_QuYu.Size = new System.Drawing.Size(356, 20);
|
|
this.comboBox_YanXian_QuYu.TabIndex = 59;
|
|
this.comboBox_YanXian_QuYu.SelectedIndexChanged += new System.EventHandler(comboBox_YanXian_QuYu_SelectedIndexChanged);
|
|
this.label4.AutoSize = true;
|
|
this.label4.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
|
this.label4.Location = new System.Drawing.Point(18, 81);
|
|
this.label4.Name = "label4";
|
|
this.label4.Size = new System.Drawing.Size(104, 16);
|
|
this.label4.TabIndex = 57;
|
|
this.label4.Text = "地闪数据年份";
|
|
this.textBox_NumberYears.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
|
|
this.textBox_NumberYears.Location = new System.Drawing.Point(133, 81);
|
|
this.textBox_NumberYears.Name = "textBox_NumberYears";
|
|
this.textBox_NumberYears.Size = new System.Drawing.Size(108, 26);
|
|
this.textBox_NumberYears.TabIndex = 60;
|
|
this.textBox_NumberYears.Leave += new System.EventHandler(textBox_DS_FileName_Leave);
|
|
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
|
this.pictureBox1.Location = new System.Drawing.Point(12, 56);
|
|
this.pictureBox1.Name = "pictureBox1";
|
|
this.pictureBox1.Size = new System.Drawing.Size(544, 348);
|
|
this.pictureBox1.TabIndex = 64;
|
|
this.pictureBox1.TabStop = false;
|
|
this.buttonShow.Location = new System.Drawing.Point(237, 410);
|
|
this.buttonShow.Name = "buttonShow";
|
|
this.buttonShow.Size = new System.Drawing.Size(108, 28);
|
|
this.buttonShow.TabIndex = 65;
|
|
this.buttonShow.Text = "显示图形";
|
|
this.buttonShow.UseVisualStyleBackColor = true;
|
|
this.buttonShow.Click += new System.EventHandler(buttonShow_Click);
|
|
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
|
|
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
base.ClientSize = new System.Drawing.Size(568, 450);
|
|
base.Controls.Add(this.buttonShow);
|
|
base.Controls.Add(this.pictureBox1);
|
|
base.Controls.Add(this.buttonCancel);
|
|
base.Controls.Add(this.buttonSelect);
|
|
base.Controls.Add(this.buttonOK);
|
|
base.Controls.Add(this.textBox_NumberYears);
|
|
base.Controls.Add(this.textBox_DS_FileName);
|
|
base.Controls.Add(this.comboBox_YanXian_QuYu);
|
|
base.Controls.Add(this.comboBox_XianLuName);
|
|
base.Controls.Add(this.label4);
|
|
base.Controls.Add(this.label2);
|
|
base.Controls.Add(this.label3);
|
|
base.Controls.Add(this.label1);
|
|
base.Name = "FormDiShanMiDu";
|
|
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
this.Text = "FormDiShanMiDu";
|
|
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FormDiShanMiDu_FormClosing);
|
|
base.Load += new System.EventHandler(FormDiShanMiDu_Load);
|
|
((System.ComponentModel.ISupportInitialize)this.pictureBox1).EndInit();
|
|
base.ResumeLayout(false);
|
|
base.PerformLayout();
|
|
}
|
|
}
|