//using DevExpress.Drawing.Internal.Fonts.Interop; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Drawing.Text; using System.Linq; using System.Security.Cryptography; namespace _1200Gxml心电图绘制 { public class CommonPrintEcgWave { private const int LeadCount12 = 12; private const int LeadCount15 = 15; private const int LeadCount18 = 18; private const double PerInch = 1.03f; //振幅高度百分比(y值) 显示波形 private const float PrintInch = 0.30f;//0.95 //打印时波形 private const int LeadWaveLenth = 4; //前排波形的尾部与后排波形的标压名称之间的间隔 private const int LeadLenght = 550; private readonly Dictionary _firstPointArray = new Dictionary(); //标压的坐标集合 private readonly List _leadList = new List { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }; private readonly string[] _leadNameArray = { "I", "II", "III", "aVR", "aVL", "aVF", "V1", "V2", "V3", "V4", "V5", "V6", "V3R", "V4R", "V5R", "V7", "V8", "V9" }; private readonly Dictionary> _points = new Dictionary>(); //下坡线点集合 private double _amplitude = 10; //振幅,默认值 private int _baseLine; private int _clearCount; //绘制QRS滤掉的点数 private readonly int _dpi = 300; //打印DPI,默认300 private Bitmap _ecgCanvas; private Dictionary> _ecgDatas = new Dictionary>(); //心电数据集合 private Graphics _ecgGraphics; private Pen _ecgPen; //画笔普通波形(除QRS波之外) private Pen _ecgPenQrs; //画笔QRS波 private Point _firstPosition = new Point(0, 0); private int _freePixs; private double _intervalPixCountPerPoint; private string _isQb; //是否起搏 private readonly double _lenthPerInch = 25.4; private readonly int _oldDpi = 96; //电脑DPI,默认96 private double _paperSpeed = 25; //走速,默认值 private Pen _pen; //画笔报告标题和参数 private readonly double _samplingRate = 1000; //默认值 private Point _secondPosition = new Point(0, 0); /// /// 波形打印初始化参数 /// /// /// /// public void InitEcgParameter(Bitmap btmp, Dictionary> ecgDatas, string isQiBo, double paperSpeed, double amplitude) { _paperSpeed = paperSpeed; _amplitude = amplitude; _ecgCanvas = btmp; _ecgGraphics = Graphics.FromImage(_ecgCanvas); _ecgGraphics.Clear(Color.White); //填充指定颜色 _ecgGraphics.SmoothingMode = SmoothingMode.AntiAlias; //抗锯齿 //Ecg_Graphics.CompositingQuality = CompositingQuality.HighQuality;//消除锯齿,最高品质 _ecgDatas = ecgDatas; _pen = new Pen(Color.Black, float.Parse("2")); _ecgPen = new Pen(Color.Black, float.Parse("2")); _ecgPenQrs = new Pen(Color.Black,2); //ConfigHelper.WaveColor _freePixs = (int)(Math.Round(_dpi / _lenthPerInch) * 5); _isQb = isQiBo; _intervalPixCountPerPoint = _paperSpeed / _samplingRate * _dpi / _lenthPerInch; } /// /// 绘制心电图的背景网格 /// public void PrintBackGroundGrid(int height1, int height2) { var ep = new Pen(Color.Gray, float.Parse("1")); //Black 背景网格颜色深 Gray 背景网格颜色浅 //if (ConfigHelper.IsDashOrSolid) // ep.DashStyle = DashStyle.Solid; //else // ep.DashStyle = DashStyle.Dash; ep.DashStyle = DashStyle.Dash; const float pointCountPerMM = 12f; //每个小网格间距 12mm;// Math.Abs(float.Parse(Dpi.ToString()) / (float)LenthPerInch); var heightTop = height1 * pointCountPerMM + 8; //+ 0.2f var heightBottm = height2 * (pointCountPerMM - 0.2f); float x; float y; var cHeight = (int)heightBottm; //网格高度 _ecgGraphics.SmoothingMode = SmoothingMode.None; //保证网格线的清晰 for (int i = _ecgCanvas.Width, j = 0; i >= -72; i -= (int)pointCountPerMM, j++) //72 代表宽度相差6个小格间距 if (j % 5 == 0) { x = (float)Math.Round(i + j / 5 * 1.2, 2); //每个大格相差1.2mm _ecgGraphics.DrawLine(ep, x, heightTop, x, cHeight); // EcgViewPro.WatchDog.WriteMsg(j / 5 + "两竖线间距:" + Math.Round((xtest - x),2)+"----"+x+":"+i); } //绘制横线 for (int i = cHeight, j = 0; i >= heightTop - 36; i -= (int)pointCountPerMM, j++) //36 代表高度相差3个小格的间距 if (j % 5 == 0) { y = (float)Math.Round(i + j / 5 * 1.2, 2); //每个大格相差1.2mm _ecgGraphics.DrawLine(ep, 0, y, _ecgCanvas.Width, y); // EcgViewPro.WatchDog.WriteMsg(j / 5 + "两横线间距:" + Math.Round((xtest - y), 2) + "----" + y + ":" + i); } else { y = (float)Math.Round(i + j * 0.24, 2); for (int k = _ecgCanvas.Width, t = 0; k >= -72; k -= (int)pointCountPerMM, t++) { x = (float)Math.Round(k + t * 0.24, 2); //每个小格相差0.24 if ((int)y < cHeight && (int)x < _ecgCanvas.Width) if (t % 5 != 0) _ecgCanvas.SetPixel((int)x, (int)y, Color.Black); //ConfigHelper.WaveColor } } } /// /// 绘制心电报告的报告头 /// public void PrintReportHeadInfo(string reportTitle, string reportDate) { var height = _freePixs * 3 - 55; var font = new Font("隶书", 20); var brush = Brushes.Black; float reportLength = reportTitle.Any(t => t >= 0x4e00 && t <= 0x9fbb)? 20 * _dpi / _oldDpi * reportTitle.Length: 10 * _dpi / _oldDpi * reportTitle.Length; var pointF = new PointF((_ecgCanvas.Width - reportLength) / 2 - 20 * _dpi / _oldDpi * 3, 15); _ecgGraphics.DrawString(reportTitle, font, brush, pointF); font = new Font("宋体", 10); pointF = new PointF(_ecgCanvas.Width - 470, height - 50); //_ecgGraphics.DrawString(LocalStorage.ResManager.GetString("ReportDate") + reportDate, font, brush, pointF); //报告日期 _ecgGraphics.DrawString( reportDate, font, brush, pointF); //报告日期 _ecgGraphics.DrawLine(_pen, 0, height, _ecgCanvas.Width, height); //第一条横线 } /// /// 绘制长十二导心电报告的报告头 /// /// public void PrintLongReportHeadInfo(string reportTitle) { var font = new Font("隶书", 20); var brush = Brushes.Black; //float reportLength = 20 * _dpi / _oldDpi * reportTitle.Length; float reportLength = reportTitle.Any(t => t >= 0x4e00 && t <= 0x9fbb) ? 20 * _dpi / _oldDpi * reportTitle.Length : 10 * _dpi / _oldDpi * reportTitle.Length; var point = new PointF((_ecgCanvas.Width - reportLength) / 2 - 20 * _dpi / _oldDpi * 3, (_freePixs * 3 + 20) / 3); _ecgGraphics.DrawString(reportTitle, font, brush, point); _ecgGraphics.DrawLine(_pen, 0, _freePixs * 3 + 20, _ecgCanvas.Width, _freePixs * 3 + 20); } /// /// 绘制患者的心电识别的参数 /// public void PrintEcgInfo(string[] diagInfoList, string idStr) { var font = new Font("宋体", 10, FontStyle.Regular); var brush = Brushes.Black; var firstPoint = 0; var secondPoint = 850; var height = _freePixs * 2 + 15; //第一排 // var pId = LocalStorage.ResManager.GetString("pId"); var pointF = new PointF(firstPoint, height); //_ecgGraphics.DrawString(pId + ":" + idStr, font, brush, pointF); //ID _ecgGraphics.DrawString("编号:" + idStr, font, brush, pointF); //ID pointF = new PointF(firstPoint, height + _freePixs); _ecgGraphics.DrawString(diagInfoList[0], font, brush, pointF); //姓名 pointF = new PointF(firstPoint, height + _freePixs * 2); _ecgGraphics.DrawString(diagInfoList[1], font, brush, pointF); //性别 pointF = new PointF(firstPoint, height + _freePixs * 3); _ecgGraphics.DrawString(diagInfoList[2], font, brush, pointF); //年龄 pointF = new PointF(firstPoint, height + _freePixs * 4); _ecgGraphics.DrawString(diagInfoList[10], font, brush, pointF); //病室 pointF = new PointF(firstPoint, height + _freePixs * 5); _ecgGraphics.DrawString(diagInfoList[12], font, brush, pointF); //住院号 //第二排 pointF = new PointF(secondPoint, height); _ecgGraphics.DrawString(diagInfoList[9], font, brush, pointF); //心率 pointF = new PointF(secondPoint, height + _freePixs * 1); _ecgGraphics.DrawString(diagInfoList[4], font, brush, pointF); //P-R pointF = new PointF(secondPoint, height + _freePixs * 2); _ecgGraphics.DrawString(diagInfoList[5], font, brush, pointF); //QRS pointF = new PointF(secondPoint, height + _freePixs * 3); _ecgGraphics.DrawString(diagInfoList[6], font, brush, pointF); //QT/QTC pointF = new PointF(secondPoint, height + _freePixs * 4); //_ecgGraphics.DrawString(diagInfoList[7], font, brush, pointF); //QRS电轴 //_ecgGraphics.DrawString("", font, brush, pointF); //QRS电轴 _ecgGraphics.DrawString(diagInfoList[8].Replace(" ", string.Empty), font, brush, pointF); //RV5/SV1 pointF = new PointF(secondPoint, height + _freePixs * 5); _ecgGraphics.DrawString(diagInfoList[3], font, brush, pointF); //RV5+SV1 //第三排 pointF = new PointF(secondPoint + 550, height); _ecgGraphics.DrawString(diagInfoList[7], font, brush, pointF); //qrs //第三排 pointF = new PointF(secondPoint + 550, height + _freePixs * 1); _ecgGraphics.DrawString(diagInfoList[13], font, brush, pointF); //p //_ecgGraphics.DrawLine(_pen, 0, height + _freePixs * 5 + 54, _ecgCanvas.Width, height + _freePixs * 5 + 54);//第二条横线 //if (ConfigHelper.IsPrintQuickResponse && File.Exists(Application.StartupPath + "\\wx.gif")) //{ // using (Image img = Image.FromFile(Application.StartupPath + "\\wx.gif")) // { // _ecgGraphics.DrawImage(img, _ecgCanvas.Width - 229, _freePixs * 2 + 20, 229, 230); // } //} } /// /// 绘制长十二导心电识别的参数 /// /// public void PrintLongEcgInfo(string[] diagInfoList, string idStr) { var font = new Font("宋体", 10); var brush = Brushes.Black; var num = 3; var point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * num + 65); _ecgGraphics.DrawString(LocalStorage.ResManager.GetString("pId") + ":" + idStr, font, brush, point); //ID point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 1) + 65); _ecgGraphics.DrawString(diagInfoList[0], font, brush, point); //姓名 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 2) + 65); _ecgGraphics.DrawString(diagInfoList[1], font, brush, point); //性别 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 3) + 65); _ecgGraphics.DrawString(diagInfoList[2], font, brush, point); //年龄 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 4) + 65); _ecgGraphics.DrawString(diagInfoList[10], font, brush, point); //病室 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 5) + 65); _ecgGraphics.DrawString(diagInfoList[12], font, brush, point); //住院号 //point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * 2 + 10); //_ecgGraphics.DrawString(diagInfoList[11], font, brush, point);//床号 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 6) + 65); _ecgGraphics.DrawString(diagInfoList[9], font, brush, point); //心率 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 7) + 65); _ecgGraphics.DrawString(diagInfoList[4], font, brush, point); //P-R point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 8) + 65); _ecgGraphics.DrawString(diagInfoList[5], font, brush, point); //QRS point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 9) + 65); _ecgGraphics.DrawString(diagInfoList[6], font, brush, point); //QT/QTC point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 10) + 65); _ecgGraphics.DrawString(diagInfoList[7], font, brush, point); //QRS电轴 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 11) + 65); _ecgGraphics.DrawString(diagInfoList[8].Replace(" ", string.Empty), font, brush, point); //RV5/SV1 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 12) + 65); _ecgGraphics.DrawString(diagInfoList[3], font, brush, point); //RV5+SV1 point = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (num + 13) + 65); _ecgGraphics.DrawString(diagInfoList[13], font, brush, point); //p //_ecgGraphics.DrawLine(_pen, 0, _freePixs * 3 + 48, _ecgCanvas.Width, _freePixs * 3 + 48); //if (ConfigHelper.IsPrintQuickResponse && File.Exists(Application.StartupPath + "\\wx.gif")) //{ // if (File.Exists(Application.StartupPath + "\\wx.gif")) // { // using (Image img = Image.FromFile(Application.StartupPath + "\\wx.gif")) // { // _ecgGraphics.DrawImage(img, _ecgCanvas.Width - 320, _freePixs * 2 + 1480, 229, 230); // } // } //} } /// /// 绘制心电诊断结论 /// /// /// /// /// /// /// /// /// /// public void PrintDiagInfo(string diagInfoContent, string reportDoctorName, string filter, string collectTime, string dept, string amp, string ps, Image img, string addr) { var font = new Font("宋体", 10, FontStyle.Regular); var brush = Brushes.Black; var firstPoint = 0; var threePoint = 1800; var height = _freePixs * 2 + 15; filter = filter.Replace("低通:", ""); //diagInfoContent = $"{LocalStorage.ResManager.GetString("DiagnosticTips")}:{diagInfoContent}" ; diagInfoContent = $"{"诊断结论:"}{diagInfoContent}"; var len = diagInfoContent.Any(t => t >= 0x4e00 && t <= 0x9fbb) ? 33 : 72; var drCnt = new string[diagInfoContent.Length / len + 1]; for (var a = 0; a < diagInfoContent.Length / len + 1; a++) if (a < diagInfoContent.Length / len) { drCnt[a] = diagInfoContent.Substring(a * len, len); } else { if (diagInfoContent.Length - a * len > len) { drCnt[a] = diagInfoContent.Substring(a * len, len); drCnt[a + 1] = diagInfoContent.Substring((a + 1) * len, diagInfoContent.Length - a * len); } else { drCnt[a] = diagInfoContent.Substring(a * len, diagInfoContent.Length - a * len); } } var pointF = new PointF(threePoint, height); //_ecgGraphics.DrawString($"{diagnosticTips}:", font, brush, pointF); //诊断结果 for (var i = 0; i < drCnt.Length; i++) { pointF = new PointF(threePoint, height + i * _freePixs); _ecgGraphics.DrawString(drCnt[i].Trim(), font, brush, pointF); //诊断结果 } //var len = diagInfoContent.Any(t => t >= 0x4e00 && t <= 0x9fbb) ? 33 : 66; //var drCnt = new string[diagInfoContent.Length / len + 1]; //for (var a = 0; a < diagInfoContent.Length / len + 1; a++) // if (a < diagInfoContent.Length / len) // { // drCnt[a] = diagInfoContent.Substring(a * len, len); // } // else // { // if (diagInfoContent.Length - a * len > len) // { // drCnt[a] = diagInfoContent.Substring(a * len, len); // drCnt[a + 1] = // diagInfoContent.Substring((a + 1) * len, diagInfoContent.Length - a * len); // } // else // { // drCnt[a] = diagInfoContent.Substring(a * len, diagInfoContent.Length - a * len); // } // } /* //23.11.21分号换行 var font = new Font("宋体", 10, FontStyle.Regular); var brush = Brushes.Black; var firstPoint = 0; var threePoint = 1800; var height = _freePixs * 2 + 15; filter = filter.Replace("低通:", ""); var drCnt = diagInfoContent.Split(';'); PointF pointF; var diagnosticTips = LocalStorage.ResManager.GetString("DiagnosticTips"); //_ecgGraphics.DrawString(diagnosticTips + ":", font, brush, pointF); //诊断结果 if (drCnt.Length > 0) drCnt[0] = $"{diagnosticTips}:{drCnt[0]}"; for (var i = 0; i < drCnt.Length; i++) { pointF = new PointF(threePoint, height + i * _freePixs);//threePoint + 200 _ecgGraphics.DrawString(drCnt[i].Trim(), font, brush, pointF); //诊断结果 } */ //pointF = new PointF(_ecgCanvas.Width - 1000, height + _freePixs * 5); pointF = new PointF(threePoint, height + _freePixs * 5); _ecgGraphics.DrawString(dept, font, brush, pointF); //科室 pointF = new PointF(_ecgCanvas.Width - 750, height + _freePixs * 5); if (img == null) { //var report = LocalStorage.ResManager.GetString("Report"); var report = "报告医生:"; _ecgGraphics.DrawString(report + reportDoctorName, font, brush, pointF); //报告医生 } else using (var bmpSource = new Bitmap((Bitmap)img, 160, 80)) { bmpSource.SetResolution(200, 200); //var reportDoctor = LocalStorage.ResManager.GetString("ReportDoctor"); //_ecgGraphics.DrawString(reportDoctor + ":", font, brush, pointF); //报告医生 var report = "报告医生:"; _ecgGraphics.DrawString(report, font, brush, pointF); //报告医生 pointF = new PointF(_ecgCanvas.Width - 444, height + _freePixs * 4 - 10); _ecgGraphics.DrawImage(bmpSource, pointF); // bmpSource.Dispose(); } pointF = new PointF(_ecgCanvas.Width - 450, _ecgCanvas.Height - _freePixs - 50); _ecgGraphics.DrawString(Convert.ToDateTime(collectTime).ToString("yyyy-MM-dd HH:mm:ss"), font, brush, pointF); //波形的起始时间点 //_ecgGraphics.DrawLine(_pen, 0, _ecgCanvas.Height - _freePixs + 49, _ecgCanvas.Width, _ecgCanvas.Height - _freePixs + 49);//第四条横线_ecgCanvas.Height==2375 font = new Font("宋体", 8, FontStyle.Regular); //var address = LocalStorage.ResManager.GetString("Address") + ":" + addr; var address = "地址:" + addr; var parameters = ps + " " + amp + " " + filter; //var reportDec = LocalStorage.ResManager.GetString("ReportDec"); var reportDec = ""; var r1w = GetStrWidth(reportDec) * font.Size; var l1w = GetStrWidth(address) * font.Size; var c1w = GetStrWidth(parameters) * font.Size; var locX = l1w + (_ecgCanvas.Width - r1w - l1w - c1w) / 2; //pointF = new PointF((_ecgCanvas.Width - parameters.Length) / 2 - 20 * _dpi / _oldDpi * 3, _ecgCanvas.Height - _freePixs); pointF = new PointF(locX, _ecgCanvas.Height - _freePixs); _ecgGraphics.DrawString(parameters, font, brush, pointF); //振幅 走纸速度 滤波 pointF = new PointF(firstPoint, _ecgCanvas.Height - _freePixs); _ecgGraphics.DrawString(address, font, brush, pointF); //地址 //pointF = new PointF(secondPoint, _ecgCanvas.Height - _freePixs); pointF = new PointF(_ecgCanvas.Width - 20 - r1w, _ecgCanvas.Height - _freePixs); _ecgGraphics.DrawString(reportDec, font, brush, pointF); } /// /// 绘制QRS波群 /// /// /// private void PointContrast(List xp, int leadindex) { var lp = new List(); for (var k = 1; k < xp.Count; k++) if (k + 1 < xp.Count) { if (_isQb == "1") { if (xp[k + 1].X - xp[k].X < 10 && xp[k + 1].X - xp[k].X >= 0) // lp.Add(xp[k]); } else { if ((xp[k + 1].X - xp[k].X < 10 && xp[k + 1].X - xp[k].X > 0) || (xp[k].Y >= xp[k + 1].Y && xp[k].Y > xp[k - 1].Y) || (xp[k].Y <= xp[k + 1].Y && xp[k].Y < xp[k - 1].Y)) // { if (!lp.Contains(xp[k])) lp.Add(xp[k]); } else { if (xp[k].X == xp[k + 1].X && xp[k].Y != xp[k + 1].Y && leadindex == 0) //leadindex==0 以I导为标准 _clearCount++; } } } if (_clearCount > xp.Count * 0.6) //0.7 代表滤掉的点数大于总点数的百分之七十 { lp.Clear(); lp = xp; } _ecgGraphics.SmoothingMode = SmoothingMode.AntiAlias; //抗锯齿 _ecgGraphics.DrawLines(_ecgPenQrs, lp.ToArray()); } /// /// 绘制长十二导心电诊断结论 /// /// /// /// /// /// /// /// /// /// /// public void PrintLongDiagInfo(string diagInfoContent, string reportDoctorName, string reportDate, string filter, string collectTime, string dept, string amp, string ps, Image img, string addr) { //ConfigHelper.EcgReportTitle = "注:本报告仅供临床医师参考,不作疾病证明。"; var flag = diagInfoContent.Any(t => t >= 0x4e00 && t <= 0x9fbb); var diagResult = flag ? diagInfoContent.Split(';', ' ', ',', ',', '。', ';') : diagInfoContent.Split(';'); var brush = Brushes.Black; var font = new Font("宋体", 8, FontStyle.Regular); var address = LocalStorage.ResManager.GetString("Address") + ":" + addr; var parameters = ps + " " + amp + " " + filter; var reportDec = LocalStorage.ResManager.GetString("ReportDec"); var r1w = GetStrWidth(reportDec) * font.Size; var l1w = GetStrWidth(address) * font.Size; var c1w = GetStrWidth(parameters) * font.Size; var locX = l1w + (_ecgCanvas.Width - r1w - l1w - c1w) / 2; var pointF = new PointF(locX, _ecgCanvas.Height - _freePixs + 10); _ecgGraphics.DrawString(parameters, font, brush, pointF); //振幅 走纸速度 滤波 pointF = new PointF(0, _ecgCanvas.Height - _freePixs + 10); _ecgGraphics.DrawString(address, font, brush, pointF); //地址 //pointF = new PointF(secondPoint, _ecgCanvas.Height - _freePixs); pointF = new PointF(_ecgCanvas.Width - 20 - r1w, _ecgCanvas.Height - _freePixs + 10); _ecgGraphics.DrawString(reportDec, font, brush, pointF); //var pointF = new PointF(_ecgCanvas.Width - 3400, _ecgCanvas.Height - _freePixs + 10); //_ecgGraphics.DrawString("地址:" + addr, font, brush, pointF); //地址 //pointF = new PointF(_ecgCanvas.Width - LeadLenght * 1.25f, _ecgCanvas.Height - _freePixs + 10); //_ecgGraphics.DrawString(LocalStorage.ResManager.GetString("ReportDec"), font, brush, pointF); //注意 ConfigHelper.EcgReportTitle //pointF = new PointF(_ecgCanvas.Width - 1800, _ecgCanvas.Height - _freePixs + 10); //_ecgGraphics.DrawString(ps + " " + amp + " " + filter, font, brush, pointF); //振幅 走纸速度滤波低通 font = new Font("宋体", 10); pointF = new PointF(_ecgCanvas.Width - LeadLenght, _ecgCanvas.Height - _freePixs * 7 - 18); //var len = GetStrWidth(dept) * 8; //if (len > 24) //{ // _ecgGraphics.DrawString(dept.Substring(0, 12), font, brush, pointF); //科室 // pointF = new PointF(_ecgCanvas.Width - LeadLenght, _ecgCanvas.Height - _freePixs * 6); // _ecgGraphics.DrawString(dept.Substring(12, dept.Length - 12), font, brush, pointF); //科室 //} //else //{ // _ecgGraphics.DrawString(dept, font, brush, pointF); //科室 var layoutRect = new RectangleF(pointF.X, pointF.Y, 550, 132); var sf = new StringFormat { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Near, Trimming = StringTrimming.None }; sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Center; sf.Trimming = StringTrimming.EllipsisCharacter; _ecgGraphics.DrawString(dept, font, brush, layoutRect, sf); //科室 //} pointF = new PointF(_ecgCanvas.Width - LeadLenght, _ecgCanvas.Height - _freePixs * 5); if (img == null) _ecgGraphics.DrawString(LocalStorage.ResManager.GetString("Report") + reportDoctorName, font, brush, pointF); //报告医生 else using (var bmpSource = new Bitmap(img, 160, 80)) { bmpSource.SetResolution(200, 200); var point2Img = new PointF(_ecgCanvas.Width - LeadLenght + 200, _ecgCanvas.Height - _freePixs * 5); //_ecgGraphics.DrawString(LocalStorage.ResManager.GetString("ReportDoctor") + ":", font, brush, pointF); //报告医生 _ecgGraphics.DrawImage(bmpSource, point2Img); } pointF = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * 3 - 20); _ecgGraphics.DrawString(LocalStorage.ResManager.GetString("ReportDate") + reportDate, font, brush, pointF); //报告日期 pointF = new PointF(_ecgCanvas.Width - LeadLenght * 0.8f, _ecgCanvas.Height - _freePixs * 1.9f); // _ecgGraphics.DrawString(collectTime, font, brush, pointF); //波形的起始时间点 pointF = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * 17 + 65); _ecgGraphics.DrawString(LocalStorage.ResManager.GetString("DiagnosticTips") + ":", font, brush, pointF); //诊断结果 //layoutRect = new RectangleF(pointF.X, pointF.Y, 550, 132); //_ecgGraphics.DrawString(diagResult, font, brush, layoutRect, sf); //科室 diagResult = diagResult.Where(it => !string.IsNullOrEmpty(it)).Select(it => it.Trim()).ToArray(); var k = 0; var len = diagInfoContent.Any(t => t >= 0x4e00 && t <= 0x9fbb) ? 12 : 24; for (var i = 0; i < diagResult.Length; i++) { if (!diagInfoContent.Any(t => t >= 0x4e00 && t <= 0x9fbb)) diagResult[i] += ""; if (diagResult[i].Length <= len) { pointF = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (18 + i + k) + 65); _ecgGraphics.DrawString(diagResult[i].Substring(0, diagResult[i].Length), font, brush, pointF, sf); //诊断结果 } else { var ok = true; while (ok) if (diagResult[i].Length - k * len > len) { pointF = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (18 + i + k) + 65); _ecgGraphics.DrawString(diagResult[i].Substring(k * len, len), font, brush, pointF, sf); //诊断结果 k++; } else { pointF = new PointF(_ecgCanvas.Width - LeadLenght, _freePixs * (18 + i + k) + 65); _ecgGraphics.DrawString( diagResult[i].Substring(k * len, diagResult[i].Length - k * len), font, brush, pointF, sf); //诊断结 ok = false; } } } _ecgGraphics.DrawLine(_pen, 0, _ecgCanvas.Height - _freePixs, _ecgCanvas.Width, _ecgCanvas.Height - _freePixs); } /// /// 绘制6x2模式波形--打印 /// /// /// /// public void PrintEcgWave(int drawInitHeight, int bottomHeight, int dataIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight *= _freePixs; bottomHeight *= _freePixs; for (var i = 0; i < LeadCount12; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 6) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + (i - 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 2; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 2; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } // int aaa = 1000 / ConfigHelper.PrintSampleRate; if (_ecgDatas.Count > 0) // for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 /1000) { if (i < 6) { if (_firstPosition.X > _ecgCanvas.Width / 2 - 5) break; } else { if (_firstPosition.X > _ecgCanvas.Width) break; } var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)Math.Round(x); if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 6) _secondPosition.X = nextX + _freePixs; else _secondPosition.X = _ecgCanvas.Width / 2 + _freePixs + nextX; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[leadIndex], leadIndex); //绘制所有导联的QRS波群 } } /// /// 绘制6X2模式标压名称---打印 /// /// public void PrintEcgLeadName(double cVoltagescale) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount12; d++) if (d < 6) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制6x2+2模式波形--打印 /// /// /// /// /// /// public void PrintEcgWave(int drawInitHeight, int bottomHeight, List longLeadInfo, int dataIndex, int dataLengthIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight *= _freePixs; bottomHeight = bottomHeight * _freePixs; for (var i = 0; i < LeadCount12; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 6) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2) / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 10 * i; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2) / 2 + (i - 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 10 * (i - 6); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 2; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 2; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (i < 6) { if (_firstPosition.X > _ecgCanvas.Width / 2 - 5) break; } else { if (_firstPosition.X > _ecgCanvas.Width) break; } var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 6) _secondPosition.X = nextX + _freePixs; else _secondPosition.X = _ecgCanvas.Width / 2 + _freePixs + nextX; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], i); //绘制所有导联的QRS波群 } _points.Clear(); for (var i = 0; i < longLeadInfo.Count; i++) { var leadIndex = _leadList[longLeadInfo[i]]; //取导联下标 0 1 2 3 ...11 _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2) / 2 + (i + 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2 + 2)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 10 * (i + 6); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(i + 12, fp); if (_ecgDatas.Count > 0) for (var b = dataLengthIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataLengthIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { _secondPosition.X = nextX + _freePixs; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(leadIndex)) { var xp = new List { _firstPosition }; _points.Add(leadIndex, xp); } else { _points[leadIndex].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[leadIndex], leadIndex); //绘制所有导联的QRS波群 } } /// /// 绘制6X2+2模式标压名称--打印 /// /// /// public void PrintEcgLeadName(double cVoltagescale, List longLeadInfo) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount12; d++) if (d < 6) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { //1 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); //2 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //3 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //4 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } for (var d = 0; d < 2; d++) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y, _freePixs / 3 * 3, _firstPointArray[d + LeadCount12].Y); var str = _leadNameArray[_leadList[longLeadInfo[d]]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制12x1模式波形--打印 /// /// /// /// public void PrintLongEcgWave(int drawInitHeight, int bottomHeight, int dataIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight *= _freePixs; bottomHeight *= _freePixs; for (var i = 0; i < LeadCount12; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / LeadCount12 / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / LeadCount12) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (_firstPosition.X > _ecgCanvas.Width - LeadLenght) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { _secondPosition.X = nextX + _freePixs; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], leadIndex); //绘制所有导联的QRS波群 } } /// /// 绘制12长导模式标压名称--显打印示 /// /// public void PrintLongEcgLeadName(double cVoltagescale) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount12; d++) { //1 _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); //2 _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); //3 _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); //4 _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制4x3+1模式波形--打印 /// /// /// /// /// /// public void PrintEcgWaveFourOne(int drawInitHeight, int bottomHeight, int dataIndex, int dataLengthIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight *= _freePixs; bottomHeight = bottomHeight * _freePixs; for (var i = 0; i < LeadCount12; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 6) { if (i < 3) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1) / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 4 * i; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1) / 2 + (i - 3) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 4 * (i - 3); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 4; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 4; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } } else { if (i < 9) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1) / 2 + (i - 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 4 * (i - 6); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 2; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 2; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1) / 2 + (i - 9) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 4 * (i - 9); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + 3 * _ecgCanvas.Width / 4; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + 3 * _ecgCanvas.Width / 4; var fp2 = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp2); } } for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (i < 6) { if (i < 3) { if (_firstPosition.X > _ecgCanvas.Width / 4 - 5) break; } else { if (_firstPosition.X > _ecgCanvas.Width / 2 - 5) break; } } else { if (i < 9) { if (_firstPosition.X > 3 * _ecgCanvas.Width / 4) break; } else { if (_firstPosition.X > _ecgCanvas.Width) break; } } var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 6) { if (i < 3) _secondPosition.X = nextX + _freePixs; else _secondPosition.X = _ecgCanvas.Width / 4 + _freePixs + nextX; } else { if (i < 9) _secondPosition.X = _ecgCanvas.Width / 2 + _freePixs + nextX; else _secondPosition.X = 3 * _ecgCanvas.Width / 4 + _freePixs + nextX; } if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], leadIndex); //绘制所有导联的QRS波群 } _points.Clear(); for (var i = 0; i < 1; i++) { var leadIndex = _leadList[ConfigHelper.SingleLead]; //取导联下标 0 1 2 3 ...11 _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1) / 2 + (i + 3) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 4 + 1)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 4 * (i + 3); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(i + LeadCount12, fp); if (_ecgDatas.Count > 0) for (var b = dataLengthIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataLengthIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { _secondPosition.X = nextX + _freePixs; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(leadIndex)) { var xp = new List { _firstPosition }; _points.Add(leadIndex, xp); } else { _points[leadIndex].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[leadIndex], leadIndex); //绘制所有导联的QRS波群 } } /// /// 绘制4x3+1导联模式标压名称--打印 /// /// /// public void PrintLeadNameFourOne(double cVoltagescale, List longLeadInfo) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount12; d++) if (d < 6) { if (d < 3) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } else { if (d < 9) { //1 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); //2 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //3 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //4 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { //1 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); //2 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //3 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //4 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(3 * _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } for (var d = 0; d < 1; d++) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y, _freePixs / 3 * 3, _firstPointArray[d + LeadCount12].Y); var str = _leadNameArray[ConfigHelper.SingleLead]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制4x3+3导联模式波形--打印 /// /// /// /// /// /// public void PrintEcgWaveFourThree(int drawInitHeight, int bottomHeight, List longLeadInfo, int dataIndex, int dataLengthIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight *= _freePixs; bottomHeight *= _freePixs; for (var i = 0; i < LeadCount12; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 6) { if (i < 3) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; // //_baseLine = _baseLine - drawInitHeight / 8 * i; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + (i - 3) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; //+ Draw_InitHeight //_baseLine = _baseLine - drawInitHeight / 8 * (i - 3); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 4; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 4; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } } else { if (i < 9) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + (i - 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; // + Draw_InitHeight //_baseLine = _baseLine - drawInitHeight / 8 * (i - 6); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 2; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 2; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } else { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + (i - 9) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; //+ Draw_InitHeight //_baseLine = _baseLine - drawInitHeight / 8 * (i - 9); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + 3 * _ecgCanvas.Width / 4; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + 3 * _ecgCanvas.Width / 4; var fp2 = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp2); } } for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (i < 6) { if (i < 3) { if (_firstPosition.X > _ecgCanvas.Width / 4 - 5) break; } else { if (_firstPosition.X > _ecgCanvas.Width / 2 - 5) break; } } else { if (i < 9) { if (_firstPosition.X > 3 * _ecgCanvas.Width / 4) break; } else { if (_firstPosition.X > _ecgCanvas.Width) break; } } var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 6) { if (i < 3) _secondPosition.X = nextX + _freePixs; else _secondPosition.X = _ecgCanvas.Width / 4 + _freePixs + nextX; } else { if (i < 9) _secondPosition.X = _ecgCanvas.Width / 2 + _freePixs + nextX; else _secondPosition.X = 3 * _ecgCanvas.Width / 4 + _freePixs + nextX; } if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], leadIndex); //绘制所有导联的QRS波群 } _points.Clear(); for (var i = 0; i < longLeadInfo.Count; i++) { var leadIndex = _leadList[longLeadInfo[i]]; //取导联下标 0 1 2 3 ...11 _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2) / 2 + (i + 3) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / (LeadCount12 / 2)) + drawInitHeight; //_baseLine = _baseLine - drawInitHeight / 8 * (i + 3); _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(i + 12, fp); if (_ecgDatas.Count > 0) for (var b = dataLengthIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataLengthIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { _secondPosition.X = nextX + _freePixs; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(leadIndex)) { var xp = new List { _firstPosition }; _points.Add(leadIndex, xp); } else { _points[leadIndex].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[leadIndex], leadIndex); //绘制所有导联的QRS波群 } } /// /// 绘制4x3+3导联模式标压名称--打印 /// /// /// public void PrintLeadNameFourThree(double cVoltagescale, List longLeadInfo) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount12; d++) if (d < 6) { if (d < 3) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 4 + _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 4 + _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } else { if (d < 9) { //1 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); //2 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //3 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //4 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 2 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 2 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 2, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } else { //1 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); // //2 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //3 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); //4 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); //5 _ecgGraphics.DrawLine(_ecgPen, 3 * _ecgCanvas.Width / 4 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, 3 * _ecgCanvas.Width / 4 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(3 * _ecgCanvas.Width / 4, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } for (var d = 0; d < longLeadInfo.Count; d++) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount12].Y, _freePixs / 3 * 3, _firstPointArray[d + LeadCount12].Y); var str = _leadNameArray[longLeadInfo[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[d + LeadCount12].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制5x3+1导联模式波形--打印 /// /// /// /// /// public void PrintEcgWaveFifteen(int drawInitHeight, int bottomHeight, int dataIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight = drawInitHeight * _freePixs; bottomHeight = bottomHeight * _freePixs; const int rowCount = 6; //分六行 #region 5x3 for (var i = 0; i < LeadCount15; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 5) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (i >= 5 && i < 10) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount / 2 + (i - 5) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 3; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 3; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (i >= 10 && i < 15) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount / 2 + (i - 10) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + 2 * _ecgCanvas.Width / 3; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + 2 * _ecgCanvas.Width / 3; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (leadIndex < LeadCount15) { for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (i < 5) if (_firstPosition.X > _ecgCanvas.Width / 3 - 5) break; if (i >= 5 && i < 10) if (_firstPosition.X > 2 * _ecgCanvas.Width / 3 - 5) break; if (i >= 10 && i < 15) if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 5) _secondPosition.X = nextX + _freePixs; if (i >= 5 && i < 10) _secondPosition.X = _ecgCanvas.Width / 3 + nextX + _freePixs; if (i >= 10 && i < 15) _secondPosition.X = 2 * _ecgCanvas.Width / 3 + _freePixs + nextX; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List(); xp.Add(_firstPosition); _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], leadIndex); //绘制所有导联的QRS波群 } } #endregion #region 任意长一导 _points.Clear(); for (var i = 0; i < 1; i++) { var leadIndex = _leadList[ConfigHelper.SingleLead]; //取导联下标 0 1 2 3 ...11 _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount / 2 + (i + 5) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / rowCount) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(i + LeadCount15, fp); if (_ecgDatas.Count > 0) for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { _secondPosition.X = nextX + _freePixs; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(leadIndex)) { var xp = new List { _firstPosition }; _points.Add(leadIndex, xp); } else { _points[leadIndex].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[leadIndex], leadIndex); //绘制所有导联的QRS波群 } #endregion } /// /// 绘制5x3+1导联模式标压名称--打印 /// /// /// public void PrintLeadNameFifteen(double cVoltagescale, string leaderType) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount15; d++) { if (d < 5) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } if (d >= 5 && d < 10) { _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } if (d >= 10 && d < 15) { _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; if (d >= 12 && leaderType == "LeaderR") str = _leadNameArray[_leadList[d] + 3]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(2 * _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } for (var d = 0; d < 1; d++) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[d + LeadCount15].Y, _freePixs / 5, _firstPointArray[d + LeadCount15].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount15].Y, _freePixs / 5, _firstPointArray[d + LeadCount15].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[d + LeadCount15].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount15].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount15].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[d + LeadCount15].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[d + LeadCount15].Y, _freePixs / 3 * 3, _firstPointArray[d + LeadCount15].Y); var str = _leadNameArray[ConfigHelper.SingleLead]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[d + LeadCount15].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } /// /// 绘制6x3导联模式波形--打印 /// /// /// /// public void PrintEcgWaveEighteen(int drawInitHeight, int bottomHeight, int dataIndex) { _points.Clear(); _firstPointArray.Clear(); drawInitHeight = drawInitHeight * _freePixs; bottomHeight = bottomHeight * _freePixs; for (var i = 0; i < LeadCount18; i++) { var leadIndex = _leadList[i]; //取导联下标 0 1 2 3 ...11 if (i < 6) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6 / 2 + i * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (i >= 6 && i < 12) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6 / 2 + (i - 6) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + _ecgCanvas.Width / 3; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + _ecgCanvas.Width / 3; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (i >= 12 && i < 18) { _baseLine = (_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6 / 2 + (i - 12) * ((_ecgCanvas.Height - drawInitHeight - bottomHeight) / 6) + drawInitHeight; _firstPosition.Y = _baseLine; _firstPosition.X = _freePixs + 2 * _ecgCanvas.Width / 3; _secondPosition.Y = _baseLine; _secondPosition.X = _freePixs + 2 * _ecgCanvas.Width / 3; var fp = new Point(_firstPosition.X + _freePixs, _firstPosition.Y); _firstPointArray.Add(leadIndex, fp); } if (leadIndex < LeadCount18) { for (var b = dataIndex; b < _ecgDatas[leadIndex].Count; b += 1000 / ConfigHelper.PrintSampleRate) { if (i < 6) if (_firstPosition.X > _ecgCanvas.Width / 3 - 5) break; if (i >= 6 && i < 12) if (_firstPosition.X > 2 * _ecgCanvas.Width / 3 - 5) break; if (i >= 12 && i < 18) if (_firstPosition.X > _ecgCanvas.Width) break; var yValues = _ecgDatas[leadIndex][b] * (_dpi / _lenthPerInch) * _amplitude * PrintInch; _secondPosition.Y = _baseLine - (int)yValues; //后一点Y轴位置 var x = (b - dataIndex) * _intervalPixCountPerPoint; var nextX = (int)x; if (Math.Abs(_firstPosition.X - _secondPosition.X) < 5) { if (i < 6) _secondPosition.X = nextX + _freePixs; if (i >= 6 && i < 12) _secondPosition.X = _ecgCanvas.Width / 3 + nextX + _freePixs; if (i >= 12 && i < 18) _secondPosition.X = 2 * _ecgCanvas.Width / 3 + _freePixs + nextX; if (_firstPosition.X != _secondPosition.X && _firstPosition.Y == _secondPosition.Y) // { _ecgGraphics.DrawLine(_ecgPen, _firstPosition, _secondPosition); } else { if (!_points.ContainsKey(i)) { var xp = new List { _firstPosition }; _points.Add(i, xp); } else { _points[i].Add(_firstPosition); } } } _firstPosition = _secondPosition; } PointContrast(_points[i], leadIndex); //绘制所有导联的QRS波群 } } } /// /// 绘制6x3导联模式标压名称--显示 /// /// public void PrintLeadNameEighteen(double cVoltagescale) { _ecgPen = new Pen(Color.Black, float.Parse("1")); for (var d = 0; d < LeadCount18; d++) { if (d < 6) { _ecgGraphics.DrawLine(_ecgPen, 0, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale)); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y - (short)Math.Round(_freePixs * cVoltagescale), _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _freePixs * 5 / 6, _firstPointArray[_leadList[d]].Y, _freePixs / 3 * 3, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(0, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } if (d >= 6 && d < 12) { _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, _ecgCanvas.Width / 3 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(_ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } if (d >= 12 && d < 18) { _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs)); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y - (short)Math.Round(cVoltagescale * _freePixs), 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawLine(_ecgPen, 2 * _ecgCanvas.Width / 3 + _freePixs / 6 * 5, _firstPointArray[_leadList[d]].Y, 2 * _ecgCanvas.Width / 3 + _freePixs, _firstPointArray[_leadList[d]].Y); var str = _leadNameArray[_leadList[d]]; var font = new Font("宋体", 11); var brush = Brushes.Black; if (d < _firstPointArray.Count) { var point = new PointF(2 * _ecgCanvas.Width / 3, _firstPointArray[_leadList[d]].Y); _ecgGraphics.DrawString(str, font, brush, point); } } } } private float GetStrWidth(string text) { var array = text.ToCharArray(); return array.Sum(it => it >= 0x4e00 && it <= 0x9fbb ? 4.26f : 2.13f); //return c.Any(t => t >= 0x4e00 && t <= 0x9fbb); } } }