ECGPrint/1200Gxml心电图绘制/ecgMeasure.cs

77 lines
3.1 KiB
C#
Raw Normal View History

2024-12-25 17:24:22 +08:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace _1200Gxml心电图绘制
{
public class ecgMeasure
{
//画垂直的 和水平的线
public void Draw_Measure(Bitmap bit, Point p1, Point p2)
{
Graphics gg = Graphics.FromImage(bit);
Pen pp = new Pen(Color.Blue, float.Parse("1"));
Pen pp1 = new Pen(Color.Blue, float.Parse("1"));
//画水平线
gg.DrawLine(pp, new Point(p1.X,0), new Point(p1.X, bit.Height));
gg.DrawLine(pp1, p1, p2);
gg.DrawLine(pp1, p1.X, p1.Y, p1.X, p1.Y - 3);
gg.DrawLine(pp1, p2.X, p2.Y, p2.X, p2.Y - 3);
gg.DrawLine(pp, new Point(p2.X, 0), new Point(p2.X, bit.Height));
double ecgValue = ((double.Parse((p2.X - p1.X).ToString()) / (96 / 25.4)) / 25) * 1000;
string heartRate = ((int)60000 / ecgValue).ToString("0.0");
if (ecgValue > 0)
Draw_Rectangular_And_Text(bit, p2.X, p2.Y, ((int)ecgValue).ToString() + " 毫秒,心率:"+ heartRate);
//Graphics gg = Graphics.FromImage(bit);
//Pen pp = new Pen(Color.Blue, float.Parse("3"));
////画水平线
//gg.DrawLine(pp, p1, p2);
//gg.DrawLine(pp, p1.X, p1.Y, p1.X, p1.Y - 3);
//gg.DrawLine(pp, p2.X, p2.Y, p2.X, p2.Y - 3);
//double ecgValue=((double.Parse((p2.X - p1.X).ToString())/(96/25.4))/25)*1000;
//Draw_Rectangular_And_Text(bit, p2.X, p2.Y, ((int)ecgValue).ToString() + " 毫秒");
}
//垂直的线
public void Draw_V_Measure(Bitmap bit, Point p1, Point p2)
{
Graphics gg = Graphics.FromImage(bit);
Pen pp = new Pen(Color.Red, float.Parse("1"));
//画水平线
//gg.DrawLine(pp, p1, p2);
gg.DrawLine(pp, p1.X - 10, p1.Y, p2.X - 10, p2.Y);
gg.DrawLine(pp, 0, p1.Y, bit.Width , p1.Y);
gg.DrawLine(pp, 0, p2.Y, bit.Width, p2.Y);
//gg.DrawLine(pp, p1.X - 10, p1.Y, p2.X - 10, p2.Y);
//gg.DrawLine(pp, p1.X - 10, p1.Y, p1.X + 30, p1.Y);
//gg.DrawLine(pp, p2.X - 10, p2.Y, p2.X + 30, p2.Y);
double ecgMV = ((double.Parse((p2.Y - p1.Y).ToString()) / ((96 / 25.4) * 10)));
if (ecgMV < 0)
ecgMV = -ecgMV;
if (p1.Y < p2.Y)
Draw_Rectangular_And_Text(bit, p1.X + 10, p1.Y, ecgMV.ToString("0.000") + " mv");
else
Draw_Rectangular_And_Text(bit, p2.X + 10, p2.Y, ecgMV.ToString("0.000") + " mv");
}
//画矩形和文字
public void Draw_Rectangular_And_Text(Bitmap bit, int x, int y, string Text)
{
//画垂直线
Graphics gg = Graphics.FromImage(bit);
Font font = new Font("宋体", 15,FontStyle.Bold); //字体
Brush brush = Brushes.Red; //字体颜色;
PointF point = new PointF(x, y); //写字的起始位置
gg.DrawString(Text, font, brush, point);
}
}
}