1、添加2个自定义控件:chartTC、TreeViewTc; 2、修复了一些bug,完善了功能;3、更新了gitignore,将bin等目录忽略;

This commit is contained in:
tangchao0503
2022-06-16 13:26:55 +08:00
parent b43227dc58
commit f36c5eaa39
50 changed files with 13043 additions and 3770 deletions

View File

@ -172,9 +172,13 @@ namespace mainProgram
{
public ProjectManager(string xx)
{
mProjectPath = xx;
string sourceFileName = Path.GetFileName(xx);//获取文件名
mProjectFile = xx;
mProjectPath = Path.GetDirectoryName(xx);
}
private string mProjectFile;
private string mProjectPath;
private string mMetadataPath;
private string mRawPath;
@ -241,18 +245,37 @@ namespace mainProgram
}
}
public void CreateProject(string calFilePath, string dataPath)
//返回值0代表成功1代表定标文件夹有错误2代表数据文件夹有错误3代表工程路径有错误
public int CreateProject(string calFilePath, string dataPath)
{
if (mProjectPath.Length == 0)
{
return;
return 3;
}
DelectDir(mProjectPath);//删除工程路径下的所有内容
CreateProjectStructure();
CopyCalFiles2Project(calFilePath);//复制定标文件到工程结构对应文件夹
CopyFiles2Project(dataPath);//复制原始数据文件到工程结构对应文件夹
CreateProjectStructure();
bool re1 = CopyCalFiles2Project(calFilePath);//复制定标文件到工程结构对应文件夹
if (!re1)
{
DelectDir(mProjectPath);
return 1;
}
mCsvFileCount = 0;//类的变量
bool re2 = CopyFiles2Project(dataPath, ref mCsvFileCount);//复制原始数据文件到工程结构对应文件夹
if (!re2)
{
DelectDir(mProjectPath);
return 2;
}
//将文件个数写入到可执行文件所在目录 → 打开工程时需要读取
BinaryWriter bw = new BinaryWriter(new FileStream(mProjectFile, FileMode.Create));//Path.Combine(mMetadataPath, "CsvFileCount.dat")
bw.Write(mCsvFileCount);
bw.Close();
@ -269,7 +292,7 @@ namespace mainProgram
////删除指定节点信息
//DeleteXmlInformation(myXMLFilePath);
return 0;
}
public bool OpenProject()
@ -285,7 +308,7 @@ namespace mainProgram
if (Directory.Exists(mMetadataPath) & Directory.Exists(mRawPath) & Directory.Exists(mRadPath) & Directory.Exists(mSifPath))
{
BinaryReader br = new BinaryReader(new FileStream(Path.Combine(mMetadataPath, "CsvFileCount.dat"), FileMode.Open));
BinaryReader br = new BinaryReader(new FileStream(mProjectFile, FileMode.Open));
mCsvFileCount = br.ReadInt32();
br.Close();
@ -502,22 +525,23 @@ namespace mainProgram
}
//文件复制实现https://www.cnblogs.com/sun-shadow/p/7553556.html
public void CopyFiles2Project(string sourceFolderName)//
public bool CopyFiles2Project(string sourceFolderName, ref int fileCounter)//
{
if (Directory.Exists(mRawPath))
{
DelectDir(mRawPath);
}
mCsvFileCount = 0;
CopySubFun(sourceFolderName, mRawPath, true);//因为此函数会递归,所以把它摘出来
bool re = CopySubFun2(sourceFolderName, mRawPath, true, ref mCsvFileCount);//因为此函数会递归,所以把它摘出来
return re;
}
public void CopyCalFiles2Project(string sourceFolderName)
public bool CopyCalFiles2Project(string sourceFolderName)
{
if (!Directory.Exists(sourceFolderName))
{
return;
return false;
}
if (!Directory.Exists(mMetadataPath))
{
@ -526,6 +550,7 @@ namespace mainProgram
string[] sourceFilesPath = Directory.GetFileSystemEntries(sourceFolderName);
int fileCounterCopied = 0;
for (int i = 0; i < sourceFilesPath.Length; i++)
{
string sourceFilePath = sourceFilesPath[i];
@ -536,27 +561,36 @@ namespace mainProgram
string dest = mMetadataPath;
string sourceFileName = Path.GetFileName(sourceFilePath);//获取文件名
File.Copy(sourceFilePath, Path.Combine(dest, sourceFileName), true);
}
else if (Directory.Exists(sourceFilePath))//是文件夹,拷贝文件夹;并递归
{
string lastDirectory = forlders[forlders.Length - 1];
string dest = Path.Combine(mMetadataPath, lastDirectory);
if (!Directory.Exists(dest))
{
Directory.CreateDirectory(dest);
}
CopySubFun(sourceFilePath, dest, true);
fileCounterCopied++;
}
//因为定标文件不能够放在
//else if (Directory.Exists(sourceFilePath))//是文件夹,拷贝文件夹;并递归
//{
// string lastDirectory = forlders[forlders.Length - 1];
// string dest = Path.Combine(mMetadataPath, lastDirectory);
// if (!Directory.Exists(dest))
// {
// Directory.CreateDirectory(dest);
// }
// CopySubFun(sourceFilePath, dest, true);
//}
}
if (fileCounterCopied == 0)
{
return false;
}
return true;
}
private void CopySubFun(string sourceFolderName, string destFolderName, bool overwrite)//因为此函数会递归,所以把它摘出来
private bool CopySubFun(string sourceFolderName, string destFolderName, bool overwrite)//因为此函数会递归,所以把它摘出来
{
if (!Directory.Exists(sourceFolderName))
{
return;
return false;
}
if (!Directory.Exists(destFolderName))
{
@ -591,11 +625,67 @@ namespace mainProgram
CopySubFun(sourceFilePath, dest, overwrite);
}
}
return true;
}
//将文件个数写入到可执行文件所在目录 → 打开工程时需要读取
BinaryWriter bw = new BinaryWriter(new FileStream(Path.Combine(mMetadataPath, "CsvFileCount.dat"), FileMode.Create));
bw.Write(mCsvFileCount);
bw.Close();
private bool CopySubFun2(string sourceFolderName, string destFolderName, bool overwrite, ref int fileCounter)//不使用递归
{
if (!Directory.Exists(sourceFolderName))
{
return false;
}
if (!Directory.Exists(destFolderName))
{
Directory.CreateDirectory(destFolderName);
}
string[] files = Directory.GetFiles(sourceFolderName);
if (files.Length>0)
{
return false;
}
string[] sourceForldersPath = Directory.GetFileSystemEntries(sourceFolderName);
for (int i = 0; i < sourceForldersPath.Length; i++)
{
string sourceForlder = sourceForldersPath[i];
string[] forlders = sourceForlder.Split('\\');
string destFolderName2 = Path.Combine(destFolderName, forlders[forlders.Length - 1]);
if (File.Exists(sourceForlder))//如果是文件代表用户选择的dn数据文件夹结构有问题
{
return false;
}
if (!Directory.Exists(destFolderName2))
{
Directory.CreateDirectory(destFolderName2);
}
string[] filesPath = Directory.GetFileSystemEntries(sourceForlder);
for (int j = 0; j < filesPath.Length; j++)//必须按照源文件夹结构!!!!!!
{
string filePath = filesPath[j];
if (Directory.Exists(filePath))//如果是文件夹代表用户选择的dn数据文件夹结构有问题
{
return false;
}
string sourceFileName = Path.GetFileName(filePath);//获取文件名
File.Copy(filePath, Path.Combine(destFolderName2, sourceFileName), overwrite);
//统计文件个数
fileCounter++;
}
}
if (fileCounter == 0)
{
return false;
}
return true;
}
public void DelectDir(string srcPath)
@ -936,14 +1026,34 @@ namespace mainProgram
Array.Sort(df);
}
public int GetDateFolderCount()
{
FindTimespan();
return df.Length;
}
public string GetMinDate()
{
return df[0].mDateFolder;
if (df.Length == 0)
{
return null;
}
else
{
return df[0].mDateFolder;
}
}
public string GetMaxDate()
{
return df[df.Length - 1].mDateFolder;
if (df.Length == 0)
{
return null;
}
else
{
return df[df.Length - 1].mDateFolder;
}
}
public void CopyWantedFiles(string minTime, string maxTime)
@ -1006,22 +1116,10 @@ namespace mainProgram
destFileName = sourceFileName.Substring(firstIndex);
}
if (File.Exists(sourceFilePath))//是文件,直接拷贝
{
File.Copy(sourceFilePath, Path.Combine(destFolderPath, sourceFolderName + destFileName), overwrite);
}
else if (Directory.Exists(sourceFilePath))//是文件夹,拷贝文件夹;并递归 → 减而治之
{
string lastDirectory = forlders[forlders.Length - 1];
string dest = Path.Combine(destFolderPath, lastDirectory);
if (!Directory.Exists(dest))
{
Directory.CreateDirectory(dest);
}
CopySubFun(sourceFilePath, dest, overwrite);
}
}
}