private SettingsService()
 {
     _iniConfigFileManager = new IniConfigFileManager();
     _settings             = PriceCalcSettings.GetDefaultSettings();
     _appSettingsFilename  = ApplicationDataFolder + "\\" + CONFIG_FILENAME;
     CreateAppDataFolderIfMissing();
 }
        public bool LoadSettings()
        {
            try
            {
                if (!File.Exists(_appSettingsFilename))
                {
                    return(false);
                }

                if (_iniConfigFileManager.LoadConfigFile(_appSettingsFilename))
                {
                    _settings = new PriceCalcSettings();

                    IniConfigFileSection exchangeRateConfigFileSection = _iniConfigFileManager.ConfigurationData.ConfigSections["ExchangeRates"];
                    _settings.BTC_Price    = double.Parse(exchangeRateConfigFileSection.ConfigItems["BTC_Price"]);
                    _settings.SEK_USD_Rate = double.Parse(exchangeRateConfigFileSection.ConfigItems["SEK_USD_Rate"]);
                    _settings.Commision    = double.Parse(exchangeRateConfigFileSection.ConfigItems["Commision"]);

                    IniConfigFileSection uiConfigFileSection = _iniConfigFileManager.ConfigurationData.ConfigSections["UserInterface"];
                    _settings.Topmost        = uiConfigFileSection.ConfigItems["Topmost"] == "1";
                    _settings.AutofocusPrice = uiConfigFileSection.ConfigItems["AutofocusPrice"] == "1";

                    if (uiConfigFileSection.ConfigItems["StartupPosX"] != null)
                    {
                        int startX = int.Parse(uiConfigFileSection.ConfigItems["StartupPosX"]);
                        int startY = int.Parse(uiConfigFileSection.ConfigItems["StartupPosY"]);
                        _settings.StartPosition = new Coordinate(startX, startY);
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }