using DevExpress.XtraEditors;
|
using Eventech.Model;
|
using System.IO;
|
using System.Windows.Forms;
|
|
namespace TProduct.WinFrmUI.TPump
|
{
|
/// <summary>
|
/// 性能测试
|
/// </summary>
|
public partial class FeatTestViewMainPage
|
{
|
private void barBtn导出测试报告_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ExportReport();
|
}
|
public void ExportReport()
|
{
|
SetTestReportInfoDlg dlg = new SetTestReportInfoDlg();
|
dlg.SetBindingData(this._testProject);
|
if (dlg.ShowDialog() != DialogResult.OK)
|
return;
|
|
var file_path = dlg.GetFilePah();
|
|
TProduct.DataFile.PumpReport.TestReportFileExcelBase file_helepr = null;
|
var tempalte = TProduct.UserSetting.Setting.Export.TemplatePumpFeatReport;
|
if (tempalte == 0)
|
{
|
if (TProduct.CorpConfig.Instance.CorpFlag == Model.eCorpFlag.LIFU)
|
{
|
file_helepr = new TProduct.DataFile.PumpReport.TestReportFileLIFU1();
|
}
|
else
|
{
|
MessageBox.Show("还未定义企业模板,如需此功能, 请与上海义维联系");
|
return;
|
}
|
}
|
else if (tempalte == 1)
|
{
|
file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT1();
|
}
|
else if (tempalte == 2)
|
{
|
file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT2();
|
}
|
else if (tempalte == 3)
|
{
|
file_helepr = new TProduct.DataFile.PumpReport.TestReportFileT3();
|
}
|
else
|
{
|
return;
|
}
|
|
var user_name = new BLL.LoginUser().GetRealNameByID(this._testProject.CreateUserID);
|
file_helepr.SetPumpGraph(GetFeatChartImage());
|
file_helepr.RecordDataSortType = dlg.RecordSortType;
|
file_helepr.SetMaxEtaPt(this._chartMainCtrl.GetMaxEtaPt());
|
file_helepr.SetBindingData(
|
this._currentPump,
|
this._currentPart,
|
this._testProject,
|
this._testItems, _testJudgeResults,
|
user_name
|
);
|
|
if (file_helepr.Create(file_path, (info, type) =>
|
{
|
MessageBox.Show(info);
|
}) == null)
|
{
|
TProduct.WinFrmUI.FileMessageBox.Show(file_path, TProduct.UserSetting.Localization.Current);
|
}
|
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void bbi导出性能曲线图_CAD_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ExportChart_Cad();
|
}
|
public void ExportChart_Cad()
|
{
|
if (_featTestItem == null)
|
return;
|
TProduct.PumpGraph.Dxf.LxpFeatChart chartCad =
|
PumpGraph.Dxf.LxpFeatChart.Build(TProduct.UserSetting.Setting.Export.TemplatePumpChartCad);
|
chartCad.SetCoordinate(new LxpCoordinateParas(_featTestItem.CoordinateParas));
|
chartCad.SetFeatPointRecords(this._currentPump, this._allRecords);
|
chartCad.SetRatedParas(this._ratedParas, this._testJudgeItems);
|
//chartImg.SetDefaultColor();
|
chartCad.InitialTemplate(TProduct.DataFolderParas.FullPath, Eventech.Model.eLocalizationType.zhCN, null);
|
SaveFileDialog saveFileDlg = new SaveFileDialog();
|
saveFileDlg.Filter = "dwg 文件(*.dwg)|*.dwg";
|
if (saveFileDlg.ShowDialog() != DialogResult.OK)
|
return;
|
|
var ret = chartCad.CreateDxf(saveFileDlg.FileName);
|
|
TProduct.WinFrmUI.FileMessageBox.Show(saveFileDlg.FileName);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void bbi导出性能曲线图_图片_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ExportChart_Image();
|
}
|
public void ExportChart_Image()
|
{
|
if (_featTestItem == null)
|
return;
|
SaveFileDialog saveFileDlg = new SaveFileDialog();
|
saveFileDlg.Filter = "图片文件(*.png)|*.png";
|
if (saveFileDlg.ShowDialog() != DialogResult.OK)
|
return;
|
var chartImg = GetFeatChartImage();
|
var img = chartImg.CreateImage();
|
img.Save(saveFileDlg.FileName);
|
TProduct.WinFrmUI.FileMessageBox.Show(saveFileDlg.FileName);
|
}
|
|
|
private TProduct.PumpGraph.Picture.LxpFeatChart GetFeatChartImage()
|
{
|
var chartImg =
|
TProduct.PumpGraph.Picture.LxpFeatChart.Build(
|
TProduct.UserSetting.Setting.Export.TemplatePumpChartImage);
|
|
chartImg.SetCoordinate(new LxpCoordinateParas(_featTestItem.CoordinateParas));
|
chartImg.SetFeatPointRecords(this._currentPump, this._allRecords);
|
chartImg.SetRatedParas(this._ratedParas, this._testJudgeItems);
|
chartImg.SetDockType(PumpGraph.Picture.FeatChart.eDockType.单独导出, 0, 0);
|
chartImg.SetExtendCurveInfoQH(_chartMainCtrl.GetExtendCurveInfoQH());
|
chartImg.SetDefaultColor();
|
chartImg.IsDispCurveName = TProduct.UserSetting.Setting.PumpChartImageDisp.IsDispCurveName;
|
if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQH))
|
{
|
chartImg.SetColorQH(
|
System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQH));
|
}
|
if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQE))
|
{
|
chartImg.SetColorQE(
|
System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQE));
|
}
|
if (!string.IsNullOrEmpty(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQP))
|
{
|
chartImg.SetColorQP(
|
System.Drawing.ColorTranslator.FromHtml(TProduct.UserSetting.Setting.PumpChartImageDisp.ColorQP));
|
}
|
return chartImg;
|
}
|
|
|
private void bbi导出性能曲线图_XML_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
ExportChart_XML();
|
}
|
public void ExportChart_XML()
|
{
|
SaveFileDialog saveFileDlg = new SaveFileDialog();
|
saveFileDlg.Filter = "XML 文件(*.xml)|*.xml";
|
if (saveFileDlg.ShowDialog() != DialogResult.OK)
|
return;
|
var strXmlPath = saveFileDlg.FileName;
|
string fileName = Path.GetFileName(strXmlPath);
|
for (int i = 0; i < InvalidFileNameChar.Length; i++)
|
{
|
if (fileName.Contains(InvalidFileNameChar[i].ToString()))
|
{
|
XtraMessageBox.Show(string.Format("{0},含有特殊符号,{1},",
|
"不能作为文件名,请修改",
|
InvalidFileNameChar[i]));
|
return;
|
}
|
}
|
|
TProduct.DataFile.YwGeneralFile.FileV1 fileXML_helepr = null;
|
fileXML_helepr = new TProduct.DataFile.YwGeneralFile.FileV1();
|
|
fileXML_helepr.SetBindingData(
|
this._currentPump,
|
this._currentPart,
|
this._testProject);
|
|
if (fileXML_helepr.CreatXmlFile(strXmlPath, (info, type) =>
|
{
|
MessageBox.Show("失败");
|
}) == null)
|
{
|
//MessageBox.Show("生成成功");
|
TProduct.WinFrmUI.FileMessageBox.Show(strXmlPath, TProduct.UserSetting.Localization.Current);
|
}
|
|
}
|
|
string InvalidFileNameChar = "/:*?\"<>|";
|
private bool CheckInvalidFileName(string fileName)
|
{
|
for (int i = 0; i < InvalidFileNameChar.Length; i++)
|
{
|
if (fileName.Contains(InvalidFileNameChar[i].ToString()))
|
{
|
XtraMessageBox.Show(string.Format("{0},含有特殊符号,{1},",
|
"不能作为文件名,请修改",
|
InvalidFileNameChar[i]));
|
return false;
|
}
|
}
|
return true;
|
}
|
}
|
}
|