Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="usePort"></param>

        public SerialPortControl(COMMPort usePort, RichTextBox msg = null)
        {
            InitializeComponent();

            //---初始化变量
            this.Init();

            //---消息控件
            if (msg != null)
            {
                if (this.usedMsg == null)
                {
                    this.usedMsg = new RichTextBox();
                }
                this.usedMsg = msg;
            }

            //---端口信息
            if (usePort != null)
            {
                //---判断对象
                if (this.usedPort == null)
                {
                    this.usedPort = new COMMPortLib.COMMPort();
                }

                //---注册端口
                this.usedPort = usePort;

                //---检查当前设备存在的端口信息
                this.usedPort.RefreshDevice(this.comboBox_portName, this.usedMsg);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 public void Init()
 {
     this.usedPort = null;
     this.usedMsg  = null;
     this.usedForm = null;
     this.pictureBox_portState.Tag = 0;
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="useForm"></param>
 /// <param name="usePort"></param>
 /// <param name="msg"></param>
 public void Init(Form useForm, COMMPort usePort, RichTextBox msg = null)
 {
     if (useForm != null)
     {
         if (this.usedForm == null)
         {
             this.usedForm = new Form();
         }
         this.usedForm = useForm;
     }
     this.Init(usePort, msg);
 }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="usePort"></param>
        /// <param name="msg"></param>
        public void Init(COMMPort usePort, RichTextBox msg = null)
        {
            if (usePort != null)
            {
                //---判断对象
                if (this.usedPort == null)
                {
                    this.usedPort = new COMMPortLib.COMMPort();
                }

                //---注册端口
                this.usedPort = usePort;

                //---检查当前设备存在的端口信息
                this.usedPort.RefreshDevice(this.comboBox_portName, this.usedMsg);

                //---添加监控端口拔插事件
                this.usedPort.AddWatcherPortEvent(this.WatcherPortEventHandler, this.WatcherPortEventHandler, new TimeSpan(0, 0, 1));
            }

            if (msg != null)
            {
                if (this.usedMsg == null)
                {
                    this.usedMsg = new RichTextBox();
                }
                this.usedMsg = msg;
            }
            if (this.usedPort != null)
            {
                //---注册按钮事件
                this.button_initDevice.Click += new EventHandler(this.button_Click);
            }

            this.pictureBox_portState.Tag = 0;

            //---点击图片控件
            this.pictureBox_portState.Click += new System.EventHandler(this.pictureBox_Click);

            //---注册鼠标进入事件
            this.pictureBox_portState.MouseEnter += new System.EventHandler(this.pictureBox_MouseEnter);
        }