List<double> labels = form.channelData2[kp.Key];
List<double> listY = kp.Value;
int labelSpan = 0;
if (form.currentMode2.display == DMAppConfig.Display.S30 || form.currentMode2.display == DMAppConfig.Display.S15 || form.currentMode2.display == DMAppConfig.Display.S10 || form.currentMode2.display == DMAppConfig.Display.S5)
labelSpan = form.maxSampleRate2;
else if (form.currentMode2.display == DMAppConfig.Display.S60 || form.currentMode2.display == DMAppConfig.Display.M2 || form.currentMode2.display == DMAppConfig.Display.M5 || form.currentMode2.display == DMAppConfig.Display.M10)
labelSpan = form.maxSampleRate2 * form.currentMode2.totalSeconds / Properties.Settings.Default.Spo2PulsePointDensity;
if (labels != null && labelSpan != 0 && labels.Count == listY.Count) //Spo2和pulse点标记的文字
{
int labelX = labelSpan / 2;
//重新设置画布,否则会出现坐标错乱的现象
while (labelX < labels.Count)
{
Graphics g3 = Graphics.FromImage(bmp);
g3.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
double label = labels[labelX];
int X0 = (int)(labelX * width * 1.0 / listY.Count);
int Y0 = (int)listY[labelX] - baseline;
string text = label.ToString("f0");
Font font = new Font("宋体", 8, FontStyle.Regular);
SizeF labelSize = g3.MeasureString(text, font);
int labelWidth = (int)(labelSize.Width * 1.2);
int labelHeight = (int)(labelSize.Height);
Rectangle rect = new Rectangle(X0 + offset, height - Y0 - 18, (int)labelWidth, (int)labelHeight);
g3.TranslateTransform(X0 + offset+ labelWidth/2, height - Y0 - 18+ labelHeight/2);
g3.RotateTransform(-45);
g3.DrawString(text, font, new SolidBrush(XMLSerializerManager.DeserializeColor(channel.lineColor)), 0,0, labelFormat);//绘制显示数字
//g2.DrawString(text, font, new SolidBrush(XMLSerializerManager.DeserializeColor(channel.lineColor)), rect, labelFormat);//绘制显示数字
labelX += labelSpan;
g3.Dispose();
}
}
本文来自博客园,作者:*大梦春秋,转载请注明原文链接:https://www.cnblogs.com/foryouforever/p/16519741.html
浙公网安备 33010602011771号