/// <summary> /// Called when the user presses the OK button to commit any new set up values /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnOK_Click(object sender, EventArgs e) { if (addressList.Text == SharedConstants.LOCALHOST_NAME) { ServerForm.ServerIPAddressString = SharedConstants.LOCALHOST_ADDRESS; } else { ServerForm.ServerIPAddressString = addressList.Text; } ServerForm.ServerPortNumber = numPort.Value; ServerForm.StartWithDevicesConnected = chkAutoConnect.Checked; ServerForm.AccessLogEnabled = chkAccessLog.Checked; ServerForm.TraceState = chkTrace.Checked; ServerForm.DebugTraceState = chkDebugTrace.Checked; ServerForm.ManagementInterfaceEnabled = chkManagementInterfaceEnabled.Checked; ServerForm.StartWithApiEnabled = ChkStartWithApiEnabled.Checked; ServerForm.RunDriversOnSeparateThreads = ChkRunDriversInSeparateThreadss.Checked; foreach (ServedDevice item in this.Controls.OfType <ServedDevice>()) { ServerForm.ConfiguredDevices[item.Name].DeviceType = item.DeviceType; ServerForm.ConfiguredDevices[item.Name].ProgID = item.ProgID; ServerForm.ConfiguredDevices[item.Name].Description = item.Description; ServerForm.ConfiguredDevices[item.Name].DeviceNumber = item.DeviceNumber; ServerForm.ConfiguredDevices[item.Name].AllowConnectedSetFalse = item.AllowConnectedSetFalse; ServerForm.ConfiguredDevices[item.Name].AllowConnectedSetTrue = item.AllowConnectedSetTrue; } ServerForm.WriteProfile(); this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Called when the user presses the OK button to commit any new set up values /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnOK_Click(object sender, EventArgs e) { try { if (addressList.Text == SharedConstants.LOCALHOST_NAME_IPV4) { ServerForm.ServerIPAddressString = SharedConstants.LOCALHOST_ADDRESS_IPV4; } else { ServerForm.ServerIPAddressString = addressList.Text; } ServerForm.ServerPortNumber = numPort.Value; ServerForm.StartWithDevicesConnected = chkAutoConnect.Checked; ServerForm.AccessLogEnabled = chkAccessLog.Checked; ServerForm.TraceState = chkTrace.Checked; ServerForm.DebugTraceState = chkDebugTrace.Checked; ServerForm.ManagementInterfaceEnabled = chkManagementInterfaceEnabled.Checked; ServerForm.StartWithApiEnabled = ChkStartWithApiEnabled.Checked; ServerForm.RunDriversOnSeparateThreads = ChkRunDriversInSeparateThreadss.Checked; ServerForm.LogClientIPAddress = ChkLogClientIPAddress.Checked; ServerForm.IncludeDriverExceptionInJsonResponse = ChkIncludeDriverExceptionsInJsonResponses.Checked; ServerForm.RemoteServerLocation = TxtRemoteServerLocation.Text; ServerForm.CorsSupportIsEnabled = ChkEnableCors.Checked; ServerForm.CorsMaxAge = NumCorsMaxAge.Value; ServerForm.CorsCredentialsPermitted = ChkCorsSupportCredentials.Checked; ServerForm.AlpacaDiscoveryEnabled = ChkEnableDiscovery.Checked; ServerForm.AlpacaDiscoveryPort = NumDiscoveryPort.Value; ServerForm.MaximumNumberOfDevices = (int)NumMaxDevices.Value; // Set the IP v4 and v6 variables as necessary if (RadIpV4.Checked) // The IPv4 radio button is checked so set the IP v4 and IP v6 variables accordingly { ServerForm.IpV4Enabled = true; ServerForm.IpV6Enabled = false; } if (RadIpV6.Checked) // The IPv6 radio button is checked so set the IP v4 and IP v6 variables accordingly { ServerForm.IpV4Enabled = false; ServerForm.IpV6Enabled = true; } if (RadIpV4AndV6.Checked) // The IPv4 and IPV6 radio button is checked so set the IP v4 and IP v6 variables accordingly { ServerForm.IpV4Enabled = true; ServerForm.IpV6Enabled = true; } foreach (ServedDevice item in deviceList) { ServerForm.ConfiguredDevices[item.Name].DeviceType = item.DeviceType; // Update the unique ID if the ProgID has changed if (ServerForm.ConfiguredDevices[item.Name].ProgID != item.ProgID) { if (item.ProgID == SharedConstants.DEVICE_NOT_CONFIGURED) // Device has been de-configured { ServerForm.ConfiguredDevices[item.Name].UniqueID = SharedConstants.DEVICE_NOT_CONFIGURED; } else // Device has been changed so create a new unique ID { ServerForm.ConfiguredDevices[item.Name].UniqueID = Guid.NewGuid().ToString().ToUpperInvariant(); } } ServerForm.ConfiguredDevices[item.Name].ProgID = item.ProgID; ServerForm.ConfiguredDevices[item.Name].Description = item.Description; ServerForm.ConfiguredDevices[item.Name].DeviceNumber = item.DeviceNumber; ServerForm.ConfiguredDevices[item.Name].AllowConnectedSetFalse = item.AllowConnectedSetFalse; ServerForm.ConfiguredDevices[item.Name].AllowConnectedSetTrue = item.AllowConnectedSetTrue; ServerForm.ConfiguredDevices[item.Name].AllowConcurrentAccess = item.AllowConcurrentAccess; } ServerForm.CorsPermittedOrigins = corsPermittedOriginsCopy.ToListString(); // Copy the edited list back to the master copy ServerForm.WriteProfile(); if (maxDevicesHasChanged) { MessageBox.Show("The maximum number of devices has changed, please close and restart the Remote Server before adding further devices.", "Maximum Number of Devices", MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { ServerForm.LogException(0, 0, 0, "OK Button", string.Format("Exception on closing form: {0}.", ex.ToString())); } }