예제 #1
0
        public void Setup()
        {
            // initialize creation of test settings file.
            // Test base path:
            // C:\Users\<user name>\AppData\Local\Packages\08e1807b-8b6d-4bfa-adc4-79c64aae8e78_9abkseg265h2m\LocalState\Microsoft\PowerToys\
            GeneralSettings       generalSettings = new GeneralSettings();
            ShortcutGuideSettings shortcutGuide   = new ShortcutGuideSettings();

            SettingsUtils.SaveSettings(generalSettings.ToJsonString());
            SettingsUtils.SaveSettings(shortcutGuide.ToJsonString(), ShortCutGuideTestFolderName);
        }
예제 #2
0
        public ShortcutGuideViewModel(ISettingsUtils settingsUtils, Func <string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
        {
            // Update Settings file folder:
            _settingsConfigFileFolder = configFileSubfolder;
            _settingsUtils            = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));

            try
            {
                Settings = _settingsUtils.GetSettings <ShortcutGuideSettings>(GetSettingsSubPath());
            }
            catch
            {
                Settings = new ShortcutGuideSettings();
                _settingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath());
            }

            GeneralSettings generalSettings;

            try
            {
                generalSettings = _settingsUtils.GetSettings <GeneralSettings>(string.Empty);
            }
            catch
            {
                generalSettings = new GeneralSettings();
                _settingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
            }

            // set the callback functions value to hangle outgoing IPC message.
            SendConfigMSG = ipcMSGCallBackFunc;

            _isEnabled = generalSettings.Enabled.ShortcutGuide;
            _pressTime = Settings.Properties.PressTime.Value;
            _opacity   = Settings.Properties.OverlayOpacity.Value;

            string theme = Settings.Properties.Theme.Value;

            if (theme == "dark")
            {
                _themeIndex = 0;
            }

            if (theme == "light")
            {
                _themeIndex = 1;
            }

            if (theme == "system")
            {
                _themeIndex = 2;
            }
        }
예제 #3
0
        public ShortcutGuideViewModel()
        {
            try
            {
                Settings = SettingsUtils.GetSettings <ShortcutGuideSettings>(ModuleName);
            }
            catch
            {
                Settings = new ShortcutGuideSettings();
                SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
            }

            GeneralSettings generalSettings;

            try
            {
                generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty);
            }
            catch
            {
                generalSettings = new GeneralSettings();
                SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
            }

            _isEnabled = generalSettings.Enabled.ShortcutGuide;
            _pressTime = Settings.Properties.PressTime.Value;
            _opacity   = Settings.Properties.OverlayOpacity.Value;

            string theme = Settings.Properties.Theme.Value;

            if (theme == "dark")
            {
                _themeIndex = 0;
            }

            if (theme == "light")
            {
                _themeIndex = 1;
            }

            if (theme == "system")
            {
                _themeIndex = 2;
            }
        }