C# 绘制电压电流六角图

2022-07-18 更新 (大家尽量用网站显示的核心代码,百度网盘的没有更新)

效果图

源码地址 链接: https://pan.baidu.com/s/1QYX0aEmHaCxQuHsVIGsmaA?pwd=2fw6 提取码: 2fw6 

以下是核心源码

public class Line
{//原创来自 www.luofenming.com
    private double x1, x2, y1, y2;
    private Color Color;

    public Line(double X1, double Y1, double X2, double Y2, Color color)
    {
        this.x1 = X1;
        this.x2 = X2;
        this.y1 = Y1;
        this.y2 = Y2;
        this.Color = color;
    }

    public void DrawLine(Graphics gr)
    {
        DrawLine(gr, this.Color);
    }

    public void DrawLine(Graphics gr, Color color)
    {
        Pen p;
        if (color == Color.Black) { p = new Pen(color, 1); } else { p = new Pen(color, 2); }

        System.Drawing.Drawing2D.AdjustableArrowCap lineArrow = new System.Drawing.Drawing2D.AdjustableArrowCap(4, 4, true);
        p.CustomEndCap = lineArrow;

        gr.DrawLine(p, (int)this.x2, (int)this.y2, (int)this.x1, (int)this.y1);
    }

    public void DrawLine(Graphics gr, System.Drawing.Drawing2D.DashStyle DashStyle)
    {
        DrawLine(gr, this.Color, DashStyle);
    }


