using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Mesnac.Controls.ChemicalWeighing.HslCurve
{
///
/// 曲线功能相关的一些静态的辅助绘画方法。
///
// Token: 0x02000021 RID: 33
public class HslCurveHelper
{
///
/// 将文本绘制到指定的位置
///
///
///
///
///
///
///
// Token: 0x060002DA RID: 730 RVA: 0x00021A1C File Offset: 0x0001FC1C
public static void DrawTextByPoint(Graphics g, string text, PointF center, Font font, Brush brush, MarkTextPositionStyle markTextPosition, int markTextOffect)
{
bool flag = !string.IsNullOrEmpty(text);
if (flag)
{
switch (markTextPosition)
{
case MarkTextPositionStyle.Up:
g.DrawString(text, font, brush, new RectangleF(center.X - 100f, center.Y - (float)font.Height - (float)markTextOffect, 200f, (float)(font.Height + 2)), HslHelper.StringFormatCenter);
break;
case MarkTextPositionStyle.Right:
g.DrawString(text, font, brush, new RectangleF(center.X + (float)markTextOffect, center.Y - (float)font.Height - (float)markTextOffect, 100f, (float)(font.Height + markTextOffect)), HslHelper.StringFormatLeft);
break;
case MarkTextPositionStyle.Down:
g.DrawString(text, font, brush, new RectangleF(center.X - 100f, center.Y + (float)markTextOffect, 200f, (float)(font.Height + 2)), HslHelper.StringFormatCenter);
break;
case MarkTextPositionStyle.Left:
g.DrawString(text, font, brush, new RectangleF(center.X - 100f, center.Y - (float)font.Height - (float)markTextOffect, (float)(100 - markTextOffect), (float)(font.Height + markTextOffect)), HslHelper.StringFormatRight);
break;
case MarkTextPositionStyle.Center:
g.DrawString(text, font, brush, new RectangleF(center.X - 100f, center.Y - (float)font.Height, 200f, (float)(font.Height * 2)), HslHelper.StringFormatCenter);
break;
}
}
}
///
/// 绘制 类型的标记数据到曲线图形上去
///
/// 会话资源
/// 标记信息
/// 中心点
/// 字体信息
/// 绘制的文本放向
// Token: 0x060002DB RID: 731 RVA: 0x00021BBC File Offset: 0x0001FDBC
public static void DrawHslMarkTextPoint(Graphics g, HslMarkText markText, PointF center, Font font, MarkTextPositionStyle markTextPosition)
{
bool flag = markText == null;
if (!flag)
{
g.FillEllipse(markText.CircleBrush, new RectangleF(center.X - 3f, center.Y - 3f, 6f, 6f));
bool flag2 = !string.IsNullOrEmpty(markText.MarkText);
if (flag2)
{
HslCurveHelper.DrawTextByPoint(g, markText.MarkText, center, font, markText.TextBrush, markTextPosition, markText.MarkTextOffect);
}
bool flag3 = markText.MarkImage != null;
if (flag3)
{
switch (markTextPosition)
{
case MarkTextPositionStyle.Up:
g.DrawImage(markText.MarkImage, new PointF(center.X - (float)(markText.MarkImage.Width / 2), center.Y - (float)markText.MarkImage.Height - (float)markText.MarkTextOffect));
break;
case MarkTextPositionStyle.Right:
g.DrawImage(markText.MarkImage, new PointF(center.X + (float)markText.MarkTextOffect, center.Y - (float)markText.MarkImage.Height - (float)markText.MarkTextOffect));
break;
case MarkTextPositionStyle.Down:
g.DrawImage(markText.MarkImage, new PointF(center.X - (float)(markText.MarkImage.Width / 2), center.Y + (float)markText.MarkTextOffect));
break;
case MarkTextPositionStyle.Left:
g.DrawImage(markText.MarkImage, new PointF(center.X - (float)markText.MarkImage.Width - (float)markText.MarkTextOffect, center.Y - (float)markText.MarkImage.Height - (float)markText.MarkTextOffect));
break;
case MarkTextPositionStyle.Center:
g.DrawImage(markText.MarkImage, new PointF(center.X - (float)(markText.MarkImage.Width / 2), center.Y - (float)(markText.MarkImage.Height / 2)));
break;
}
}
}
}
///
/// 核心绘制曲线的方法,根据曲线的基本样式信息,所有的点的情况,点的圆点信息
///
/// 绘图上下文
/// 曲线的基本样式信息
/// 所有的点的信息
/// 如果点位想要突出显示,就设置大于0
/// 基准的Y点位信息
// Token: 0x060002DC RID: 732 RVA: 0x00021DCC File Offset: 0x0001FFCC
public static void DrawLineCore(Graphics g, HslCurveItem line, List listPoints, int pointsRadius, float referenceY = -1f)
{
bool flag = listPoints.Count <= 1;
if (!flag)
{
using (Pen pen = new Pen(line.LineColor, line.LineThickness))
{
bool flag2 = line.Style == CurveStyle.LineSegment;
if (flag2)
{
g.DrawLines(pen, listPoints.ToArray());
}
else
{
bool flag3 = line.Style == CurveStyle.Curve;
if (flag3)
{
g.DrawCurve(pen, listPoints.ToArray());
}
else
{
bool flag4 = line.Style == CurveStyle.LineDot;
if (flag4)
{
pen.DashStyle = DashStyle.Dot;
g.DrawLines(pen, listPoints.ToArray());
}
else
{
bool flag5 = line.Style == CurveStyle.CurveDot;
if (flag5)
{
pen.DashStyle = DashStyle.Dot;
g.DrawCurve(pen, listPoints.ToArray());
}
else
{
bool flag6 = line.Style == CurveStyle.LineDash;
if (flag6)
{
pen.DashStyle = DashStyle.Dash;
g.DrawLines(pen, listPoints.ToArray());
}
else
{
bool flag7 = line.Style == CurveStyle.CurveDash;
if (flag7)
{
pen.DashStyle = DashStyle.Dash;
g.DrawCurve(pen, listPoints.ToArray());
}
else
{
bool flag8 = line.Style == CurveStyle.LineLongDath;
if (flag8)
{
pen.DashStyle = DashStyle.Custom;
pen.DashPattern = new float[]
{
5f,
5f
};
g.DrawLines(pen, listPoints.ToArray());
}
else
{
bool flag9 = line.Style == CurveStyle.CurveLongDath;
if (flag9)
{
pen.DashStyle = DashStyle.Custom;
pen.DashPattern = new float[]
{
5f,
5f
};
g.DrawCurve(pen, listPoints.ToArray());
}
else
{
bool flag10 = line.Style == CurveStyle.Section;
if (flag10)
{
g.DrawCurve(pen, listPoints.ToArray());
bool flag11 = listPoints.Count > 0;
if (flag11)
{
GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddCurve(listPoints.ToArray());
graphicsPath.AddLines(new PointF[]
{
listPoints[listPoints.Count - 1],
new PointF(listPoints[listPoints.Count - 1].X, referenceY),
new PointF(listPoints[0].X, referenceY),
new PointF(listPoints[0].X, listPoints[0].Y)
});
using (Brush brush = new SolidBrush(Color.FromArgb(64, pen.Color)))
{
g.FillPath(brush, graphicsPath);
}
}
}
else
{
for (int i = 0; i < listPoints.Count - 1; i++)
{
PointF pointF = new PointF(listPoints[i + 1].X, listPoints[i].Y);
g.DrawLine(pen, listPoints[i], pointF);
bool flag12 = line.Style == CurveStyle.StepLine;
if (flag12)
{
g.DrawLine(pen, pointF, listPoints[i + 1]);
}
}
}
}
}
}
}
}
}
}
}
}
bool flag13 = pointsRadius > 0;
if (flag13)
{
using (Brush brush2 = new SolidBrush(line.LineColor))
{
for (int j = 0; j < listPoints.Count; j++)
{
g.FillEllipse(brush2, listPoints[j].X - (float)pointsRadius, listPoints[j].Y - (float)pointsRadius, (float)(pointsRadius * 2), (float)(pointsRadius * 2));
}
}
}
}
}
}
}