public void PinTweak(string TweakGroup, string name) { PresetGroup preset = FindPreset(name); TweakPreset item = new TweakPreset(); item.TweakGroup = TweakGroup; item.Sync(); // gets the name and so on preset.Items.Add(item.guid, item); UpdatePreset(preset); }
public void PinProg(Guid ProgSetId, string name) { PresetGroup preset = FindPreset(name); FirewallPreset item = new FirewallPreset(); item.ProgSetId = ProgSetId; item.Sync(); // gets the name and so on preset.Items.Add(item.guid, item); UpdatePreset(preset); }
public PresetGroup Clone() { PresetGroup preset = new PresetGroup(); preset.guid = this.guid; preset.Name = this.Name; preset.Icon = this.Icon; preset.Description = this.Description; //preset.Category = this.Category; preset.AutoUndo = this.AutoUndo; preset.UndoTime = this.UndoTime; preset.Items = this.Items.ToDictionary(entry => entry.Key, entry => entry.Value.Clone()); return(preset); }
public PresetGroup FindPreset(string name, bool orMake = true) { foreach (PresetGroup preset in Presets.Values) { if (preset.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return(preset); } } if (!orMake) { return(null); } var newPreset = new PresetGroup(); newPreset.Name = name; return(newPreset); }
public bool Load(string FilePath) { if (!File.Exists(FilePath)) { return(false); } #if !DEBUG try #endif { XmlDocument xDoc = new XmlDocument(); xDoc.Load(FilePath); foreach (XmlNode node in xDoc.DocumentElement.ChildNodes) { //LoadCount++; PresetGroup preset = new PresetGroup(); if (!preset.Load(node)) { //ErrorCount++; continue; } if (!Presets.ContainsKey(preset.guid)) { Presets.Add(preset.guid, preset); } } } #if !DEBUG catch (Exception err) { AppLog.Exception(err); return(false); } #endif return(true); }
public void UpdatePreset(PresetGroup preset) { if (!Presets.ContainsKey(preset.guid)) { Presets.Add(preset.guid, preset); preset = null; // trigger full list refresh } else { var oldPreset = Presets[preset.guid]; Presets[preset.guid] = preset; if (oldPreset.State) { oldPreset.SetState(false); preset.SetState(true); } } PresetChange?.Invoke(this, new PresetChangeArgs() { preset = preset }); }