public void SetupDialog()
        {
            TL.LogMessage(clientNumber, "SetupDialog", "Connected: " + clientIsConnected.ToString());
            if (clientIsConnected)
            {
                MessageBox.Show("Simulator is connected, setup parameters cannot be changed, please press OK");
            }
            else
            {
                TL.LogMessage(clientNumber, "SetupDialog", "Creating setup form");
                using (setupForm = new SetupDialogForm(TL))
                {
                    // Pass the setup dialogue data into the form
                    setupForm.DriverDisplayName          = DriverDisplayName;
                    setupForm.TraceState                 = traceState;
                    setupForm.DebugTraceState            = debugTraceState;
                    setupForm.ServiceType                = serviceType;
                    setupForm.IPAddressString            = ipAddressString;
                    setupForm.PortNumber                 = portNumber;
                    setupForm.RemoteDeviceNumber         = remoteDeviceNumber;
                    setupForm.EstablishConnectionTimeout = establishConnectionTimeout;
                    setupForm.StandardTimeout            = standardServerResponseTimeout;
                    setupForm.LongTimeout                = longServerResponseTimeout;
                    setupForm.UserName               = userName;
                    setupForm.Password               = password;
                    setupForm.ManageConnectLocally   = manageConnectLocally;
                    setupForm.ImageArrayTransferType = imageArrayTransferType;
                    setupForm.DeviceType             = DEVICE_TYPE;

                    TL.LogMessage(clientNumber, "SetupDialog", "Showing Dialogue");
                    var result = setupForm.ShowDialog();
                    TL.LogMessage(clientNumber, "SetupDialog", "Dialogue closed");
                    if (result == DialogResult.OK)
                    {
                        TL.LogMessage(clientNumber, "SetupDialog", "Dialogue closed with OK status");

                        // Retrieve revised setup data from the form
                        traceState                    = setupForm.TraceState;
                        debugTraceState               = setupForm.DebugTraceState;
                        serviceType                   = setupForm.ServiceType;
                        ipAddressString               = setupForm.IPAddressString;
                        portNumber                    = setupForm.PortNumber;
                        remoteDeviceNumber            = setupForm.RemoteDeviceNumber;
                        establishConnectionTimeout    = (int)setupForm.EstablishConnectionTimeout;
                        standardServerResponseTimeout = (int)setupForm.StandardTimeout;
                        longServerResponseTimeout     = (int)setupForm.LongTimeout;
                        userName               = setupForm.UserName;
                        password               = setupForm.Password;
                        manageConnectLocally   = setupForm.ManageConnectLocally;
                        imageArrayTransferType = setupForm.ImageArrayTransferType;

                        // Write the changed values to the Profile
                        TL.LogMessage(clientNumber, "SetupDialog", "Writing new values to profile");
                        RemoteClientDriver.WriteProfile(clientNumber, TL, DEVICE_TYPE, DriverProgId,
                                                        traceState, debugTraceState, ipAddressString, portNumber, remoteDeviceNumber, serviceType, establishConnectionTimeout, standardServerResponseTimeout, longServerResponseTimeout, userName, password, manageConnectLocally, imageArrayTransferType, imageArrayCompression);

                        // Establish new host and device parameters
                        TL.LogMessage(clientNumber, "SetupDialog", "Establishing new host and device parameters");
                        RemoteClientDriver.ConnectToRemoteServer(ref client, ipAddressString, portNumber, serviceType, TL, clientNumber, DEVICE_TYPE, standardServerResponseTimeout, userName, password);
                    }
                    else
                    {
                        TL.LogMessage(clientNumber, "SetupDialog", "Dialogue closed with Cancel status");
                    }
                }
                if (!(setupForm == null))
                {
                    setupForm.Dispose();
                    setupForm = null;
                }
            }
        }