private void LoadSettings()
        {
            try
            {
                IniFile iniFile = new IniFile(_iniPath);

                String value = iniFile.ReadValue("Settings", nameof(ScreenResolution));
                if (String.IsNullOrEmpty(value))
                {
                    value = "1280x960";
                }
                _resolution = value;

                value = iniFile.ReadValue("Settings", nameof(Windowed));
                if (String.IsNullOrEmpty(value))
                {
                    value = "true";
                }
                if (!Boolean.TryParse(value, out _isWindowMode))
                {
                    _isWindowMode = true;
                }

                value = iniFile.ReadValue("Memoria", nameof(IsX64));
                if (String.IsNullOrEmpty(value))
                {
                    value = "true";
                }
                if (!Boolean.TryParse(value, out _isX64))
                {
                    _isX64 = true;
                }

                if (!Environment.Is64BitOperatingSystem || !Directory.Exists("x64"))
                {
                    _isX64        = false;
                    _isX64Enabled = false;
                }
                else if (!Directory.Exists("x86"))
                {
                    _isX64        = true;
                    _isX64Enabled = false;
                }

                value = iniFile.ReadValue("Memoria", nameof(IsDebugMode));
                if (String.IsNullOrEmpty(value))
                {
                    value = "false";
                }
                if (!Boolean.TryParse(value, out _isDebugMode))
                {
                    _isDebugMode = false;
                }

                OnPropertyChanged(nameof(ScreenResolution));
                OnPropertyChanged(nameof(Windowed));
                OnPropertyChanged(nameof(IsX64));
                OnPropertyChanged(nameof(IsX64Enabled));
                OnPropertyChanged(nameof(IsDebugMode));
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(Application.Current.MainWindow, ex);
            }
        }
Esempio n. 2
0
        private void LoadSettings()
        {
            try
            {
                IniFile iniFile = new IniFile(_iniPath);

                String value = iniFile.ReadValue("Settings", nameof(ScreenResolution));
                if (String.IsNullOrEmpty(value))
                {
                    value = "1280x960";
                }
                _resolution = value;

                value = iniFile.ReadValue("Settings", nameof(ActiveMonitor));
                if (!String.IsNullOrEmpty(value))
                {
                    _activeMonitor = value;
                }

                value = iniFile.ReadValue("Settings", nameof(Windowed));
                if (String.IsNullOrEmpty(value))
                {
                    value = "true";
                }
                if (!Boolean.TryParse(value, out _isWindowMode))
                {
                    _isWindowMode = true;
                }

                value = iniFile.ReadValue("Memoria", nameof(IsX64));
                if (String.IsNullOrEmpty(value))
                {
                    value = "true";
                }
                if (!Boolean.TryParse(value, out _isX64))
                {
                    _isX64 = true;
                }

                if (!Environment.Is64BitOperatingSystem || !Directory.Exists("x64"))
                {
                    _isX64        = false;
                    _isX64Enabled = false;
                }
                else if (!Directory.Exists("x86"))
                {
                    _isX64        = true;
                    _isX64Enabled = false;
                }

                UInt16  x64SamplingFrequency;
                UInt16  x86SamplingFrequency;
                Boolean?x64SamplingReaded = TryReadAudioSamplingFrequency(@"x64\FF9_Data\Plugins\SdLib.dll", out x64SamplingFrequency);
                Boolean?x86SamplingReaded = TryReadAudioSamplingFrequency(@"x86\FF9_Data\Plugins\SdLib.dll", out x86SamplingFrequency);
                if (x64SamplingReaded != true && x86SamplingReaded != true)
                {
                    _audioFrequency        = 32000;
                    _audioFrequencyEnabled = false;
                }
                else
                {
                    _audioFrequency = Math.Max(x86SamplingFrequency, x64SamplingFrequency);

                    if (x64SamplingFrequency < x86SamplingFrequency)
                    {
                        TryWriteAudioSamplingFrequency(true, _audioFrequency, true);
                    }
                    else if (x86SamplingFrequency < x64SamplingFrequency)
                    {
                        TryWriteAudioSamplingFrequency(false, _audioFrequency, true);
                    }
                }

                value = iniFile.ReadValue("Memoria", nameof(IsDebugMode));
                if (String.IsNullOrEmpty(value))
                {
                    value = "false";
                }
                if (!Boolean.TryParse(value, out _isDebugMode))
                {
                    _isDebugMode = false;
                }

                OnPropertyChanged(nameof(ScreenResolution));
                OnPropertyChanged(nameof(ActiveMonitor));
                OnPropertyChanged(nameof(Windowed));
                OnPropertyChanged(nameof(AudioFrequency));
                OnPropertyChanged(nameof(AudioFrequencyEnabled));
                OnPropertyChanged(nameof(IsX64));
                OnPropertyChanged(nameof(IsX64Enabled));
                OnPropertyChanged(nameof(IsDebugMode));
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(Application.Current.MainWindow, ex);
            }
        }