public MainForm(SerialSenderFactory p_serialSenderFactory )
        {
            InitializeComponent();
            InitializeDrawingPanel();

            statusLabel.Text = "";

            this.panelDrawPad.Size = new System.Drawing.Size(IMAGE_LENGTH + 1, IMAGE_WIDTH+1);
            m_serialSenderFactory = p_serialSenderFactory;

            _serialPort = m_serialSenderFactory.GenerateSerialSender();
        }
        private void btnconnect_Click(object sender, EventArgs e)
        {
            if (combocom.Text != "" )//&& _serialPort.IsOpen == false)
            {
                _serialPort = m_serialSenderFactory.GenerateSerialSender(combocom.Text, 9600, Parity.None, 8, StopBits.One);
                //_serialPort = new SerialPort("COM20", 115200, Parity.None, 8, StopBits.One);
                _serialPort.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
                _serialPort.Handshake = Handshake.None;
                _serialPort.DtrEnable = true;
                _serialPort.RtsEnable = true;

                //_serialPort.ReadTimeout = 1000;
                //_serialPort.WriteTimeout = 500;
                _serialPort.Open();
                btnconnect.Text = "Disconnect";
                btnconnect.BackColor = Color.Red;

                try
                {
                    if (!_serialPort.IsOpen)
                        _serialPort.Open();

                    //_serialPort.Write("\r\n\r\n");
                    //System.Threading.Thread.Sleep(2);

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error opening/writing to serial port :: " + ex.Message, "Error!");
                }

            }
            else
            {
                if (_serialPort.IsOpen)
                {
                    _serialPort.Close();
                    btnconnect.Text = "Connect";
                    btnconnect.BackColor = Color.Lime;
                }
            }
        }