public static UserSetting GetUserSettings()
 {
     var value = LoadUserSetting<UserSetting>();
     if (value == null)
         value = new UserSetting();
     return value;
 }
 public static void SaveUserSettings(UserSetting userSetting)
 {
     userSetting.SaveUserSetting<UserSetting>();
 }
        private void Settings_Load(object sender, EventArgs e)
        {
            userSetting = UserSetting.GetUserSettings();

            EndpointTextBox.Text = userSetting.Endpoint;
            APIKeyTextBox.Text = userSetting.APIKey;
            PasswordTextBox.Text = userSetting.Password;
            LabelDirectoryTextBox.Text = userSetting.LabelDirectory;
            AccountNumberTextBox.Text = userSetting.AccountNumber;
            MeterNumberTextBox.Text = userSetting.MeterNumber;

            DropOffComboBox.DataSource = Enum.GetValues(typeof(DropoffType));
            var dIdx = DropOffComboBox.Items.IndexOf(userSetting.DropOffType);
            if (dIdx > -1)
                DropOffComboBox.SelectedIndex = dIdx;

            ServiceTypeComboBox.DataSource = Enum.GetValues(typeof(ServiceType));
            var sIdx = ServiceTypeComboBox.Items.IndexOf(userSetting.ServiceType);
            if (sIdx > -1)
                ServiceTypeComboBox.SelectedIndex = sIdx;

            PackagingComboBox.DataSource = Enum.GetValues(typeof(PackagingType));
            var kIdx = PackagingComboBox.Items.IndexOf(userSetting.PackagingType);
            if (kIdx > -1)
                PackagingComboBox.SelectedIndex = kIdx;

            foreach (var printer in PrinterSettings.InstalledPrinters) {
                PrinterCombo.Items.Add(printer);
            }
            var pIdx = PrinterCombo.Items.IndexOf(userSetting.PrinterName);
            if (pIdx > -1)
                PrinterCombo.SelectedIndex = pIdx;

            CompanyNameTextBox.Text = userSetting.CompanyName;
            TelephoneTextBox.Text = userSetting.Telephone;
            EmailTextBox.Text = userSetting.Email;
            AddressLine1TextBox.Text = userSetting.AddressLine1;
            AddressLine2TextBox.Text = userSetting.AddressLine2;
            CityTextBox.Text = userSetting.City;
            StateTextBox.Text = userSetting.State;
            PostalCodeTextBox.Text = userSetting.PostalCode;
            CountryCodeTextBox.Text = userSetting.CountryCode;
        }