/****************************************************************************************************************/


        /***************************************************画图*******************************************************/
        public void draw_pic()//画图
        {
            Bitmap   my_bitmap  = new Bitmap("ModbusBase.bmp");
            Graphics my_pic     = Graphics.FromImage(my_bitmap);
            SizeF    d          = new SizeF();
            int      line_width = 1;//画笔宽度
            Pen      my_pen     = new Pen(Brushes.Red, line_width);

            label5.Text = "颗粒物:" + Convert.ToString(ShowData[0]);
            label6.Text = "二氧化硫:" + Convert.ToString(ShowData[1]);
            label7.Text = "氮氧化物:" + Convert.ToString(ShowData[2]);


            for (int i = 0; i < 3; i++)
            {
                j节目config tmp = (j节目config)d数据格式[i];                                    //从config找到第i个数据的格式

                string str_temp = ShowData[i].ToString("f" + tmp.dat_point.ToString()); //数据标准化

                /*MeasureString方法,只要指定了字体和字符串后,用这个方法就能获得一个矩形的区域,
                 * 这个区域是Graphics对象用DrawString方法在空间表面绘制字符串时所要的区域。*/
                d = my_pic.MeasureString(str_temp, new Font(tmp.FontName, tmp.FontSize, FontStyle.Bold));

                draw_string(my_pic, str_temp, tmp.left, tmp.top, tmp.FontSize);
            }


            if (File.Exists("new.bmp")) //如果已经存在
            {
                File.Delete("new.bmp");
            }
            my_bitmap.Save("new.bmp");

            FileStream fs  = new FileStream("new.bmp", FileMode.Open, FileAccess.Read); //获取图片文件流
            Image      img = Image.FromStream(fs);                                      // 文件流转换成Image格式

            pictureBox1.Image = img;                                                    //给 图片框设置要显示的图片
            fs.Close();                                                                 // 关闭流,释放图片资源


            my_bitmap.Dispose();
        }
        public void load_para()//载入参数
        {
            {
                ///  load colum
                string filepath1 = Application.ExecutablePath;
                filepath1 = filepath1.Substring(0, filepath1.LastIndexOf('\\'));
                string       inipath = filepath1 + "\\" + "config.txt";
                FileStream   fs      = new FileStream(inipath, FileMode.Open);
                StreamReader sw      = new StreamReader(fs, Encoding.Default);

                string str = "";//屏幕参数设置
                str = sw.ReadLine();
                string[] aa = str.Split(',');
                try
                {
                    led大屏设置.ip        = aa[1];
                    led大屏设置.width     = Convert.ToInt16(aa[2]);
                    led大屏设置.height    = Convert.ToInt16(aa[3]);
                    led大屏设置.FontColor = Convert.ToInt16(aa[4]);
                }
                catch { MessageBox.Show("读取大屏幕设置出错"); }

                str = sw.ReadLine();//ModBus串口监听设置
                aa  = str.Split(',');
                try
                {
                    serialPort1.PortName = aa[1];
                    serialPort1.Open();
                    serialPort1.BaudRate = 57600;
                }
                catch { MessageBox.Show("打开" + aa[0] + "设备端口出错"); }



                str = sw.ReadLine();//定时器设置
                aa  = str.Split(',');
                try
                {
                    timer1.Interval = Convert.ToInt16(aa[1]) * 1000;
                    timer1.Enabled  = true;
                }
                catch { MessageBox.Show("设置定时器出错"); }


                //读取数据格式
                d数据格式.Clear(); //读取数据格式
                str = sw.ReadLine();
                for (int k = 0; k < 3; k++)
                {
                    aa = str.Split(',');
                    try
                    {
                        j节目config tmp = new j节目config();
                        tmp.left      = Convert.ToInt16(aa[1]);
                        tmp.top       = Convert.ToInt16(aa[2]);
                        tmp.FontName  = (aa[3]);
                        tmp.FontSize  = Convert.ToInt16(aa[4]);
                        tmp.dat_min   = Convert.ToInt16(aa[5]);
                        tmp.dat_max   = Convert.ToInt16(aa[6]);
                        tmp.dat_point = Convert.ToInt16(aa[7]);

                        d数据格式.Add(tmp);
                        str = sw.ReadLine();
                    }
                    catch { MessageBox.Show("读取数据格式信息出错"); }
                }

                sw.Close();
            }

            // init show
        }