示例#1
0
        public void DrawingArcs(Label label, string KEY, int n, int Total, Label labelr)
        {
            if (label.InvokeRequired)
            {
                InvokeDrawingArcs labelCallback = new InvokeDrawingArcs(DrawingArcs);
                label.Invoke(labelCallback, new object[] { label, KEY, n, Total });
            }
            else
            {
                //Log.Info("DrawingArcs Key=" + KEY + ", n=" + n + ", Total=" + Total);
                int    r     = 120;
                double ratio = (double)n / Total;
                if (ratio > 100)
                {
                    ratio = 100.00;
                }

                string strRatio = string.Format("{0:0.0%}", ratio);//得到5.88%

                AnswerCount ac = new AnswerCount();
                ac.AnswerBackColor   = System.Drawing.Color.FromArgb(212, 214, 213);
                ac.AnswerBorderColor = System.Drawing.Color.FromArgb(0, 0, 0);
                ac.AnswerBorderWidth = 10;
                ac.AnswerW           = r + 20;
                ac.AnswerH           = r + 20;
                ac.AnswerX           = 4;
                ac.AnswerY           = 4;
                float nArc = (float)n * 360 / Total;
                ac.AnswerSweep = (int)nArc;

                Color colorBackground = CircleBackgroundColor;
                Color colorText       = System.Drawing.Color.FromArgb(249, 142, 56);

                string text1 = "" + n;
                //if (n == 0)
                //    text1 = KEY;

                Image img = ac.DrawingArcWithText(r, colorBackground, colorText, text1, strRatio);
                if (KEY == "A")
                {
                    pictureBox_A.Image = img;
                }
                else if (KEY == "B")
                {
                    pictureBox_B.Image = img;
                }
                else if (KEY == "C")
                {
                    pictureBox_C.Image = img;
                }
                else if (KEY == "D")
                {
                    pictureBox_D.Image = img;
                }
            }
        }
示例#2
0
        public void DrawingArcs(Label label, string KEY, int n, int Total, Label labelr)
        {
            if (label.InvokeRequired)
            {
                InvokeDrawingArcs labelCallback = new InvokeDrawingArcs(DrawingArcs);
                label.Invoke(labelCallback, new object[] { label, KEY, n, Total, labelr });
            }
            else
            {
                label_A.BringToFront();
                label_B.BringToFront();
                label_C.BringToFront();
                label_D.BringToFront();
                label_F.BringToFront();
                label_E.BringToFront();
                label_R.BringToFront();
                label_W.BringToFront();

                //Log.Info("DrawingArcs Key=" + KEY + ", n=" + n + ", Total=" + Total);
                int    r     = 120;
                double ratio = (double)n / Total;
                if (ratio > 100)
                {
                    ratio = 100.00;
                }

                string strRatio = string.Format("{0:0.0%}", ratio);//得到5.88%

                AnswerCount ac = new AnswerCount();
                ac.AnswerBackColor   = System.Drawing.Color.FromArgb(212, 214, 213);
                ac.AnswerBorderColor = System.Drawing.Color.FromArgb(0, 0, 0);
                ac.AnswerBorderWidth = 10;
                ac.AnswerW           = r + 20;
                ac.AnswerH           = r + 20;
                ac.AnswerX           = 4;
                ac.AnswerY           = 4;
                float nArc = (float)n * 360 / Total;
                ac.AnswerSweep = (int)nArc;


                Color colorBackground = System.Drawing.Color.FromArgb(254, 99, 99);;
                Color colorText       = System.Drawing.Color.FromArgb(74, 74, 74);
                label.ForeColor  = System.Drawing.Color.FromArgb(74, 74, 74);
                labelr.ForeColor = System.Drawing.Color.FromArgb(74, 74, 74);
                labelr.BackColor = System.Drawing.Color.FromArgb(254, 99, 99);

                //if (KEY == _answer)
                //{
                //    colorBackground = System.Drawing.Color.FromArgb(152, 237, 154);
                //    colorText = System.Drawing.Color.FromArgb(43, 191, 45);
                //    label.ForeColor = System.Drawing.Color.FromArgb(43, 191, 45);
                //    labelr.ForeColor = System.Drawing.Color.FromArgb(43, 191, 45);
                //    labelr.BackColor = System.Drawing.Color.FromArgb(152, 237, 154);
                //}

                char[] str = _answer.ToCharArray();
                char[] key = KEY.ToCharArray();
                for (int i = 0; i < str.Length; i++)
                {
                    if (key[0] == str[i])
                    {
                        colorBackground = System.Drawing.Color.FromArgb(105, 240, 174);
                        colorText       = System.Drawing.Color.FromArgb(74, 74, 74);
                        //label.ForeColor = System.Drawing.Color.FromArgb(43, 191, 45);
                        //labelr.ForeColor = System.Drawing.Color.FromArgb(43, 191, 45);
                        label.ForeColor  = System.Drawing.Color.FromArgb(74, 74, 74);
                        labelr.ForeColor = System.Drawing.Color.FromArgb(74, 74, 74);
                        labelr.BackColor = System.Drawing.Color.FromArgb(105, 240, 174);
                    }
                }
                string text1 = "" + n;
                //if (n == 0)
                //    text1 = KEY;

                Image img = ac.DrawingArcWithText(r, colorBackground, colorText, text1, strRatio);
                if (KEY == "A")
                {
                    pictureBox_A.Image = img;
                }
                else if (KEY == "B")
                {
                    pictureBox_B.Image = img;
                }
                else if (KEY == "C")
                {
                    pictureBox_C.Image = img;
                }
                else if (KEY == "D")
                {
                    pictureBox_D.Image = img;
                }
                else if (KEY == "E")
                {
                    pictureBox_E.Image = img;
                }
                else if (KEY == "F")
                {
                    pictureBox_F.Image = img;
                }
                else if (KEY == "R")
                {
                    pictureBox_R.Image = img;
                }
                else if (KEY == "W")
                {
                    pictureBox_W.Image = img;
                }
            }
        }