예제 #1
0
        public bool Save(string name, VStancerPreset preset)
        {
            // Check if the preset and the ID are valid
            if (string.IsNullOrEmpty(name) || preset == null)
            {
                return(false);
            }

            // Get the KVP key
            string key = string.Concat(mKvpPrefix, name);

            // Be sure the key isn't already used
            if (GetResourceKvpString(key) != null)
            {
                return(false);
            }

            // Get the Json
            var json = JsonConvert.SerializeObject(preset);

            // Save the KVP
            SetResourceKvp(key, json);

            // Invoke the event
            PresetsListChanged?.Invoke(this, EventArgs.Empty);

            return(true);
        }
예제 #2
0
        public bool Delete(string name)
        {
            // Check if the preset ID is valid
            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }

            // Get the KVP key
            string key = string.Concat(mKvpPrefix, name);

            // Check if a KVP with the given key exists
            if (GetResourceKvpString(key) == null)
            {
                return(false);
            }

            // Delete the KVP
            DeleteResourceKvp(key);

            // Invoke the event
            PresetsListChanged?.Invoke(this, EventArgs.Empty);

            return(true);
        }