using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Uninpho.Railway.Waveform
{
///
/// 绘图类
///
class DrawFunClass
{
///
/// 坐标转换
///
/// Graphics g
/// 距离左上角屏幕坐标系的x的相对位置(偏移量)
/// 距离左上角屏幕坐标系的y的相对位置(偏移量)
public static void Trans(Graphics g, float dx, float dy)
{
Matrix mymatrix = new Matrix(1, 0, 0, -1, 0, 0);
g.Transform = mymatrix;
g.TranslateTransform(dx, dy, MatrixOrder.Append);
}
///
/// 绘制一条波形图曲线
///
/// Graphics g
/// 点集
public static void DrawCuvreFun(Graphics graphics, PointF[] points, Color color, int width)
{
if (points.Length >= 2)
{
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.DrawCurve(new Pen(color, width), points);
}
}
///
/// 绘制折线
///
/// Graphics g
/// 点集
public static void DrawLinesFun(Graphics graphics, PointF[] points, Color color, int width)
{
if (points.Length >= 2)
{
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.DrawLines(new Pen(color, width), points);
}
}
public static void DrawScaleLine(Graphics graphics, PointF points1, PointF points2, Color color, int width)
{
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.DrawLine(new Pen(color, width), points1, points2);
}
public static void DrawScaleString(Graphics graphics, PointF points, Color color, int size, string s , int Xpianyi)
{
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
StringFormat fomt = new StringFormat();
fomt.LineAlignment = StringAlignment.Center;
fomt.Alignment = StringAlignment.Center;
Matrix oldtrans = graphics.Transform;
Font goodFont = new Font("MS UI Gothic", size);
graphics.ResetTransform();
graphics.DrawString(s, goodFont, new SolidBrush(color), points.X + Xpianyi, points.Y - 20, fomt);
graphics.Transform = oldtrans;
}
}
}