标题:求大神 看看这段程序 总是提示没有ScrollEventArgs的命名空间或类型
只看楼主
刘志海
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-1-20
 问题点数:0 回复次数:0 
求大神 看看这段程序 总是提示没有ScrollEventArgs的命名空间或类型
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;//线程
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public static Form1 pCurrentWin = null;
        public static String read;
        private static String[] S = new string[15]; //存储促销信息
        private static byte ip1 = 0x71;//IP地址
        private static byte ip2 = 0x79;
        private delegate void FlushClient();//代理
        private static float[] int_X1 = new float[10] { 1f, 13f, 25f, 1f, 13f, 25f, 0f, 0f, 0f, 0f };//存储参考节点坐标
        private static float[] int_Y1 = new float[10] { 1f, 1f, 1f, 9f, 9f, 9f, 0f, 0f, 0f, 0f };
        private static int di = 0;//参考点索引
        private static int data = 1;//间隔数
        public static int pi = 28;// 38;//间隔像素
        public static int r = pi;//参考节点半径
        private static int Key;//有Key条促销信息
        private static int message1;//是否循环促销信息message1=1循环
        private static int sleeptime = 1000;//循环间隔
        public static Bitmap bmpformfile;//背景图片
       public static float scale;//背景图片放缩比例
        public static Form5 f5;
        private  static byte[] REF_RSPXYbyteread = new byte[] {0x00 };
        public static byte[] REF_RSPXYbyteread1 = new byte[] { 0x00 };
        private static byte[] byteread;
        private static byte[] REF_RSPHEAD=new byte[5]{0x02,0x10, 0x18, 0x0C, 0xCB };
        private static byte[] PING_REQUEST = new byte[5] { 0x02, 0x00, 0x07, 0x00, 0x07 };
        private static byte[] PING_RESPONSE = new byte[7] { 0x02, 0x10, 0x07, 0x02, 0x00, 0x00, 0x15 };
        private static byte[] GET_DEVICE_INFO = new byte[5] { 0x02, 0x00, 0x14, 0x00, 0x14 };
        public Form1()
        {
            InitializeComponent();
            Form.CheckForIllegalCrossThreadCalls = false;
            pCurrentWin = this;
        }
        private void 串口调试工具ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            chuankou.Form2 f2 = new chuankou.Form2();
            f2.Show();
        }
        
        
        private void 地图设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.ShowDialog(); ;
        }
      
        private void 商品信息查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form4 f4 = new Form4();
            f4.Owner = this;
            f4.ShowDialog();
        }
      
        private void 参考节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
           f5 = new Form5();
           f5.Owner = this;
           f5.ShowDialog();
        }
      
        private void 盲节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form6 f6 = new Form6();
            f6.ShowDialog(); ;
        }
      
        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            PointF contextMenuPoint = panel1.PointToClient(Control.MousePosition); //鼠标相对于contextMenuStrip1左上角的坐标
            if (e.Button == MouseButtons.Right)
            {
                String x = Convert.ToString(contextMenuPoint.X / pi);
                String y = Convert.ToString(contextMenuPoint.Y / pi);
                //  MessageBox.Show("确定移除?", "^_^提示");
                for (int i = 0; i < 10; i++)
                {
                    if (contextMenuPoint.X / pi >= (int_X1[i] - 0.5) && contextMenuPoint.X / pi <= (int_X1[i] + 0.5) && contextMenuPoint.Y / pi >= int_Y1[i] - 0.5 && contextMenuPoint.Y / pi <= int_Y1[i] + 0.5)
                    {
                        int_X1[i] = 0;
                        int_Y1[i] = 0;
                        panel1.Refresh();
                    }
                }
            }
            else
            {
                /* string x = (contextMenuPoint.X / pi).ToString("0.00");
                 string y = (contextMenuPoint.Y / pi).ToString("0.00");
                 MessageBox.Show("此处坐标值为:" + "(" + x + "," + y + ")", "^_^提示");*/
            }

        }
        
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            PointF contextMenuPoint = panel1.PointToClient(Control.MousePosition); //鼠标相对于contextMenuStrip1左上角的坐标
            string x = (contextMenuPoint.X / pi).ToString("0.00");
            string y = (contextMenuPoint.Y / pi).ToString("0.00");
            label23.Text = "鼠标当前坐标:" + "(" + x + "," + y + ")";
            /////////////////////////画坐标指示线
            Point cpt = new Point(0, 0);//中心点
            label24.Location = new Point(cpt.X + 10, Convert.ToInt32(cpt.Y + contextMenuPoint.Y)); //y
            label22.Location = new Point(Convert.ToInt32(cpt.X + contextMenuPoint.X), cpt.Y + 10);//x
        }
        private void panel1_MouseLeave(object sender, EventArgs e)
        {
            label23.Visible = false;
            label22.Visible = false;
            label24.Visible = false;

        }
  
        private void panel1_MouseEnter(object sender, EventArgs e)
        {
            label23.Visible = true;
            label22.Visible = true;
            label24.Visible = true;
        }
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics gph = panel1.CreateGraphics();
            Graphics gph1 = panel3.CreateGraphics();
            Graphics gph2 = panel4.CreateGraphics();
            Font fi = new Font("Tahoma", 8, FontStyle.Bold | FontStyle.Italic);
            String XY;
            Point cpt = new Point(0, 0);//中心点
            Pen Mypen = new Pen(Color.Gray, 1);//生成画笔,蓝色,1个像素
            Mypen.DashStyle = DashStyle.Dot;
            int j = 0;
            for (int i = 0; i <= map_X; )
            {
                gph.DrawLine(Mypen, cpt.X, cpt.Y + i, cpt.X + map_X, cpt.Y + i);//x画线
                gph.DrawLine(Mypen, cpt.X + i, cpt.Y, cpt.X + i, cpt.Y + map_X);//y画线
                XY = Convert.ToString(j);
                i = i + pi;
                j = j + data;
                gph.DrawLine(new Pen(Color.Green, 3), 0, 0, side_Y * pi, 0);//y边界画线
                gph.DrawLine(new Pen(Color.Green, 3), 0, 0, 0, side_X * pi);//x边界画线
                if (j == side_X)
                    gph.DrawLine(new Pen(Color.Green, 3), cpt.X, cpt.Y + i, cpt.X + side_Y * pi, cpt.Y + i);//y画线
                if (j == side_Y)
                    gph.DrawLine(new Pen(Color.Green, 3), cpt.X + i, cpt.Y, cpt.X + i, cpt.Y + side_X * pi);//x画线

            }
            Mypen.Dispose();
            gph.Dispose();
           
        }
      
        private void panel3_Paint(object sender, PaintEventArgs e)
        {
            Graphics gph1 = panel3.CreateGraphics();
            Font fi = new Font("Tahoma", 8, FontStyle.Bold | FontStyle.Italic);
            String XY;
            Point cpt = new Point(0, 0);//中心点
            int j = 0;
            for (int i = 0; i <= map_X; )
            {
                XY = Convert.ToString(j);
                gph1.DrawString(XY, fi, new SolidBrush(Color.Black), cpt.X + i, cpt.Y);//y字
                i = i + pi;
                j = j + data;
            }

        }
        
        private void panel4_Paint(object sender, PaintEventArgs e)
        {
            Graphics gph2 = panel4.CreateGraphics();
            Font fi = new Font("Tahoma", 8, FontStyle.Bold | FontStyle.Italic);
            String XY;
            Point cpt = new Point(0, 0);//中心点
            int j = 0;
            for (int i = 0; i <= map_X; )
            {
                XY = Convert.ToString(j);
                gph2.DrawString(XY, fi, new SolidBrush(Color.Black), cpt.X, cpt.Y + i);//x字
                i = i + pi;
                j = j + data;
            }
        }
      
        private void Form1_Load(object sender, EventArgs e)
        {
            bmpformfile = new Bitmap(panel1.BackgroundImage);
            panel1.Size = panel1.BackgroundImage.Size;
            panel3.Width = panel1.BackgroundImage.Width;
            map_X = panel3.Width;
            panel4.Height = panel1.BackgroundImage.Height;
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            this.UpdateStyles();
            //以上两句是为了设置控件样式为双缓冲,这可以有效减少图片闪烁的问题,关于这个大家可以自己去搜索下
            //串口的发现
            string[] ports = ();//遍历串口
            int i = 0;
            foreach (string port in ports)
            {
                comboBox2.Items.Add(port);
                i++;
            }
            if (i > 0)
            {
                comboBox2.SelectedIndex = 0;
            }
            panel3.Location = new Point(20 - panel2.HorizontalScroll.Value, 0);//水平
            panel4.Location = new Point(0, 20 - panel2.VerticalScroll.Value);
            ///////////////////////
            this.KeyPreview = true;  //Enter 代替 Tab
        }
        
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                SendKeys.Send("{TAB}");
                e.Handled = true;
            }
        }

        
        private void CrossThreadFlush()
        {
            while (message1 == 1)
            {
                //将sleep和无限循环放在等待异步的外面
                Thread.Sleep(sleeptime);
                ThreadFunction();

            }
        }
        
        private void ThreadFunction()
        {
            int i = Convert.ToInt32(toolStripStatusLabel3.Text);
            if (i == Key)
            {
                i = 0;
            }
            if (this.textBox1.InvokeRequired)//等待异步
            {
                FlushClient fc = new FlushClient(ThreadFunction);
                this.Invoke(fc);//通过代理调用刷新方法
            }
            else
            {
                string s = S[i];
                toolStripStatusLabel3.Text = Convert.ToString(i + 1);
                byte[] byte_arr = Encoding.Default.GetBytes(s);
                byte[] content = byte_arr;
                byte[] head = new byte[11] { 0x02, 0x00, 0x18, Convert.ToByte(byte_arr.Length + 7), 0x0A, 0x71, 0x79, 0x0A, 0x11, 0x00, Convert.ToByte(byte_arr.Length) };
                head[5] = 0xFF;//ip1;
                head[6] =0xFF ;//ip2;
                string a1 = string.Format("{0:X2} ", ip1);
                string a2 = string.Format("{0:X2} ", ip2);
                textBox16.Text = a1 + a2;
                string str1 = System.Text.Encoding.Default.GetString(head) + System.Text.Encoding.Default.GetString(content);
                byte[] b1 = System.Text.Encoding.Default.GetBytes(str1);
                //异或
                byte end = b1[1];
                for (int k = 2; k < (b1.Length); k++)
                {
                    end = Convert.ToByte(end ^ b1[k]);
                }
               
                byte[] all = new byte[b1.Length + 1];
                for (int k = 0; k < (b1.Length); k++)
                {
                    all[k] = b1[k];
                }
                all[b1.Length] = end;
                try
                {
                    serialPort1.Write(all, 0, all.Length);
               
                }
                catch (System.InvalidOperationException ee)
                {
                    serialPort1.Close();
                    MessageBox.Show("串口被关闭", "提示");
                    canedit();//促销信息可编辑
                }
            }
        }
        
        private void canedit()
        {

            groupBox1.Enabled = true;
        }
      
        private void canotedit()
        {
            groupBox1.Enabled = false;
        }
        
        private void Message_init()
        {
            S[0] = "@1." + textBox1.Text + "*";
            S[1] = "@2." + textBox2.Text + "*";
            S[2] = "@3." + textBox3.Text + "*";
            S[3] = "@4." + textBox4.Text + "*";
            S[4] = "@5." + textBox5.Text + "*";
            S[5] = "@6." + textBox6.Text + "*";
            S[6] = "@7." + textBox7.Text + "*";
            S[7] = "@8." + textBox8.Text + "*";
            S[8] = "@9." + textBox9.Text + "*";
            S[9] = "@10.." + textBox10.Text + "*";
            S[10] = "@11.." + textBox11.Text + "*";
            S[11] = "@12.." + textBox12.Text + "*";
            S[12] = "@13.." + textBox13.Text + "*";
            S[13] = "@14.." + textBox14.Text + "*";
            S[14] = "@15.." + textBox15.Text + "*";
        }
      
        private void button2_Click(object sender, EventArgs e)
        {
            if (button2.Text == "发送")
            {
                if (this.serialPort1.IsOpen)
                {
                    Message_init();
                    for (int i = 0; i < 15; i++)
                    {
                        string js = Convert.ToString(i + 1);
                        if (S[i] == "@" + js + ".*" | S[i] == "@" + js + "..*")
                        {
                            Key = i;
                            break;
                        }
                    }
                    if (Key != 0)    //检测促销品信息是否为0条
                    {
                        int count = 0;
                        for (int i = 0; i < Key; i++)///检测促销品信息字数
                        {
                            string s = S[i];
                            byte[] byte_arr = Encoding.Default.GetBytes(s);
                            if (byte_arr.Length > (5 + 14 * 3))
                            {
                                MessageBox.Show("第" + Convert.ToString(i + 1) + "条促销品信息字数超过14字", "^_^提示");
                                count = 1;
                            }
                        }
                        if (count == 0)
                        {
                            message1 = 1;
                            sleeptime = Convert.ToInt32(comboBox3.SelectedItem);
                            Thread thread = new Thread(CrossThreadFlush);//创建线程
                            thread.IsBackground = true; ;//加上个标识后防止主线程停止后这个线程关不掉。
                            thread.Start();
                            button2.Text = "停止发送";
                            //////////////////////////////促销商品不可编辑
                            canotedit();

                        }
                    }
                    else
                        MessageBox.Show("请输入促销品信息", "^_^提示");
                }
                else
                    MessageBox.Show("串口没打开", "^_^提示");
            }
            else
            {
                button2.Text = "发送";
                message1 = 0;
                toolStripStatusLabel3.Text = "0";
                ////////////////////////////////////促销信息可编辑
                canedit();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            message1 = 0;
            toolStripStatusLabel3.Text = "0";

        }

      
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "断开连接")
            {
                if (button2.Text == "发送")
                {

                    button1.Text = "建立连接";
                    button7.Text = "打开接收";
                    Light.ForeColor = Color.DarkGray;
                    toolStripStatusLabel2.Text = "Location Dongle 状态:未连接!";
                    MessageBox.Show("已与Location Dongle断开连接!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    节点配置ToolStripMenuItem.Enabled = false;
                    if (this.serialPort1.IsOpen)
                    {
                        button2.Text = "发送";
                        message1 = 0;
                        toolStripStatusLabel3.Text = "0";
                        this.serialPort1.Close();
                    }
                }
                else
                {
                    button2.Text = "停止发送";

                }
            }
            else
            {
                try
                {
                /*    if (this.serialPort1.IsOpen)
                    {
                        this.serialPort1.Close();
                    }*/
                    if (comboBox2.Items.Count > 0)
                    {
                        this.serialPort1.PortName = comboBox2.SelectedItem.ToString();
                    }
                        this.serialPort1.Open();
                      //  serialPort1.DiscardInBuffer();         // 清空接收缓冲区  
                      //  serialPort1.DiscardOutBuffer();
                        //*PING_REQUEST
                        serialPort1.Write(PING_REQUEST, 0, PING_REQUEST.Length);
                }
                catch ( ee)
                {
                    MessageBox.Show("没发现次串口", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    button1.Text = "建立连接";

                }
                catch (UnauthorizedAccessException ee)
                {
                    MessageBox.Show("串口被占用!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    button1.Text = "建立连接";
                }

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Stop();
            if (serialPort1.BytesToRead==0)//byteread == null)
            {
                MessageBox.Show("与Location Dongle连接失败!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                button1.Text = "建立连接";              
            }

        }
     
        bool SerialPortIsReceiving = false;
        public void serialPort1_DataReceived(object sender, e)
        {
            SerialPortIsReceiving = true;
            if (button7.Text != "关闭接收")
                Thread.Sleep(100); //等待100毫秒充分接收数据
            else
                Thread.Sleep(20);
            byteread = new byte[serialPort1.BytesToRead];//接收到的参考节点(x,y)
            serialPort1.Read(byteread, 0, byteread.Length);
            serialPort1.DiscardInBuffer();
            if (byteread.Length > 3)
            {
                // f5 = new Form5();
                 string str = " ";
                  for (int i = 0; i < byteread.Length; i++)
                  {
                      str += string.Format("{0:X2} ", byteread[i]);
                  }
                if (PasswordEquals(byteread, PING_RESPONSE))
                {
                    serialPort1.Write(GET_DEVICE_INFO, 0, GET_DEVICE_INFO.Length);
                }
                if ((byteread[0] == 0x02) & (byteread[1] == 0x10) & (byteread[2] == 0x14))
                {
                    button1.Text = "断开连接";
                    Light.ForeColor = Color.Lime;
                    节点配置ToolStripMenuItem.Enabled = true;
                    toolStripStatusLabel2.Text = "Location Dongle 状态:已连接!";
                    MessageBox.Show("与Location Dongle连接成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            if (byteread.Length == 25 && button7.Text == "关闭接收")
            {
                try
                {
                    if ((button7.Text == "关闭接收") && (byteread[8] == 0x14 && byteread[9] == 0x00) && byteread.Length == 25)
                    {
                        label3.Visible = true;
                        label25.Visible = true;
                        ip1 = byteread[5];//低位
                        ip2 = byteread[6];
                        byte a = byteread[12];
                        byte b = byteread[13];
                        byte c = byteread[14];
                        byte d = byteread[15];
                        int x, y;
                        int i, j;
                        i = (a & 0x00FF) + ((b & 0x00FF) << 5);
                        j = (c & 0x00FF) + ((d & 0x00FF) << 4);
                        x = (i & 0x0003) * 25 + (i >> 2) * 100;
                        y = (j & 0x0003) * 25 + (j >> 2) * 100;
                        float x_f = x / 100f;
                        float y_f = y / 100f;
                        if (x_f > panel1.Size.Width || y_f > panel1.Size.Height)
                        {
                            x_f = 0;
                            y_f = 0;
                        }
                        string x1 = Convert.ToString(x_f);// + byteThird[2].ToString("X");
                        textBoxRec.Text = "(";
                        textBoxRec.Text += x1 + ", ";
                        string y1 = Convert.ToString(y_f);// + byteThird[2].ToString("X");
                        textBoxRec.Text += y1 + ") ";
                        label3.Visible = true;
                        label3.Location = new Point(Convert.ToInt32(x_f * pi - r / 2), Convert.ToInt32(y_f * pi - r / 2));

                        label25.Text = "0x" + string.Format("{0:X2}", ip2) + string.Format("{0:X2}", ip1);
                        label25.Text += "(";
                        label25.Text += x1 + ", ";
                        label25.Text += y1 + ") ";
                        label25.Visible = true;

                        label25.Location = new Point(Convert.ToInt32(x_f * pi - r / 2), Convert.ToInt32(y_f * pi - r / 2) + 40);
                        byteread = new byte[] { 0x00 };
                    }
                }
                catch
                {
                    return;
                }
            }
                    if (byteread.Length != 25 && PasswordEquals(byteread, PING_RESPONSE) == false && ((byteread[0] != 0x02) || (byteread[1] != 0x10) || (byteread[2] != 0x14)))
                    {
                        REF_RSPXYbyteread = byteread;
                        REF_RSPXYbyteread1 = byteread;
                    }

            }
         
            SerialPortIsReceiving = false;



            Application.DoEvents();//
        }

    private bool PasswordEquals(byte[] b1, byte[] b2)
    {
        if (b1.Length != b2.Length) return false;
        if (b1 == null || b2 == null) return false;
        for (int i = 0; i < b1.Length; i++)
            if (b1[i] != b2[i])
                return false;
        return true;
    }

    private bool LEquals(byte[] b1, byte[] b2,int L)
    {
        if (b1 == null || b2 == null) return false;
        for (int i = 0; i <L; i++)
            if (b1[i] != b2[i])
                return false;
        return true;
    }

        private void button7_Click(object sender, EventArgs e)
        {
            if (this.serialPort1.IsOpen)
            {
                if (button7.Text == "打开接收")
                {
                    节点配置ToolStripMenuItem.Enabled = false;
                    //groupBox3.Enabled = false;
                    button7.Text = "关闭接收";
                    label3.Visible = true;
                    label25.Visible = true;
                }
                else
                {
                    节点配置ToolStripMenuItem.Enabled = true;
                    //groupBox3.Enabled = true;
                    button7.Text = "打开接收";
                    textBoxRec.Text = "";
                    label3.Visible = false;
                    label25.Visible = false;

                }
            }
            else
                MessageBox.Show("串口未打开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static byte[] Getbyteread()

          {
              return REF_RSPXYbyteread;
         }
      
        private static Label[] slabel = new Label[100];
        private static Label[] slabel0 = new Label[100];
        private static float[] x=new float[100];
        private static float[] y = new float[100];
        private static int  notecount;
        public Label[] Slabel
        {
            get
            {
                return slabel;
            }
            set
            {
                slabel = value;
            }
        }
        public Label[] Slabel0
        {
            get
            {
                return slabel0;
            }
            set
            {
                slabel0 = value;
            }
        }
        public float[] X
        {
            get
            {
                return x;
            }
            set
            {
                x = value;
            }
        }
        public float[] Y
        {
            get
            {
                return y;
            }
            set
            {
                y = value;
               
            }
        }
        public int noteCount
        {
            get
            {
                return notecount;
            }
            set
            {
                notecount = value;
            }
        }

        private static int map_x;//标尺边界
        public int map_X
        {
            get
            {
                return map_x;
            }
            set
            {
                map_x = value;
            }
        }
        /*     public int map_Y
             {
                 get
                 {
                     return map_y;
                 }
                 set
                 {
                     map_y = value;
                     // this.label1.Text = strLabel1;
                 }
             }*/
        private static int side_x;//边界
        private static int side_y;

        public int side_X
        {
            get
            {
                return side_x;
            }
            set
            {
                side_x = value;
                // this.label1.Text = strLabel1;
            }
        }
        public int side_Y
        {
            get
            {
                return side_y;
            }
            set
            {
                side_y = value;
            }
        }

        private void trackBar1_Scroll_1(object sender, EventArgs e)
        {
            Bitmap backbitmap = bmpformfile;//获取打开的文件
            comboBox1.Text = Convert.ToString(trackBar1.Value) + "%";
            scale = trackBar1.Value / 100f;
            pi = Convert.ToInt32(38 * scale);
            r = Convert.ToInt32(38 * scale);
            panel3.Refresh();
            panel4.Refresh();
            backbitmap = KiResizeImage(backbitmap, Convert.ToInt32(bmpformfile.Width * scale), Convert.ToInt32(bmpformfile.Height * scale));
            panel1.Size = backbitmap.Size;
            panel1.BackgroundImage = backbitmap;

            panel3.Width = panel1.BackgroundImage.Width;
            map_X = panel3.Width;
            panel4.Height = panel1.BackgroundImage.Height;

            panel3.Location = new Point(20 - panel2.HorizontalScroll.Value, 0);//水平
            panel4.Location = new Point(0, 20 - panel2.VerticalScroll.Value);


            for (int i = 0; i < noteCount; i++)
            {
                Slabel[i].Size = new Size((int)(50 * scale), (int)(50 * scale));
                GraphicsPath myPath = new GraphicsPath();
                myPath.AddEllipse(0, 0, r*scale, r*scale);
                Slabel[i].Region = new Region(myPath);
                Slabel0[i].Size = new Size((int)(50 * scale), (int)(18 * scale));
                Slabel0[i].Font = new Font("宋体", 10.5f * scale);
                Slabel[i].Location = new Point(Convert.ToInt32(X[i] * pi - (r / 2) * scale), Convert.ToInt32(Y[i] * pi - (r / 2) * scale));
                Slabel0[i].Location = new Point(Convert.ToInt32(X[i] * pi - (r / 3) * scale), Convert.ToInt32(Y[i] * pi + (r / 2) * scale ));
            }
         
        }
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            string tags = comboBox1.SelectedItem.ToString();
            string tagsArray = tags.Replace("%", "");
            scale = Convert.ToInt32(tagsArray) / 100f;

            Bitmap backbitmap = bmpformfile;//获取打开的文件
            
            pi = Convert.ToInt32(38 * scale);
            r = Convert.ToInt32(38 * scale);
            panel3.Refresh();
            panel4.Refresh();
            backbitmap = KiResizeImage(backbitmap, Convert.ToInt32(bmpformfile.Width * scale), Convert.ToInt32(bmpformfile.Height * scale));
            panel1.Size = backbitmap.Size;
            panel1.BackgroundImage = backbitmap;

            panel3.Width = panel1.BackgroundImage.Width;
            map_X = panel3.Width;
            panel4.Height = panel1.BackgroundImage.Height;

            panel3.Location = new Point(20 - panel2.HorizontalScroll.Value, 0);//水平
            panel4.Location = new Point(0, 20 - panel2.VerticalScroll.Value);
        }
   
        private void panel2_Scroll(object sender, ScrollEventArgs e)
        {
            panel3.Location = new Point(20 - panel2.HorizontalScroll.Value, 0);//水平
            panel4.Location = new Point(0, 20 - panel2.VerticalScroll.Value);

        }
   
        public static Bitmap KiResizeImage(Bitmap bmp, int newW, int newH)
        {
            try
            {
                Bitmap b = new Bitmap(newW, newH);
                Graphics g = Graphics.FromImage(b);
                // 插值算法的质量
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                g.Dispose();
                return b;
            }
            catch
            {
                return null;
            }
        }

   
        private void button3_Click_1(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();
            comboBox2.Text = "";
            string[] ports = ();
            //this.serialPort1.ReadTimeout = 32;
            int i = 0;
            foreach (string port in ports)
            {
                if (!comboBox2.Items.Contains(port))
                {
                    comboBox2.Items.Add(port);
                }

                i++;
            }
            if (i > 0)
            {
                comboBox2.SelectedIndex = 0;
            }
        }

    }

}
搜索更多相关主题的帖子: 空间 private public null 
2013-01-20 11:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-397131-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.761967 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved