From 1f7091dac2a5dddf4a0a40acb0940d3787cf35f5 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期二, 18 二月 2025 14:05:47 +0800 Subject: [PATCH] 损失统计整理 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/00-core/SimulationWordReportHelper.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 53 insertions(+), 2 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/00-core/SimulationWordReportHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/00-core/SimulationWordReportHelper.cs index f8b4131..2bbdd12 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/00-core/SimulationWordReportHelper.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/00-core/SimulationWordReportHelper.cs @@ -1,4 +1,6 @@ 锘縰sing Aspose.Words; +using SkiaSharp; +using System.Drawing.Imaging; namespace HStation.WinFrmUI { @@ -272,7 +274,7 @@ /// <param name="content"></param> public void AddBlankLine() { - _builder.Writeln(); + _builder.Writeln(); } /// <summary> @@ -306,6 +308,55 @@ } /// <summary> + /// 鏋勫缓鍥剧墖 (鍚屼竴琛屽涓浘鐗�) + /// </summary> + /// <param name="addresses">鍥剧墖鍦板潃鍒楄〃</param> + /// <param name="height">鍥剧墖楂樺害</param> + /// <param name="width">鍥剧墖瀹藉害</param> + /// <param name="spacing">鍥剧墖涔嬮棿鐨勯棿璺�</param> + public void structureImagesInRow(List<string> addresses, int height, int width) + { + _builder.ParagraphFormat.Alignment = _fontalignment; + _builder.SetBuilderFont(_font, _fontSize, _fontcolor, _isBlod); + + foreach (var address in addresses) + { + if (!System.IO.File.Exists(address)) + { + continue; // 濡傛灉鏂囦欢涓嶅瓨鍦紝鍒欒烦杩囪鍥剧墖 + } + + _builder.InsertImage(address, width, height); + } + + _builder.Writeln(""); // 鍦ㄦ墍鏈夊浘鐗囨彃鍏ュ悗娣诲姞涓�涓崲琛� + } + + /// <summary> + /// 鏋勫缓鍥剧墖 + /// </summary> + /// <param name="content">鏂囧瓧鍐呭</param> + /// <param name="BitMap">鍥剧墖鍦板潃</param> + public void structureTextAndImage(Bitmap BitMap, int height, int wide) + { + using (var stream = new MemoryStream()) + { + // 灏哠ystem.Drawing.Bitmap淇濆瓨鍒板唴瀛樻祦涓� + BitMap.Save(stream, ImageFormat.Png); + stream.Position = 0; + // 浣跨敤SKManagedStream浠庡唴瀛樻祦涓В鐮佸嚭SKBitmap + using (var skManagedStream = new SKManagedStream(stream)) + { + var skBitmap = SKBitmap.Decode(skManagedStream); + _builder.ParagraphFormat.Alignment = _fontalignment; + _builder.SetBuilderFont(_font, _fontSize, _fontcolor, _isBlod); + _builder.InsertImage(skBitmap, wide, height); + _builder.Writeln(""); + } + } + } + + /// <summary> /// 鏋勫缓鍥剧墖 /// </summary> /// <param name="address"></param> @@ -327,7 +378,7 @@ public void structureCell(string content) { _builder.ParagraphFormat.FirstLineIndent = 0; - _builder.ParagraphFormat.LeftIndent = 2; + _builder.ParagraphFormat.LeftIndent = 2; var cell = _builder.InsertCell(); //_builder.InsertParagraph(); // 娣诲姞涓�涓柊娈佃惤 //_builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; // 璁剧疆娈佃惤鍨傜洿灞呬腑 -- Gitblit v1.9.3