/// <summary> /// Loads the settings of the message queue. /// </summary> void LoadSettings() { var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Softlex\SMS\" + guid.ToString(), false); if (key == null) { return; } // Get the endpoint and token. endpointTextBox.Text = (key.GetValue("Endpoint", "") as string) ?? ""; tokenTextBox.Text = (key.GetValue("Token", "") as string) ?? ""; // Get the list of accepted countries. countriesListBox.Items.Clear(); if (key.GetValue("Countries") is string[] countryCodes) { foreach (string countryCode in countryCodes) { var country = Countries.GetByCountryCode(countryCode); if (country == null) { continue; } countriesListBox.Items.Add(country); } } UpdateFormatList(); // Check if country restrictions have been enabled. restrictCountriesCheckBox.Checked = Convert.ToInt32(key.GetValue("CountryRestriction", 0)) == 1; // Get the queue filter policy. var queuePolicy = (MessageQueueNumberPolicy)Convert.ToInt32(key.GetValue("NumberPolicy", 0)); switch (queuePolicy) { case MessageQueueNumberPolicy.AcceptAndConvert: acceptRadioButton.Checked = true; break; case MessageQueueNumberPolicy.Reject: rejectRadioButton.Checked = true; break; } // Get the converstion target country. string queuePolicyTargetCode = key.GetValue("NumberPolicyTarget") as string ?? ""; if (!string.IsNullOrWhiteSpace(queuePolicyTargetCode)) { Country queuePolicyTarget = Countries.GetByCountryCode(queuePolicyTargetCode); if (queuePolicyTarget != null) { countryComboBox.SelectedItem = queuePolicyTarget; } } // Get the way in which large messages received by this queue need to be handled. int largeMessagePolicy = (int)key.GetValue("LargeMessagePolicy", 1); switch (largeMessagePolicy) { case 1: splitLargeMessagesRadioButton.Checked = true; break; default: rejectLargeMessagesRadioButton.Checked = true; break; } // Get the maximum message length. int maxLength = (int)key.GetValue("MaxMessageSize", 160); if (maxLength < 1) { maxLength = 1; } else if (maxLength > 999) { maxLength = 999; } maxLengthTextBox.Text = maxLength.ToString(); }