using DevExpress.Charts.Native;
|
using DevExpress.Utils;
|
using DevExpress.XtraCharts;
|
using DevExpress.XtraReports.UI;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport
|
{
|
public XtraReport1()
|
{
|
InitializeComponent();
|
}
|
|
private SimulationPrintViewModel _printViewModel;
|
|
public void SetBingdingData(SimulationPrintViewModel vm)
|
{
|
// A4设置 827 1169
|
this.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4;
|
this.Margins = new DevExpress.Drawing.DXMargins(50, 50, 50, 50);
|
|
// 内容宽度
|
float contentWidth = 727F; // 内容宽度
|
float firstCaptionHeight = 30F; // 一级标题高度
|
float pageHeight = 1069F; // 页面可用高度
|
float currentY = 0F; // 当前Y坐标
|
|
#region 页眉
|
|
var labForCorp = new XRLabel();
|
labForCorp.Name = "页眉";
|
labForCorp.Text = "杭州科维节能技术股份有限公司";
|
labForCorp.Multiline = true;
|
labForCorp.LocationFloat = new DevExpress.Utils.PointFloat(482F, 16F);
|
labForCorp.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
labForCorp.SizeF = new System.Drawing.SizeF(236F, 24F);
|
labForCorp.StylePriority.UseTextAlignment = false;
|
labForCorp.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
|
this.TopMargin.Controls.Add(labForCorp);
|
|
#endregion 页眉
|
|
#region 页脚
|
|
var pageForCurrentNum = new XRPageInfo();
|
pageForCurrentNum.LocationFloat = new DevExpress.Utils.PointFloat(617F, 10.00001F);
|
pageForCurrentNum.Name = "页脚";
|
pageForCurrentNum.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
pageForCurrentNum.SizeF = new System.Drawing.SizeF(100F, 23F);
|
pageForCurrentNum.StylePriority.UseTextAlignment = false;
|
pageForCurrentNum.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
|
pageForCurrentNum.TextFormatString = "第{0}页";
|
this.BottomMargin.Controls.Add(pageForCurrentNum);
|
|
#endregion 页脚
|
|
#region 标题
|
|
var labForTitle = new XRLabel();
|
labForTitle.AnchorHorizontal = ((DevExpress.XtraReports.UI.HorizontalAnchorStyles)((DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right)));
|
labForTitle.Font = new DevExpress.Drawing.DXFont("Arial", 15F, DevExpress.Drawing.DXFontStyle.Bold);
|
labForTitle.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY);
|
labForTitle.Multiline = true;
|
labForTitle.Name = "labTitle";
|
labForTitle.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
|
labForTitle.SizeF = new System.Drawing.SizeF(727F, 50F);
|
labForTitle.StylePriority.UseFont = false;
|
labForTitle.StylePriority.UseTextAlignment = false;
|
labForTitle.Text = $"{vm.Project.Name}项目节能报告";
|
labForTitle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
|
this.Detail.Controls.Add(labForTitle);
|
currentY += 50F;
|
|
#endregion 标题
|
|
#region 一、项目概述
|
|
var labForDescription = CreateFirstCaption("一、项目概述", contentWidth, firstCaptionHeight, 0F, currentY);
|
this.Detail.Controls.Add(labForDescription);
|
currentY += firstCaptionHeight;
|
|
#endregion 一、项目概述
|
|
#region 项目概述内容
|
|
var labForDescriptionContent = new XRLabel();
|
labForDescriptionContent.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right);
|
labForDescriptionContent.Font = new DevExpress.Drawing.DXFont("Arial", 10F);
|
labForDescriptionContent.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY);
|
labForDescriptionContent.Multiline = true;
|
labForDescriptionContent.Name = "labForDescriptionContent";
|
labForDescriptionContent.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
|
labForDescriptionContent.SizeF = new System.Drawing.SizeF(727F, 100F);
|
labForDescriptionContent.StylePriority.UseFont = false;
|
labForDescriptionContent.StylePriority.UseTextAlignment = false;
|
labForDescriptionContent.Text = $" {vm.Project.Description}";
|
labForDescriptionContent.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
|
this.Detail.Controls.Add(labForDescriptionContent);
|
currentY += 100F;
|
|
#endregion 项目概述内容
|
|
// 二、水泵明细
|
var labForPumpList = new XRLabel();
|
labForPumpList.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right);
|
labForPumpList.Font = new DevExpress.Drawing.DXFont("Arial", 12F, DevExpress.Drawing.DXFontStyle.Bold);
|
labForPumpList.LocationFloat = new DevExpress.Utils.PointFloat(0F, currentY);
|
labForPumpList.Multiline = true;
|
labForPumpList.Name = "labForPumpList";
|
labForPumpList.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
labForPumpList.SizeF = new System.Drawing.SizeF(727F, 25F);
|
labForPumpList.StylePriority.UseFont = false;
|
labForPumpList.StylePriority.UseTextAlignment = false;
|
labForPumpList.Text = "二、水泵明细";
|
labForPumpList.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
|
this.Detail.Controls.Add(labForPumpList);
|
currentY += 25F;
|
|
// 水泵明细内容
|
if (vm.PumpList != null && vm.PumpList.Count > 0)
|
{
|
// 创建 XRTable
|
var tableForPumpList = new XRTable();
|
tableForPumpList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
tableForPumpList.SizeF = new SizeF(727F, 30F + vm.PumpList.Count * 25F); // 设置大小
|
|
// 创建表头行
|
XRTableRow headerRowPumpList = new XRTableRow();
|
headerRowPumpList.BackColor = Color.LightGray; // 设置背景颜色
|
|
// 添加表头列
|
headerRowPumpList.Cells.Add(CreateTableCell("名称", 100));
|
headerRowPumpList.Cells.Add(CreateTableCell("编码", 100));
|
headerRowPumpList.Cells.Add(CreateTableCell("额定流量", 100));
|
headerRowPumpList.Cells.Add(CreateTableCell("额定扬程", 100));
|
headerRowPumpList.Cells.Add(CreateTableCell("额定功率(KW)", 100));
|
headerRowPumpList.Cells.Add(CreateTableCell("额定转速", 100));
|
|
// 将表头行添加到表格
|
tableForPumpList.Rows.Add(headerRowPumpList);
|
|
// 遍历水泵
|
foreach (var pump in vm.PumpList)
|
{
|
// 创建数据行
|
var dataRow = new XRTableRow();
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.Name,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.Code,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.RatedQ.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.RatedH.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.RatedP.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = pump.RatedN.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
tableForPumpList.Rows.Add(dataRow);
|
}
|
|
// 将表格添加到Detail
|
this.Detail.Controls.Add(tableForPumpList);
|
currentY += tableForPumpList.HeightF;
|
//currentY += vm.PumpList.Count*10;
|
}
|
|
var labForWorking = CreateFirstCaption("三、工况视图", contentWidth, firstCaptionHeight, 0F, currentY);
|
this.Detail.Controls.Add(labForWorking);
|
currentY += firstCaptionHeight;
|
var labForAccuracy = CreateFirstCaption("(1)、精度评估", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForAccuracy);
|
currentY += firstCaptionHeight;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
/*XRChart chart = new XRChart();
|
chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
chart.WidthF = contentWidth;
|
chart.HeightF = 300F;
|
|
// 创建一个线系列
|
Series series = new Series("Series1", ViewType.Spline);
|
// 添加数据点
|
foreach (var item in working.PumpAnaly.Items[0].RatedCurveQH)
|
{
|
series.Points.Add(new SeriesPoint(item.X, item.Y));
|
}
|
chart.Series.Add(series);
|
Series series2 = new Series("Series2", ViewType.Spline);
|
// 添加数据点
|
foreach (var item in working.PumpAnaly.Items[0].CurrentCurveQE)
|
{
|
series2.Points.Add(new SeriesPoint(item.X, item.Y));
|
}
|
chart.Series.Add(series2);
|
Series series3 = new Series("Series3", ViewType.Spline);
|
// 添加数据点
|
foreach (var item in working.PumpAnaly.Items[0].CurrentCurveQP)
|
{
|
series3.Points.Add(new SeriesPoint(item.X, item.Y));
|
}
|
chart.Series.Add(series3);
|
|
Detail.Controls.Add(chart);
|
currentY += chart.HeightF;*/
|
/* var accuracyFlowChart = CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 250F, 300F, currentY);
|
if (currentY + accuracyFlowChart.HeightF > pageHeight)
|
{
|
accuracyFlowChart.LocationF = new DevExpress.Utils.PointFloat(accuracyFlowChart.LocationF.X, currentY);
|
}
|
Detail.Controls.Add(accuracyFlowChart);
|
currentY += accuracyFlowChart.HeightF;
|
|
var accuracyPressChart = CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 250F, 513F, currentY);
|
if (currentY + accuracyPressChart.HeightF > pageHeight)
|
{
|
accuracyPressChart.LocationF = new DevExpress.Utils.PointFloat(accuracyPressChart.LocationF.X, currentY);
|
}
|
Detail.Controls.Add(accuracyPressChart);
|
currentY += accuracyPressChart.HeightF;*/
|
var accuracyScaleChart = CreateAccuracyScale(working.Accuracy.Scale, 300F, 230F, currentY);
|
Detail.Controls.Add(accuracyScaleChart);
|
var accuracyFlowChart = CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 230F, 300F, currentY);
|
Detail.Controls.Add(accuracyFlowChart);
|
var accuracyPressChart = CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 230F, 513F, currentY);
|
Detail.Controls.Add(accuracyPressChart);
|
currentY += accuracyScaleChart.HeightF;
|
}
|
currentY += 20F;
|
}
|
var labForAccuracyList = CreateFirstCaption("(1.1)、评估列表", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForAccuracyList);
|
currentY += firstCaptionHeight;
|
|
#region 评估列表
|
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.Accuracy.Items != null && working.Accuracy.Items.Count > 0)
|
{ // 创建 XRTable
|
var tableForAccuracyList = new XRTable();
|
tableForAccuracyList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
tableForAccuracyList.SizeF = new SizeF(727F, 30F + working.Accuracy.Items.Count * 25F); // 设置大小
|
|
// 创建表头行
|
XRTableRow headerRowAccuracyList = new XRTableRow();
|
headerRowAccuracyList.BackColor = Color.LightGray; // 设置背景颜色
|
|
// 添加表头列
|
headerRowAccuracyList.Cells.Add(CreateTableCell("评估构件", 100));
|
headerRowAccuracyList.Cells.Add(CreateTableCell("评估项", 100));
|
headerRowAccuracyList.Cells.Add(CreateTableCell("监测值", 100));
|
headerRowAccuracyList.Cells.Add(CreateTableCell("计算值", 100));
|
headerRowAccuracyList.Cells.Add(CreateTableCell("评估误差", 100));
|
|
// 将表头行添加到表格
|
tableForAccuracyList.Rows.Add(headerRowAccuracyList);
|
|
foreach (var item in working.Accuracy.Items)
|
{
|
// 创建数据行
|
var dataRow = new XRTableRow();
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.EvaluateName,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.EvaluateItem,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.MonitorValue.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CalcuValue.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.EvaluateError?.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
tableForAccuracyList.Rows.Add(dataRow);
|
}
|
// 将表格添加到Detail
|
this.Detail.Controls.Add(tableForAccuracyList);
|
currentY += tableForAccuracyList.HeightF;
|
}
|
}
|
currentY += 20F;
|
}
|
|
#endregion 评估列表
|
|
#region 水泵分析
|
|
var labForPump = CreateFirstCaption("(2)、水泵分析", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForPump);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.PumpAnaly != null && working.PumpAnaly.Items != null && working.PumpAnaly.Items.Count > 0)
|
{
|
foreach (var item in working.PumpAnaly.Items)
|
{
|
var label = CreateFirstCaption(item.Name, contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(label);
|
currentY += 20F;
|
|
XRChart chart = new XRChart();
|
((System.ComponentModel.ISupportInitialize)(chart)).BeginInit();
|
chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
chart.WidthF = contentWidth;
|
chart.HeightF = 700F;
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
// 创建 XY 图表
|
XYDiagram xyDiagram = new XYDiagram();
|
((System.ComponentModel.ISupportInitialize)(xyDiagram)).BeginInit();
|
// 设置 X 轴主要网格线可见
|
xyDiagram.AxisX.GridLines.Visible = true;
|
// 设置 X 轴主要刻度间隔,可根据需求调整该值,值越小网格越密
|
xyDiagram.AxisX.Tickmarks.Thickness = 1;
|
// 设置 Y 轴主要网格线可见
|
xyDiagram.AxisY.GridLines.Visible = true;
|
// 设置 Y 轴主要刻度间隔,可根据需求调整该值,值越小网格越密
|
xyDiagram.AxisX.Tickmarks.Thickness = 1;
|
|
// 配置主 X 轴
|
xyDiagram.AxisX.Title.Text = "流量(m³/h)";
|
xyDiagram.AxisX.Title.Visibility = DefaultBoolean.True;
|
xyDiagram.AxisX.Visibility = DefaultBoolean.True;
|
|
// 配置主 Y 轴
|
xyDiagram.AxisY.Title.Text = "扬程/m";
|
xyDiagram.AxisY.Title.Visibility = DefaultBoolean.True;
|
xyDiagram.AxisY.Visibility = DefaultBoolean.True;
|
|
// 创建两个面板
|
XYDiagramPane pane1 = new XYDiagramPane();
|
pane1.Name = "Pane 1";
|
xyDiagram.Panes.Add(pane1);
|
|
XYDiagramPane pane2 = new XYDiagramPane();
|
pane2.Name = "Pane 2";
|
xyDiagram.Panes.Add(pane2);
|
|
// 创建次要 Y 轴
|
SecondaryAxisY secondaryAxisY1 = new SecondaryAxisY("Secondary Y-Axis 1");
|
secondaryAxisY1.Title.Text = "功率(KW)";
|
secondaryAxisY1.Title.Visibility = DefaultBoolean.True;
|
secondaryAxisY1.Visibility = DefaultBoolean.True;
|
secondaryAxisY1.GridLines.Visible = true;
|
secondaryAxisY1.Tickmarks.Thickness = 1;
|
secondaryAxisY1.GridLines.Color = Color.LightGray;
|
|
xyDiagram.SecondaryAxesY.Add(secondaryAxisY1);
|
|
SecondaryAxisY secondaryAxisY2 = new SecondaryAxisY("Secondary Y-Axis 2");
|
secondaryAxisY2.Title.Text = "效率(%)";
|
secondaryAxisY2.Title.Visibility = DefaultBoolean.True;
|
secondaryAxisY2.Visibility = DefaultBoolean.True;
|
secondaryAxisY2.GridLines.Visible = true;
|
secondaryAxisY2.Tickmarks.Thickness = 1;
|
secondaryAxisY2.GridLines.Color = Color.LightGray;
|
|
xyDiagram.SecondaryAxesY.Add(secondaryAxisY2);
|
|
chart.Diagram = xyDiagram;
|
((System.ComponentModel.ISupportInitialize)(xyDiagram)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(chart)).EndInit();
|
|
// 创建第一个系列
|
Series series1 = new Series("Series 1", ViewType.Spline);
|
foreach (var qh in item.RatedCurveQH)
|
{
|
series1.Points.Add(new SeriesPoint(qh.X, qh.Y));
|
}
|
series1.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series1);
|
// 创建第二个系列
|
Series series2 = new Series("Series 2", ViewType.Spline);
|
foreach (var qe in item.RatedCurveQE)
|
{
|
series2.Points.Add(new SeriesPoint(qe.X, qe.Y));
|
}
|
((XYDiagramSeriesViewBase)series2.View).Pane = pane2;
|
((XYDiagramSeriesViewBase)series2.View).AxisY = secondaryAxisY2;
|
series2.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series2);
|
// 创建第三个系列
|
Series series3 = new Series("Series 3", ViewType.Spline);
|
foreach (var qp in item.RatedCurveQP)
|
{
|
series3.Points.Add(new SeriesPoint(qp.X, qp.Y));
|
}
|
((XYDiagramSeriesViewBase)series3.View).Pane = pane1;
|
((XYDiagramSeriesViewBase)series3.View).AxisY = secondaryAxisY1;
|
series3.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series3);
|
|
Detail.Controls.Add(chart);
|
currentY += chart.HeightF;
|
}
|
}
|
}
|
currentY += 20F;
|
}
|
|
#endregion 水泵分析
|
|
#region 监测分析
|
|
var labForMonitor = CreateFirstCaption("(3)、监测分析", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForMonitor);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.MonitorAnaly.Items != null && working.MonitorAnaly.Items.Count > 0)
|
{ // 创建 XRTable
|
var tableForMonitorList = new XRTable();
|
tableForMonitorList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
tableForMonitorList.SizeF = new SizeF(727F, 30F + working.MonitorAnaly.Items.Count * 25F); // 设置大小
|
|
// 创建表头行
|
XRTableRow headerRowMonitorList = new XRTableRow();
|
headerRowMonitorList.BackColor = Color.LightGray; // 设置背景颜色
|
|
// 添加表头列
|
headerRowMonitorList.Cells.Add(CreateTableCell("构件", 100));
|
headerRowMonitorList.Cells.Add(CreateTableCell("属性", 100));
|
headerRowMonitorList.Cells.Add(CreateTableCell("计算值", 100));
|
headerRowMonitorList.Cells.Add(CreateTableCell("单位", 100));
|
|
// 将表头行添加到表格
|
tableForMonitorList.Rows.Add(headerRowMonitorList);
|
|
foreach (var item in working.MonitorAnaly.Items)
|
{
|
// 创建数据行
|
var dataRow = new XRTableRow();
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.VisualName,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.PropName,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CalcuValue?.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.UnitName,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
tableForMonitorList.Rows.Add(dataRow);
|
}
|
// 将表格添加到Detail
|
this.Detail.Controls.Add(tableForMonitorList);
|
currentY += tableForMonitorList.HeightF;
|
currentY += 20F;
|
}
|
}
|
}
|
|
#endregion 监测分析
|
|
#region 能耗分析
|
|
var labForEnergyAnaly = CreateFirstCaption("(4)、能耗分析", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForEnergyAnaly);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.EnergyAnaly != null)
|
{
|
if (working.EnergyAnaly.Items != null && working.EnergyAnaly.Items.Count > 0)
|
{
|
var group = working.EnergyAnaly.Items.GroupBy(x => x.BeginGroup).ToArray();
|
foreach (var item in group)
|
{
|
var label = CreateFirstCaption(item.Key, contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(label);
|
currentY += 20F;
|
|
XRChart chart = new XRChart();
|
((System.ComponentModel.ISupportInitialize)(chart)).BeginInit();
|
chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
chart.WidthF = contentWidth;
|
chart.HeightF = 600F;
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
// 创建 XY 图表
|
XYDiagram xyDiagram = new XYDiagram();
|
((System.ComponentModel.ISupportInitialize)(xyDiagram)).BeginInit();
|
|
// 设置 X 轴主要网格线可见
|
xyDiagram.AxisX.GridLines.Visible = true;
|
// 设置 X 轴主要刻度间隔,可根据需求调整该值,值越小网格越密
|
xyDiagram.AxisX.Tickmarks.Thickness = 1;
|
// 设置 Y 轴主要网格线可见
|
xyDiagram.AxisY.GridLines.Visible = true;
|
// 设置 Y 轴主要刻度间隔,可根据需求调整该值,值越小网格越密
|
xyDiagram.AxisX.Tickmarks.Thickness = 1;
|
// 配置主 X 轴
|
xyDiagram.AxisX.Title.Text = "流量(m³/h)";
|
xyDiagram.AxisX.Title.Visibility = DefaultBoolean.True;
|
xyDiagram.AxisX.Visibility = DefaultBoolean.True;
|
|
// 配置主 Y 轴
|
xyDiagram.AxisY.Title.Text = "扬程/m";
|
xyDiagram.AxisY.Title.Visibility = DefaultBoolean.True;
|
xyDiagram.AxisY.Visibility = DefaultBoolean.True;
|
//xyDiagram.AxisY.Alignment = AxisAlignment.Zero; // 设置 Y 轴与 X 轴共用零点
|
|
// 创建两个面板
|
XYDiagramPane pane1 = new XYDiagramPane();
|
pane1.Name = "Pane 1";
|
xyDiagram.Panes.Add(pane1);
|
|
XYDiagramPane pane2 = new XYDiagramPane();
|
pane2.Name = "Pane 2";
|
xyDiagram.Panes.Add(pane2);
|
|
// 创建次要 Y 轴
|
SecondaryAxisY secondaryAxisY1 = new SecondaryAxisY("Secondary Y-Axis 1");
|
secondaryAxisY1.Title.Text = "功率(KW)";
|
secondaryAxisY1.Title.Visibility = DefaultBoolean.True;
|
secondaryAxisY1.Visibility = DefaultBoolean.True;
|
secondaryAxisY1.GridLines.Visible = true;
|
secondaryAxisY1.Tickmarks.Thickness = 1;
|
secondaryAxisY1.GridLines.Color = Color.LightGray;
|
|
xyDiagram.SecondaryAxesY.Add(secondaryAxisY1);
|
|
SecondaryAxisY secondaryAxisY2 = new SecondaryAxisY("Secondary Y-Axis 2");
|
secondaryAxisY2.Title.Text = "效率(%)";
|
secondaryAxisY2.Title.Visibility = DefaultBoolean.True;
|
secondaryAxisY2.Visibility = DefaultBoolean.True;
|
secondaryAxisY2.GridLines.Visible = true;
|
secondaryAxisY2.Tickmarks.Thickness = 1;
|
secondaryAxisY2.GridLines.Color = Color.LightGray;
|
|
xyDiagram.SecondaryAxesY.Add(secondaryAxisY2);
|
|
chart.Diagram = xyDiagram;
|
((System.ComponentModel.ISupportInitialize)(xyDiagram)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(chart)).EndInit();
|
|
foreach (var valve in item)
|
{
|
// 创建第一个系列
|
Series series1 = new Series("Series 1", ViewType.Spline);
|
if (valve.CurrentCurveQH != null)
|
{
|
foreach (var qh in valve.CurrentCurveQH)
|
{
|
series1.Points.Add(new SeriesPoint(qh.X, qh.Y));
|
}
|
series1.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series1);
|
}
|
// 创建第二个系列
|
Series series2 = new Series("Series 2", ViewType.Spline);
|
if (valve.CurrentCurveQE != null)
|
{
|
foreach (var qe in valve.CurrentCurveQE)
|
{
|
series2.Points.Add(new SeriesPoint(qe.X, qe.Y));
|
}
|
((XYDiagramSeriesViewBase)series2.View).Pane = pane2;
|
((XYDiagramSeriesViewBase)series2.View).AxisY = secondaryAxisY2;
|
series2.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series2);
|
}
|
// 创建第三个系列
|
Series series3 = new Series("Series 3", ViewType.Spline);
|
if (valve.RatedCurveQP != null)
|
{
|
foreach (var qp in valve.RatedCurveQP)
|
{
|
series3.Points.Add(new SeriesPoint(qp.X, qp.Y));
|
}
|
((XYDiagramSeriesViewBase)series3.View).Pane = pane1;
|
((XYDiagramSeriesViewBase)series3.View).AxisY = secondaryAxisY1;
|
series3.LabelsVisibility = DefaultBoolean.False;
|
chart.Series.Add(series3);
|
}
|
}
|
Detail.Controls.Add(chart);
|
currentY += chart.HeightF;
|
}
|
}
|
}
|
}
|
}
|
|
#endregion 能耗分析
|
|
//能效明细
|
var labForEnergyDetails = CreateFirstCaption("(4.1)、能效明细", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForEnergyDetails);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.EnergyAnaly.Items != null && working.EnergyAnaly.Items.Count > 0)
|
{
|
// 创建 XRTable
|
var tableForEnergyDetails = new XRTable();
|
tableForEnergyDetails.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
tableForEnergyDetails.SizeF = new SizeF(727F, 30F + working.EnergyAnaly.Items.Count * 25F); // 设置大小
|
|
// 创建表头行
|
XRTableRow headerRowEnergyDetails = new XRTableRow();
|
headerRowEnergyDetails.BackColor = Color.LightGray; // 设置背景颜色
|
|
// 添加表头列
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("分组", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("名称", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("运行状态", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("设定频率(hz)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("设定流量(m³/h)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("进口压力(m)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("出口压力(m)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("扬程(m)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("功率(Kw)", 100));
|
headerRowEnergyDetails.Cells.Add(CreateTableCell("效率(%)", 100));
|
// 将表头行添加到表格
|
tableForEnergyDetails.Rows.Add(headerRowEnergyDetails);
|
|
foreach (var item in working.EnergyAnaly.Items)
|
{
|
// 创建数据行
|
var dataRow = new XRTableRow();
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.BeginGroup,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.Name,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.LinkStatus,
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.RatedHz.ToString(),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentQ?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentPr1?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentPr2?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentH?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentP?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
dataRow.Cells.Add(new XRTableCell()
|
{
|
Text = item.CurrentE?.ToString("F2"),
|
WidthF = 100F,
|
TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
|
Borders = DevExpress.XtraPrinting.BorderSide.All
|
});
|
tableForEnergyDetails.Rows.Add(dataRow);
|
}
|
// 将表格添加到Detail
|
this.Detail.Controls.Add(tableForEnergyDetails);
|
currentY += tableForEnergyDetails.HeightF;
|
currentY += 20F;
|
}
|
}
|
}
|
|
#region 损失曲线
|
|
var labForLossCurve = CreateFirstCaption("(5)、损失曲线", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForLossCurve);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
if (working.LossCurve != null && working.LossCurve.Items != null)
|
{
|
XRChart chart = new XRChart();
|
chart.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
|
chart.WidthF = contentWidth;
|
chart.HeightF = 300F;
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
// 创建一个线系列
|
Series series = new Series("Series1", ViewType.Area);
|
Series series2 = new Series("Series2", ViewType.Area);
|
Series series3 = new Series("Series3", ViewType.Area);
|
series.LabelsVisibility = DefaultBoolean.False;
|
series2.LabelsVisibility = DefaultBoolean.False;
|
series3.LabelsVisibility = DefaultBoolean.False;
|
// 添加数据点
|
foreach (var item in working.LossCurve.End.Items)
|
{
|
series.Points.Add(new SeriesPoint(item.X, item.Y));
|
}
|
// 添加数据点
|
foreach (var item in working.LossCurve.Start.Items)
|
{
|
series2.Points.Add(new SeriesPoint(item.X, item.Y));
|
} // 添加数据点
|
foreach (var item in working.LossCurve.Elev.Items)
|
{
|
series3.Points.Add(new SeriesPoint(item.X, item.Y));
|
}
|
|
chart.Series.Add(series);
|
chart.Series.Add(series2);
|
chart.Series.Add(series3);
|
Detail.Controls.Add(chart);
|
currentY += chart.HeightF;
|
}
|
}
|
}
|
|
#endregion 损失曲线
|
|
#region 损失统计
|
|
var labForLossStatistics = CreateFirstCaption("(6)、损失统计", contentWidth - 25F, 15F, 20F, currentY);
|
this.Detail.Controls.Add(labForLossStatistics);
|
currentY += 20F;
|
if (vm.WorkingList != null && vm.WorkingList.Count > 0)
|
{
|
foreach (var working in vm.WorkingList)
|
{
|
var accuracyScaleChart = CreateLossStatistics(working.LossStatistics, 350F, 230F, 0F, currentY);
|
Detail.Controls.Add(accuracyScaleChart);
|
var EnergyLossChart = CreateEnergyLoss(working.LossStatistics, 377F, 230F, 350F, currentY);
|
Detail.Controls.Add(EnergyLossChart);
|
currentY += accuracyScaleChart.HeightF;
|
var CategoryChart = CreateCategory(working.LossStatistics, 727F, 230F, 0F, currentY);
|
Detail.Controls.Add(CategoryChart);
|
currentY += CategoryChart.HeightF;
|
}
|
}
|
|
#endregion 损失统计
|
}
|
|
//创建一级标题
|
private XRLabel CreateFirstCaption(string caption, float sizeX, float sizeY, float locationX, float locationY)
|
{
|
var lab = new XRLabel();
|
lab.AnchorHorizontal = (DevExpress.XtraReports.UI.HorizontalAnchorStyles.Left | DevExpress.XtraReports.UI.HorizontalAnchorStyles.Right);
|
lab.Font = new DevExpress.Drawing.DXFont("Arial", 12F, DevExpress.Drawing.DXFontStyle.Bold);
|
lab.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY);
|
lab.Multiline = true;
|
lab.Name = "lab";
|
lab.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
|
lab.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
lab.StylePriority.UseFont = false;
|
lab.StylePriority.UseTextAlignment = false;
|
lab.Text = caption;
|
lab.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
|
return lab;
|
}
|
|
//创建精度比例
|
private XRChart CreateAccuracyScale(SimulationPrintAccuracyScaleViewModel scale, float sizeX, float sizeY, float locationY)
|
{
|
var chart = new XRChart();
|
chart.BackColor = System.Drawing.Color.Transparent;
|
chart.BorderColor = System.Drawing.Color.Black;
|
chart.Borders = DevExpress.XtraPrinting.BorderSide.All;
|
chart.Legend.Name = "Default Legend";
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
chart.LocationFloat = new DevExpress.Utils.PointFloat(0F, locationY);
|
chart.Name = "chart";
|
chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F);
|
|
var series = new DevExpress.XtraCharts.Series();
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Name = "Series";
|
var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView();
|
doughnutSeriesView.HoleRadiusPercent = 45;
|
doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 12F, DevExpress.Drawing.DXFontStyle.Bold);
|
doughnutSeriesView.TotalLabel.Visible = true;
|
series.View = doughnutSeriesView;
|
series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Label.TextPattern = "{A}:{VP:P1}";
|
chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series };
|
chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
chart.StylePriority.UseBackColor = false;
|
chart.StylePriority.UsePadding = false;
|
if (scale != null)
|
{
|
if (scale.Items != null && scale.Items.Count > 0)
|
{
|
foreach (var item in scale.Items)
|
{
|
series.Points.Add(new SeriesPoint(item.EvaluateItem, item.EvaluateCount));
|
}
|
}
|
doughnutSeriesView.TotalLabel.TextPattern = string.Format("{0:0%}", (scale.AvgError ?? 0) / 100F);
|
}
|
return chart;
|
}
|
|
//创建能量输入
|
private XRChart CreateLossStatistics(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY)
|
{
|
var chart = new XRChart();
|
chart.BackColor = System.Drawing.Color.Transparent;
|
chart.BorderColor = System.Drawing.Color.Black;
|
chart.Borders = DevExpress.XtraPrinting.BorderSide.All;
|
chart.Legend.Name = "Default Legend";
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY);
|
chart.Name = "chart";
|
chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F);
|
|
var series = new DevExpress.XtraCharts.Series();
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Name = "Series";
|
var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView();
|
doughnutSeriesView.HoleRadiusPercent = 45;
|
doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 8F, DevExpress.Drawing.DXFontStyle.Bold);
|
doughnutSeriesView.TotalLabel.Visible = true;
|
series.View = doughnutSeriesView;
|
series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Label.TextPattern = "{A}:{VP:P1}";
|
chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series };
|
chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
chart.StylePriority.UseBackColor = false;
|
chart.StylePriority.UsePadding = false;
|
if (statistics != null)
|
{
|
if (statistics.Input.Items != null && statistics.Input.Items.Count > 0)
|
{
|
foreach (var item in statistics.Input.Items)
|
{
|
series.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue));
|
}
|
}
|
doughnutSeriesView.TotalLabel.TextPattern = $"总能量:{statistics.Input.TotalEnergyValue:P0}";
|
}
|
return chart;
|
}
|
|
//创建能量统计
|
private XRChart CreateCategory(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY)
|
{
|
var chart = new XRChart();
|
chart.BackColor = System.Drawing.Color.Transparent;
|
chart.BorderColor = System.Drawing.Color.Black;
|
chart.Borders = DevExpress.XtraPrinting.BorderSide.All;
|
chart.Legend.Name = "Default Legend";
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY);
|
chart.Name = "chart";
|
chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F);
|
chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
chart.StylePriority.UseBackColor = false;
|
chart.StylePriority.UsePadding = false;
|
if (statistics != null)
|
{
|
if (statistics.Category != null && statistics.Category.Items.Count > 0)
|
{
|
foreach (var item in statistics.Category.Items)
|
{
|
var series1 = new Series(item.EnergyName, ViewType.Bar);
|
series1.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue));
|
// 获取系列视图并转换为 BarSeriesView 类型
|
BarSeriesView barSeriesView = (BarSeriesView)series1.View;
|
series1.Label.TextPattern = "{V} KW";
|
// 设置柱子宽度,这里设置为 0.8,可根据需要调整
|
barSeriesView.BarWidth = 2.5;
|
// 将系列添加到图表中
|
chart.Series.Add(series1);
|
}
|
}
|
}
|
return chart;
|
}
|
|
//创建能量损失
|
private XRChart CreateEnergyLoss(HydroLossStatisticsViewModel statistics, float sizeX, float sizeY, float locationX, float locationY)
|
{
|
var chart = new XRChart();
|
chart.BackColor = System.Drawing.Color.Transparent;
|
chart.BorderColor = System.Drawing.Color.Black;
|
chart.Borders = DevExpress.XtraPrinting.BorderSide.All;
|
chart.Legend.Name = "Default Legend";
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY);
|
chart.Name = "chart";
|
chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F);
|
|
var series = new DevExpress.XtraCharts.Series();
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Name = "Series";
|
var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView();
|
doughnutSeriesView.HoleRadiusPercent = 45;
|
doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 8F, DevExpress.Drawing.DXFontStyle.Bold);
|
doughnutSeriesView.TotalLabel.Visible = true;
|
series.View = doughnutSeriesView;
|
series.Label.LineVisibility = DevExpress.Utils.DefaultBoolean.True;
|
series.Label.TextPattern = "{A}:{VP:P1}";
|
chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series };
|
chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
chart.StylePriority.UseBackColor = false;
|
chart.StylePriority.UsePadding = false;
|
if (statistics != null)
|
{
|
if (statistics.Catalog != null && statistics.Catalog.Items.Count > 0)
|
{
|
foreach (var item in statistics.Catalog.Items)
|
{
|
series.Points.Add(new SeriesPoint(item.EnergyName.ToString(), item.EnergyValue));
|
}
|
}
|
doughnutSeriesView.TotalLabel.TextPattern = $"总损失:{statistics.Input.TotalEnergyValue:P0}";
|
}
|
return chart;
|
}
|
|
//创建精度项
|
private XRChart CreateAccuracyItem(double value, float sizeX, float sizeY, float locationX, float locationY)
|
{
|
var chart = new XRChart();
|
chart.BackColor = System.Drawing.Color.Transparent;
|
chart.BorderColor = System.Drawing.Color.Black;
|
chart.Borders = DevExpress.XtraPrinting.BorderSide.All;
|
chart.Legend.Name = "Default Legend";
|
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
chart.LocationFloat = new DevExpress.Utils.PointFloat(locationX, locationY);
|
chart.Name = "chart";
|
chart.Padding = new DevExpress.XtraPrinting.PaddingInfo(10, 10, 20, 20, 100F);
|
chart.PaletteRepository.Add("Palette 1", new DevExpress.XtraCharts.Palette("Palette 1", DevExpress.XtraCharts.PaletteScaleMode.Repeat, new DevExpress.XtraCharts.PaletteEntry[] {
|
new DevExpress.XtraCharts.PaletteEntry(System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(174)))), ((int)(((byte)(197))))), System.Drawing.Color.FromArgb(((int)(((byte)(103)))), ((int)(((byte)(174)))), ((int)(((byte)(197)))))),
|
new DevExpress.XtraCharts.PaletteEntry(System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(236)))), ((int)(((byte)(240))))), System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(236)))), ((int)(((byte)(240))))))}));
|
chart.PaletteName = "Palette 1";
|
|
var series = new DevExpress.XtraCharts.Series();
|
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
|
series.Name = "Series";
|
var doughnutSeriesView = new DevExpress.XtraCharts.DoughnutSeriesView();
|
doughnutSeriesView.HoleRadiusPercent = 45;
|
doughnutSeriesView.TotalLabel.DXFont = new DevExpress.Drawing.DXFont("Tahoma", 12F, DevExpress.Drawing.DXFontStyle.Bold);
|
doughnutSeriesView.TotalLabel.Visible = true;
|
series.View = doughnutSeriesView;
|
chart.SeriesSerializable = new DevExpress.XtraCharts.Series[] { series };
|
chart.SizeF = new System.Drawing.SizeF(sizeX, sizeY);
|
chart.StylePriority.UseBackColor = false;
|
chart.StylePriority.UsePadding = false;
|
|
var otherValue = 100 - value;
|
series.Points.Add(new SeriesPoint("误差", value));
|
series.Points.Add(new SeriesPoint("其他", otherValue));
|
|
doughnutSeriesView.TotalLabel.TextPattern = string.Format("{0:0%}", value / 100f);
|
return chart;
|
}
|
|
// 创建表头单元格
|
private XRTableCell CreateTableCell(string text, int width)
|
{
|
XRTableCell cell = new XRTableCell();
|
cell.Text = text;
|
cell.Width = width;
|
cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; // 文本居中
|
cell.Borders = DevExpress.XtraPrinting.BorderSide.All; // 设置边框
|
return cell;
|
}
|
|
// 创建数据绑定单元格
|
private XRTableCell CreateTableCellWithBinding(string dataMember, int width)
|
{
|
XRTableCell cell = new XRTableCell();
|
cell.DataBindings.Add(new XRBinding("Text", null, dataMember)); // 绑定数据字段
|
cell.Width = width;
|
cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; // 文本左对齐
|
cell.Borders = DevExpress.XtraPrinting.BorderSide.All; // 设置边框
|
return cell;
|
}
|
}
|
}
|