private void OnPropertyChanged([CallerMemberName] String propertyName = null)
        {
            try
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

                IniFile iniFile = new IniFile(_iniPath);
                switch (propertyName)
                {
                case nameof(ScreenResolution):
                    iniFile.WriteValue("Settings", propertyName, ScreenResolution ?? "1280x960");
                    break;

                case nameof(Windowed):
                    iniFile.WriteValue("Settings", propertyName, (Windowed).ToString());
                    break;

                case nameof(IsDebugMode):
                    iniFile.WriteValue("Memoria", propertyName, (IsDebugMode).ToString());
                    break;

                case nameof(IsX64):
                    iniFile.WriteValue("Memoria", propertyName, (IsX64).ToString());
                    break;
                }
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(Application.Current.MainWindow, ex);
            }
        }
Beispiel #2
0
        protected override async void OnClick()
        {
            try
            {
                IsEnabled = false;

                String label = Label;
                try
                {
                    await DoAction();
                }
                finally
                {
                    Label = label;
                }
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(this, ex);
            }
            finally
            {
                IsEnabled = true;
            }
        }
Beispiel #3
0
        private async void OnPropertyChanged([CallerMemberName] String propertyName = null)
        {
            try
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

                IniFile iniFile = new IniFile(_iniPath);
                switch (propertyName)
                {
                case nameof(ScreenResolution):
                    iniFile.WriteValue("Settings", propertyName, ScreenResolution ?? "1280x960");
                    break;

                case nameof(ActiveMonitor):
                    iniFile.WriteValue("Settings", propertyName, ActiveMonitor ?? String.Empty);
                    break;

                case nameof(Windowed):
                    iniFile.WriteValue("Settings", propertyName, (Windowed).ToString());
                    break;

                case nameof(IsDebugMode):
                    iniFile.WriteValue("Memoria", propertyName, (IsDebugMode).ToString());
                    break;

                case nameof(IsX64):
                    iniFile.WriteValue("Memoria", propertyName, (IsX64).ToString());
                    break;

                case nameof(CheckUpdates):
                {
                    iniFile.WriteValue("Memoria", propertyName, (CheckUpdates).ToString());
                    if (CheckUpdates)
                    {
                        using (ManualResetEvent evt = new ManualResetEvent(false))
                        {
                            Window root = this.GetRootElement() as Window;
                            if (root != null)
                            {
                                await UiLauncherPlayButton.CheckUpdates(root, evt, this);
                            }
                        }
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                UiHelper.ShowError(Application.Current.MainWindow, ex);
            }
        }
        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);
            }
        }
Beispiel #5
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);
            }
        }