    public void DrawLine(Graphics gr, Color color, System.Drawing.Drawing2D.DashStyle DashStyle)
    {
        lock (gr)
        {
            Pen p = null;
            if (color == Color.Black) { p = new Pen(color, 1); } else { p = new Pen(color, 2); }

            System.Drawing.Drawing2D.AdjustableArrowCap lineArrow = new System.Drawing.Drawing2D.AdjustableArrowCap(4, 4, true);
            p.CustomEndCap = lineArrow;
            p.DashStyle = DashStyle;
            gr.DrawLine(p, (int)this.x2, (int)this.y2, (int)this.x1, (int)this.y1);
        }
    }
}
public class LiuJiaoTu
{//原创来自 www.luofenming.com
    const double PI = 3.1415926;
    /// <summary>
    /// 画出六角图
    /// </summary>
    /// <param name="JUAC">电压 AC夹角</param>
    /// <param name="JUAB">电压 AB夹角</param>
    /// <param name="JUBC">电压 BC夹角</param>
    /// <param name="JIAC">电流 AC夹角</param>
    /// <param name="UA">A相电压</param>
    /// <param name="UB">B相电压</param>
    /// <param name="UC">C相电压</param>
    /// <param name="IA">A相电流</param>
    /// <param name="IB">B相电流</param>
    /// <param name="IC">C相电流</param>
    /// <param name="JA">A相电压与电流夹角</param>
    /// <param name="JB">B相电压与电流夹角</param>
    /// <param name="JC">C相电压与电流夹角</param>
    /// <param name="isThird">true 三相三相    false 三相四线</param>
    /// <param name="width">图片的 宽</param>
    /// <param name="height">图片的 高</param>
    /// <returns></returns>
    public Bitmap CreateLiuJiaoTu(string JUAC, string JUAB, string JUBC, string JIAC,
                                    string UA, string UB, string UC,
                                    string IA, string IB, string IC,
                                    string JA, string JB, string JC,
                                     bool isThird, int width = 260, int height = 260)
    {
        double JUac = StringToDouble(JUAC);
        double JUab = StringToDouble(JUAB);
        double JUbc = StringToDouble(JUBC);
        double JIac = StringToDouble(JIAC);

        double Ua = StringToDouble(UA);
        double Ub = StringToDouble(UB);
        double Uc = StringToDouble(UC);

        double Ia = StringToDouble(IA);
        double Ib = StringToDouble(IB);
        double Ic = StringToDouble(IC);

        double Ja = StringToDouble(JA);
        double Jb = StringToDouble(JB);
        double Jc = StringToDouble(JC);
        return CreateLiuJiaoTu(JUac, JUab, JUbc, JIac, Ua, Ub, Uc, Ia, Ib, Ic, Ja, Jb, Jc, isThird, width, height);
    }
    /// <summary>
    /// 画出六角图
    /// </summary>
    /// <param name="JUAC">电压 AC夹角</param>
    /// <param name="JUAB">电压 AB夹角</param>
    /// <param name="JUBC">电压 BC夹角</param>
    /// <param name="JIAC">电流 AC夹角</param>
    /// <param name="UA">A相电压</param>
    /// <param name="UB">B相电压</param>
    /// <param name="UC">C相电压</param>
    /// <param name="IA">A相电流</param>
    /// <param name="IB">B相电流</param>
    /// <param name="IC">C相电流</param>
    /// <param name="JA">A相电压与电流夹角</param>
    /// <param name="JB">B相电压与电流夹角</param>
    /// <param name="JC">C相电压与电流夹角</param>
    /// <param name="isThird">true 三相三相    false 三相四线</param>
    /// <param name="width">图片的 宽</param>
    /// <param name="height">图片的 高</param>
    /// <returns></returns>
    public Bitmap CreateLiuJiaoTu(double JUAC, double JUAB, double JUBC, double JIAC,
                                    double UA, double UB, double UC,
                                    double IA, double IB, double IC,
                                    double JA, double JB, double JC,
                                     bool isThird, int width = 260, int height = 260)
    {
        Bitmap LoadBitMap = new Bitmap(width, height);
        Graphics Ljt_Gs = Graphics.FromImage(LoadBitMap);
        Ljt_Gs.FillRectangle(Brushes.White, new Rectangle(0, 0, width, height));
        Ljt_Gs.Clear(Color.White);

        JUAC = JUAC % 360;
        if (JUAC > 180) { JUAC = JUAC - 360; }

        JUAB = JUAB % 360;
        if (JUAB > 180) { JUAB = JUAB - 360; }

        JUBC = JUBC % 360;
        if (JUBC > 180) { JUBC = JUBC - 360; }

        JIAC = JIAC % 360;
        if (JIAC > 180) { JIAC = JIAC - 360; }

        double[] U = new double[] { UA, UB, UC };
        double[] I = new double[] { IA, IB, IC };
        double[] J = new double[] { JA, JB, JC };

        double[,] LiuJiaoTuData = new double[8, 2];

        if (Math.Abs(JUAC - 360) >= 40 && Math.Abs(JUAC - 360) <= 80 && U[0] != 0 && (U[2] != 0 || isThird) && Math.Abs(U[1]) <= 0.005 && Math.Abs(I[1]) <= 0.005)
        {
            Calate3Six(JUAC - 360, JIAC, width / 4 * 1.5, height / 4, U, I, J, ref LiuJiaoTuData);    //计算坐标三相三线   
            Drow3Six(Ljt_Gs, J, JUAC, LiuJiaoTuData, width / 2, height / 2);//画六角图;  
        }
        else if (Math.Abs(JUAC) >= 40 && Math.Abs(JUAC) <= 80 && U[0] != 0 && (U[2] != 0 || isThird) && Math.Abs(U[1]) <= 0.005 && Math.Abs(I[1]) <= 0.005)
        {
            Calate3Six(JUAC, JIAC, width / 4 * 1.5, height / 4, U, I, J, ref LiuJiaoTuData);    //计算坐标三相三线   
            Drow3Six(Ljt_Gs, J, JUAC, LiuJiaoTuData, width / 2, height / 2);//画六角图;  
        }
        else
        {
            Calate4Six(JUAB, JUAC, JUBC, width / 4 * 1.5, height / 4, U, I, J, ref LiuJiaoTuData);   //计算坐标三相四线  
            Drow4Six(Ljt_Gs, J, JUAC, JUAB, LiuJiaoTuData, width / 2, height / 2);//画六角图;  
        }
        return LoadBitMap;
    }
    /// <summary> 求三个浮点数中的绝对值最大数 </summary> 
    /// <returns></returns>
    private double Max3(double x, double y, double z)
    {
        double x1, y1, z1;
        double max3;

        x1 = Math.Abs(x);
        y1 = Math.Abs(y);
        z1 = Math.Abs(z);
        if (x1 == 0 && y1 == 0 && z1 == 0)
        {
            max3 = 0;
        }
        else if (x1 >= y1 && x1 >= z1)
        {
            max3 = x1;
        }
        else if (y1 >= x1 && y1 >= z1)
        {
            max3 = y1;
        }
        else
        {
            max3 = z1;
        }
        return max3;
    }
    /// <summary>把字符串转成小数字, 主意: 不能转换着返回 0</summary> 
    private double StringToDouble(string InString)
    {
        double Tmp;
        double.TryParse(InString, out Tmp);
        return Tmp;
    }
    /// <summary>三相三线六角图</summary>
    /// <param name="fFUac1">Ubc夹角</param>
    /// <param name="fFIac1">Iac夹角</param>
    /// <param name="ZoomU1">U半径</param>
    /// <param name="ZoomI1">I半径</param>
    /// <param name="fUrms_A1">U数组</param>
    /// <param name="fIrms_A1">I数据</param>
    /// <param name="fPhasic_A1">角度数据</param>
    /// <param name="LiuJiaoTu1">六角图数据</param>
    private void Calate3Six(double JUBC, double jIac, double ZoomU1, double ZoomI1, double[] U, double[] I, double[] J, ref double[,] LiuJiaoTu1)
    {
        double DrawLen;
        double VUa;
        double VUb;
        double VUc = 0;
        double[] fUrms_A = U;
        double[] fIrms_A = I;
        double[] fPhasic_A = J;
        double[,] LiuJiaoTu = LiuJiaoTu1;
        double ZoomU = ZoomU1;
        double fFUac = JUBC;
        double ZoomI = ZoomI1;
        DrawLen = 400d;
        ZoomU = ZoomU * 1d;
        ZoomI = ZoomI * 0.9d;
        VUa = fUrms_A[0] * 1.73 / 3;//长度
        VUb = fUrms_A[0] * 1.73 / 3;

        JUBC = JUBC % 360;
        if (JUBC > 180) { JUBC = JUBC - 360; }

        jIac = jIac % 360;
        if (jIac > 180) { jIac = jIac - 360; }

        for (int i = 0; i < J.Length; i++)
        {
            J[i] = J[i] % 360;
            if (J[i] > 180) { J[i] = J[i] % 360 - 360; }
        }


        if (fFUac >= 0)
        {
            VUc = Math.Sqrt(VUb * VUb + fUrms_A[2] * fUrms_A[2] - 2 * VUb * fUrms_A[2] * Math.Cos((fFUac - 30) * PI / 180));
        }

        if (fFUac < 0)
        {
            VUc = Math.Sqrt(VUb * VUb + fUrms_A[2] * fUrms_A[2] - 2 * VUb * fUrms_A[2] * Math.Cos((fFUac + 30) * PI / 180));
        }

        for (int Lj = 0; Lj < 8; Lj++)
        {
            if (Lj == 6 || Lj == 7)
            {
                DrawLen = Max3(fUrms_A[0], fUrms_A[2], 0d); //Ua,Uc
            }
            else if (Lj == 1 || Lj == 3 || Lj == 5)
            {
                DrawLen = Max3(fIrms_A[0], fIrms_A[1], fIrms_A[2]);
            }

            if (Lj == 0 || Lj == 2 || Lj == 4)
            {
                DrawLen = Max3(VUa, VUb, VUc);  //Ua,Ub,Uc
            }
            if (Lj == 0 && DrawLen != 0) /////////////////Ua
            {
                LiuJiaoTu[Lj, 0] = LiuJiaoTu[Lj, 0] - (VUa * ZoomU / DrawLen) * Math.Sin(0d * PI / 180);
                LiuJiaoTu[Lj, 1] = LiuJiaoTu[Lj, 0] - (VUa * ZoomU / DrawLen) * Math.Cos(0d * PI / 180);
            }
            else if (Lj == 2 && DrawLen != 0)  ///////////////Ub
            {
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = (VUb * ZoomU / DrawLen) * Math.Sin(60 * PI / 180);
                    LiuJiaoTu[Lj, 1] = (VUb * ZoomU / DrawLen) * Math.Cos(60 * PI / 180);
                }
                else if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = -(VUb * ZoomU / DrawLen) * Math.Sin(60 * PI / 180);
                    LiuJiaoTu[Lj, 1] = (VUb * ZoomU / DrawLen) * Math.Cos(60 * PI / 180);
                }
            }
            else if (Lj == 4 && DrawLen != 0) //////////////Uc
            {
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = -(VUc * ZoomU / DrawLen) * Math.Sin(60 * PI / 180);
                    LiuJiaoTu[Lj, 1] = (VUc * ZoomU / DrawLen) * Math.Cos(60 * PI / 180);
                }
                if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = (VUc * ZoomU / DrawLen) * Math.Sin(60 * PI / 180);
                    LiuJiaoTu[Lj, 1] = (VUc * ZoomU / DrawLen) * Math.Cos(60 * PI / 180);
                }
            }
            else if (Lj == 1 && DrawLen != 0)  //////////////////Ia
            {
                double K = (fIrms_A[0] / DrawLen); ///Ia
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((120 - fPhasic_A[0]) * PI / 180) * K);  //ΦUIa
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((120 - fPhasic_A[0]) * PI / 180) * K);
                }
                if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((60 - fPhasic_A[0]) * PI / 180) * K);
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((60 - fPhasic_A[0]) * PI / 180) * K);
                }
            }
            else if (Lj == 5 && DrawLen != 0) ////////////////////Ic
            {
                double K = (fIrms_A[2] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((120 - fPhasic_A[2] - fFUac) * PI / 180) * K);
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((120 - fPhasic_A[2] - fFUac) * PI / 180) * K);
                }
                if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((60 - fPhasic_A[2] - fFUac) * PI / 180) * K);
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((60 - fPhasic_A[2] - fFUac) * PI / 180) * K);
                }
            }
            else if (Lj == 6 && DrawLen != 0)/////////////////////////ΦUab
            {
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = -(ZoomU) * fUrms_A[0] / DrawLen * Math.Sin(30 * PI / 180);  //Ua
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * fUrms_A[0] / DrawLen * Math.Cos(30 * PI / 180);
                }
                if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = ZoomU * fUrms_A[0] / DrawLen * Math.Sin(30 * PI / 180);
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * fUrms_A[0] / DrawLen * Math.Cos(30 * PI / 180);
                }
            }
            else if (Lj == 7 && DrawLen != 0)  ///////////////////////Ucb
            {
                if (fFUac < 0)
                {
                    LiuJiaoTu[Lj, 0] = -(ZoomU) * fUrms_A[2] / DrawLen * Math.Sin((30 - fFUac) * PI / 180);  //Uc
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * fUrms_A[2] / DrawLen * Math.Cos((30 - fFUac) * PI / 180);
                }
                if (fFUac > 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * fUrms_A[2] / DrawLen * Math.Sin((30 + fFUac) * PI / 180);//Uc;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * fUrms_A[2] / DrawLen * Math.Cos((30 + fFUac) * PI / 180);
                }
            }
            else
            {
                LiuJiaoTu[Lj, 0] = 0;
                LiuJiaoTu[Lj, 1] = 0;
            }
        }
    }


    /// <summary>三相四线六角图</summary>
    /// <param name="fFUac1">Uab夹角</param>
    /// <param name="fFIac1">Uac夹角</param>
    /// <param name="fFIac1">Ibc夹角</param>
    /// <param name="ZoomU1">U半径</param>
    /// <param name="ZoomI1">I半径</param>
    /// <param name="fUrms_A1">U数组</param>
    /// <param name="fIrms_A1">I数据</param>
    /// <param name="fPhasic_A1">角度数据</param>
    /// <param name="LiuJiaoTu1">六角图数据</param>
    private void Calate4Six(double jUab, double jUac, double jUbc, double ZoomU1, double ZoomI1, double[] U, double[] I, double[] J, ref double[,] LiuJiaoTu1)
    {
        double DrawLen;
        double[] fUrms_A = U;
        double[] fIrms_A = I;
        double[] fPhasic_A = J;
        double[,] LiuJiaoTu = LiuJiaoTu1;

        double ZoomU = ZoomU1;
        double fFUac = jUac;
        double fFUab = jUab;
        double fFUcb = jUbc;
        double ZoomI = ZoomI1;

        for (int Lj = 0; Lj < 8; Lj++)
        {
            if (Lj == 0 || Lj == 2 || Lj == 4)
            {
                DrawLen = Max3(fUrms_A[0], fUrms_A[1], fUrms_A[2]);
            }
            else
            {
                DrawLen = Max3(fIrms_A[0], fIrms_A[1], fIrms_A[2]);
            }
            if (Lj == 0 && DrawLen != 0)  ////////////////////////Ua
            {
                double K = (fUrms_A[Lj] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos(90 * PI / 180) * K;
                LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin(90 * PI / 180) * K;
            }
            else if (Lj == 2 && DrawLen != 0) /////////////////Ub
            {
                double K = (fUrms_A[1] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fUrms_A[1] != 0) //ub!=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos((90 - fFUab) * PI / 180) * K;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin((90 - fFUab) * PI / 180 * K);
                }
                else
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos((90 - 120) * PI / 180) * K;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin((90 - 120) * PI / 180) * K;
                }
            }
            else if (Lj == 4 && DrawLen != 0)  //Uc
            {
                double K = (fUrms_A[2] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fUrms_A[0] != 0)  //ua!=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos((90 - fFUac) * PI / 180) * K;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin((90 - fFUac) * PI / 180) * K;
                }
                else
                    if (fUrms_A[1] == 0) //ua=0 ub=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos((90 + 120) * PI / 180) * K;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin((90 + 120) * PI / 180) * K;
                }
                else
                {
                    LiuJiaoTu[Lj, 0] = (ZoomU) * Math.Cos((90 - 120 - fFUcb) * PI / 180) * K;
                    LiuJiaoTu[Lj, 1] = -(ZoomU) * Math.Sin((90 - 120 - fFUcb) * PI / 180) * K;
                }
            }
            else if (Lj == 1 && DrawLen != 0)  //Ia
            {
                double K = (fIrms_A[0] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fUrms_A[0] != 0)
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 - fPhasic_A[0]) * PI / 180) * K);//ΦUIa
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 - fPhasic_A[0]) * PI / 180) * K);
                }
                else
                {
                    LiuJiaoTu[Lj, 0] = 0;
                    LiuJiaoTu[Lj, 1] = 0;
                }
            }
            else if (Lj == 3 && DrawLen != 0)//Ib
            {
                double K = (fIrms_A[1] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fUrms_A[1] != 0 && fUrms_A[0] != 0)   //ua ub!=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 - fFUab - fPhasic_A[1]) * PI / 180) * K);//ΦUIb
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 - fFUab - fPhasic_A[1]) * PI / 180) * K);
                }
                else if (fUrms_A[1] != 0 && fUrms_A[0] == 0) //ub!=0 ua=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 - 120 - fPhasic_A[1]) * PI / 180) * K); //ΦUIb
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 - 120 - fPhasic_A[1]) * PI / 180) * K);
                }
                else
                {
                    LiuJiaoTu[Lj, 0] = 0;
                    LiuJiaoTu[Lj, 1] = 0;
                }
            }
            else if (Lj == 5 && DrawLen != 0) //Ic
            {
                double K = (fIrms_A[2] / DrawLen);
                if ((K < 0.3) && K > 0)
                {
                    K = 0.3;
                }
                if (fUrms_A[2] != 0 && fUrms_A[0] != 0)        //ua uc!=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 - fFUac - fPhasic_A[2]) * PI / 180) * K);
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 - fFUac - fPhasic_A[2]) * PI / 180) * K);
                }
                else if (fUrms_A[2] != 0 && fUrms_A[0] == 0 && fUrms_A[1] == 0)//uc!=0 ua=0 ub=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 + 120 - fPhasic_A[2]) * PI / 180) * K);   //ΦUIc
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 + 120 - fPhasic_A[2]) * PI / 180) * K);
                }
                else if (fUrms_A[2] != 0 && fUrms_A[0] == 0 && fUrms_A[1] != 0)  //uc!=0 ua=0 ub!=0
                {
                    LiuJiaoTu[Lj, 0] = (ZoomI * Math.Cos((90 - 120 - fFUcb - fPhasic_A[2]) * PI / 180) * K);   //ΦUIc
                    LiuJiaoTu[Lj, 1] = -(ZoomI * Math.Sin((90 - 120 - fFUcb - fPhasic_A[2]) * PI / 180) * K);  //ΦUIc
                }
                else
                {
                    LiuJiaoTu[Lj, 0] = 0;
                    LiuJiaoTu[Lj, 1] = 0;
                }
            }
            else
            {
                LiuJiaoTu[Lj, 0] = 0;
                LiuJiaoTu[Lj, 1] = 0;
            }
        }
    }

    private void Drow3Six(Graphics gr, double[] J, double JUac, double[,] LiuJiaoTuData, double CenterX, double CenterY)
    {
        double x2 = CenterX;
        double y2 = CenterY;
        DwawPic(gr, Color.LightGray, CenterX, CenterY, CenterX * 2 - 30);

        Line Line_Ua = new Line(LiuJiaoTuData[0, 0] + x2, LiuJiaoTuData[0, 1] + y2, x2, y2, Color.Black); //Ua
        Line_Ua.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Dot);
        DispLienTitel(gr, Color.Black, LiuJiaoTuData[0, 0] + x2, LiuJiaoTuData[0, 1] + y2, 90, "Ua", CenterX, CenterY);//箭头

        Line Line_Ub = new Line(LiuJiaoTuData[2, 0] + x2, LiuJiaoTuData[2, 1] + y2, x2, y2, Color.Black);//Ub
        Line_Ub.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Dot);
        DispLienTitel(gr, Color.Black, LiuJiaoTuData[2, 0] + x2, LiuJiaoTuData[2, 1] + y2, 90 - 120, "Ub", CenterX, CenterY);//箭头

        Line Line_Ib = new Line(LiuJiaoTuData[3, 0] + x2, LiuJiaoTuData[3, 1] + y2, x2, y2, Color.Blue);//Ib .
        Line_Ib.DrawLine(gr);

        Line Line_Uc = new Line(LiuJiaoTuData[4, 0] + x2, LiuJiaoTuData[4, 1] + y2, x2, y2, Color.Black);//UC
        Line_Uc.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Dot);
        DispLienTitel(gr, Color.Black, LiuJiaoTuData[4, 0] + x2, LiuJiaoTuData[4, 1] + y2, 90 + 120, "Uc", CenterX, CenterY);//箭头

        Line Line_Uab = new Line(LiuJiaoTuData[6, 0] + x2, LiuJiaoTuData[6, 1] + y2, x2, y2, Color.Orange);//Uac
        Line_Uab.DrawLine(gr);
        DispLienTitel(gr, Color.Orange, LiuJiaoTuData[6, 0] + x2, LiuJiaoTuData[6, 1] + y2, 120, "Uab", CenterX, CenterY);

        Line Line_Ia = new Line(LiuJiaoTuData[1, 0] + x2, LiuJiaoTuData[1, 1] + y2, x2, y2, Color.Orange); //Ia
        Line_Ia.DrawLine(gr);
        DispLienTitel(gr, Color.Orange, LiuJiaoTuData[1, 0] + x2, LiuJiaoTuData[1, 1] + y2, 120 - J[0], "Ia", CenterX, CenterY);

        Line Line_Ucb = new Line(LiuJiaoTuData[7, 0] + x2, LiuJiaoTuData[7, 1] + y2, x2, y2, Color.Red);//Uac
        Line_Ucb.DrawLine(gr);
        DispLienTitel(gr, Color.Red, LiuJiaoTuData[7, 0] + x2, LiuJiaoTuData[7, 1] + y2, 120 - JUac, "Ucb", CenterX, CenterY);

        Line Line_Ic = new Line(LiuJiaoTuData[5, 0] + x2, LiuJiaoTuData[5, 1] + y2, x2, y2, Color.Red);//IC 
        Line_Ic.DrawLine(gr);
        DispLienTitel(gr, Color.Red, LiuJiaoTuData[5, 0] + x2, LiuJiaoTuData[5, 1] + y2, 120 - JUac - J[2], "IC", CenterX, CenterY);
    }



    private void Drow4Six(Graphics gr, double[] J, double JUac, double JUab, double[,] LiuJiaoTuData, double CenterX, double CenterY)
    {
        double x2 = CenterX;
        double y2 = CenterY;

        DwawPic(gr, Color.LightGray, CenterX, CenterY, CenterX * 2 - 30);

        Line Line_Ua = new Line(LiuJiaoTuData[0, 0] + x2, LiuJiaoTuData[0, 1] + y2, x2, y2, Color.Orange); //Ua
        Line_Ua.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);
        DispLienTitel(gr, Color.Orange, LiuJiaoTuData[0, 0] + x2, LiuJiaoTuData[0, 1] + y2, 90, "Ua", CenterX, CenterY);

        Line Line_Ia = new Line(LiuJiaoTuData[1, 0] + x2, LiuJiaoTuData[1, 1] + y2, x2, y2, Color.Orange); //Ia
        Line_Ia.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);
        DispLienTitel(gr, Color.Orange, LiuJiaoTuData[1, 0] + x2, LiuJiaoTuData[1, 1] + y2, 90 - J[0], "Ia", CenterX, CenterY);


        Line Line_Ub = new Line(LiuJiaoTuData[2, 0] + x2, LiuJiaoTuData[2, 1] + y2, x2, y2, Color.Green);//Ub
        Line_Ub.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);
        DispLienTitel(gr, Color.Green, LiuJiaoTuData[2, 0] + x2, LiuJiaoTuData[2, 1] + y2, 90 - JUab, "Ub", CenterX, CenterY);

        Line Line_Ib = new Line(LiuJiaoTuData[3, 0] + x2, LiuJiaoTuData[3, 1] + y2, x2, y2, Color.Green);//Ib .
        DispLienTitel(gr, Color.Green, LiuJiaoTuData[3, 0] + x2, LiuJiaoTuData[3, 1] + y2, 90 - JUab - J[1], "Ib", CenterX, CenterY);
        Line_Ib.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);

        Line Line_Uc = new Line(LiuJiaoTuData[4, 0] + x2, LiuJiaoTuData[4, 1] + y2, x2, y2, Color.Red);//UC
        Line_Uc.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);
        DispLienTitel(gr, Color.Red, LiuJiaoTuData[4, 0] + x2, LiuJiaoTuData[4, 1] + y2, 90 - JUac, "Uc", CenterX, CenterY);

        Line Line_Ic = new Line(LiuJiaoTuData[5, 0] + x2, LiuJiaoTuData[5, 1] + y2, x2, y2, Color.Red);//IC 
        Line_Ic.DrawLine(gr, System.Drawing.Drawing2D.DashStyle.Custom);
        DispLienTitel(gr, Color.Red, LiuJiaoTuData[5, 0] + x2, LiuJiaoTuData[5, 1] + y2, 90 - JUac - J[2], "IC", CenterX, CenterY);
    }
    /// <summary></summary>
    /// <param name="DrawControl">显示的控件</param>
    /// <param name="x1">顶点x</param>
    /// <param name="y1">顶点y</param>
    /// <param name="angle">角度</param>
    /// <param name="len">长度</param>
    /// <param name="flags">是否显示</param>
    /// <param name="title">标识</param>
    private void DispLienTitel(Graphics gr, Color color, double x1, double y1, double angle, string title, double CenterX, double CenterY)
    {
        Font font = new Font("宋体", 9, FontStyle.Bold);
        Brush brush = new Pen(color).Brush;
        SizeF size = gr.MeasureString(title, font);

        double sizeX = size.Width;
        double sizeY = size.Height;

        if (x1 == CenterX && y1 == CenterY)
        {
            return;
        }


        if (x1 <= CenterX && y1 <= CenterY) //1
        {
            x1 -= sizeX + 1;
            y1 -= sizeY;
        }
        else if (x1 >= CenterX && y1 <= CenterY) //2
        {
            x1 += 1;
            y1 -= sizeY + 1;
        }
        else if (x1 >= CenterX && y1 >= CenterY) //3
        {
            x1 += 1;
            y1 += 1;
        }
        else if (x1 <= CenterX && y1 >= CenterY) //4
        {
            x1 -= sizeX + 1;
            y1 += 1;
        }

        gr.DrawString(title, font, brush, (float)x1, (float)y1);

    }
    /// <summary> </summary>
    /// <param name="gr"></param>
    /// <param name="color"></param>
    /// <param name="x1"></param>
    /// <param name="y1"></param>
    /// <param name="angle"></param>
    /// <param name="title"></param>
    /// <param name="CenterX"></param>
    /// <param name="CenterY"></param>
    private void DwawPic(Graphics gr, Color color, double CenterX, double CenterY, double R)
    {
        float R1 = (float)R;
        Pen p = new Pen(color, (float)0.2);
        p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        gr.DrawPie(p, (float)(CenterX - R1 / 2), (float)(CenterY - R1 / 2), R1, R1, 0, 360);

        float R2 = (float)(R / 2);
        gr.DrawPie(p, (float)(CenterX - R2 / 2), (float)(CenterY - R2 / 2), R2, R2, 0, 360);
        gr.DrawLine(p, (float)(CenterX - R / 2) - 5, (float)(CenterY), (float)(CenterX + R / 2) + 5, (float)(CenterY));
        gr.DrawLine(p, (float)(CenterX), (float)(CenterY - R / 2) - 3, (float)(CenterX), (float)(CenterY + R / 2) + 5);
    }
}