Example #1
0
        public void SetValue(string settingsKey, string settingsValue, PrinterSettingsLayer layer = null)
        {
            // Stash user overrides if a non-user override is being set
            if (layer != null && layer != UserLayer)
            {
                StashUserOverride(layer, settingsKey);
            }
            else
            {
                // Remove any staged/conflicting user override, making this the new and active user override
                if (StagedUserSettings.ContainsKey(settingsKey))
                {
                    StagedUserSettings.Remove(settingsKey);
                }
            }

            var persistenceLayer = layer ?? UserLayer;

            // If the setting exists and is set to the requested value, exit without setting or saving
            string existingValue;

            if (persistenceLayer.TryGetValue(settingsKey, out existingValue) && existingValue == settingsValue)
            {
                return;
            }

            // Otherwise, set and save
            persistenceLayer[settingsKey] = settingsValue;
            Save();

            ActiveSliceSettings.OnSettingChanged(settingsKey);
        }
Example #2
0
        private void RestoreUserOverride(PrinterSettingsLayer settingsLayer, string settingsKey)
        {
            string stagedUserOverride;

            if (StagedUserSettings.TryGetValue(settingsKey, out stagedUserOverride))
            {
                StagedUserSettings.Remove(settingsKey);
                UserLayer[settingsKey] = stagedUserOverride;
            }
        }