void Button1Click(object sender, EventArgs e)
 {
     try
     {
         if (!editMode)
         {
             easyModbusManager.AddConnection(connectionProperties);
             if (connectionProperties.ModbusTypeProperty == ModbusType.ModbusTCP)
             {
                 connectionProperties.modbusClient = new EasyModbus.ModbusClient();
                 connectionProperties.modbusClient.UnitIdentifier = (byte)connectionProperties.SlaveID;
             }
             else
             {
                 connectionProperties.modbusClient = new EasyModbus.ModbusClient(connectionProperties.ComPort);
                 connectionProperties.modbusClient.UnitIdentifier = (byte)connectionProperties.SlaveID;
             }
         }
         else
         {
             easyModbusManager.EditConnection(connectionProperties, indexToEdit);
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Exception Adding connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.Close();
 }
 void Button1Click(object sender, EventArgs e)
 {
     try
     {
         if (!editMode)
         {
             easyModbusManager.AddConnection(connectionProperties);
         }
         else
         {
             easyModbusManager.EditConnection(connectionProperties, indexToEdit);
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Exception Adding connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.Close();
 }