void InitData() { //InitDefaultPTZSpaces(); //Nodes.Clear(); Presets.Clear(); model.presets.ForEach(x => { Presets.Add(x); }); valuePresetName.CreateBinding(TextBox.TextProperty, this, x => x.PresetName, (m, v) => { m.PresetName = v; }); valuePresetsList.ItemsSource = Presets; valuePresetsList.CreateBinding(ListBox.SelectedItemProperty, this, x => x.SelectedPreset, (m, v) => m.SelectedPreset = v); var node = model.node; if (node == null) { return; } var supportedPtzSpaces = node.supportedPTZSpaces; if (supportedPtzSpaces == null) { return; } ptzConfig = model.profile.ptzConfiguration; if (ptzConfig == null) { return; } ptzSpacesConfig.Setup(ptzConfig, supportedPtzSpaces); }
public async Task InitializeAsync() { try { StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("_Settings_LoadPresets".GetLocalized())); string dataString = await FileIO.ReadTextAsync(file); Presets.Clear(); foreach (Preset p in JsonConvert.DeserializeObject <List <Preset> >(dataString)) { Presets.Add(p); } ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; if (localSettings.Values.TryGetValue("SELECTED_PRESET", out object obj)) { SelectedPreset = Presets.Where(p => p.Id == (string)(obj)).FirstOrDefault(); } else { SelectedPreset = Presets.Where(p => p.Id == "Default").FirstOrDefault(); } } catch (Exception) { } }
// TODO: Split for optimization? private async Task RebuildPresetsList() { if (_reloading) { return; } _reloading = true; PresetsReady = false; try { Presets.Clear(); _builtInPresets = await ScanAsync(ControlsSettings.SubBuiltInPresets); _userPresets = await ScanAsync(ControlsSettings.SubUserPresets); Presets.Add(Rebuild(ControlsStrings.Controls_BuiltInPresets, ControlsSettings.SubBuiltInPresets, _builtInPresets)); Presets.Add(Rebuild(ControlsStrings.Controls_UserPresets, ControlsSettings.SubUserPresets, _userPresets)); PresetsReady = true; } catch (Exception e) { Logging.Warning("RebuildPresetsList(): " + e); } finally { _reloading = false; } }
private void LoadPresetItems(bool clearBeforeLoading = true) { Presets.Clear(); SelectedPreset = null; PresetsProvider.ReloadPresetItems(); Presets.AddRange(PresetsProvider.PresetItems); Presets.IsDirty = false; IsDirty = false; SelectedPreset = Presets.FirstOrDefault(); }
bool LoadPresets(bool silentErrors = true) { var loadedPresets = new List <AutoSplitList>(); var corruptedPresets = new List <string>(); var success = true; try { var doc = new XmlDocument(); doc.Load(PRESETS_FILE_PATH); foreach (XmlElement listElem in doc.DocumentElement) { AutoSplitList preset; try { preset = AutoSplitList.FromXml(listElem, _autoSplitEnv); } catch { corruptedPresets.Add(listElem["Name"]?.InnerText); continue; } loadedPresets.Add(preset); } if (!silentErrors && corruptedPresets.Count != 0) { var errorMessage = new System.Text.StringBuilder(); errorMessage.AppendLine("The following presets could not be loaded:"); foreach (var preset in corruptedPresets) { string name = preset != null ? $"\"{preset}\"" : "(could not retrieve the name)"; errorMessage.AppendLine($"\t{name}"); } MessageBox.Show(errorMessage.ToString(), "Preset import error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { success = false; if (!silentErrors) { MessageBox.Show("Update failed.", "Presets update failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Presets.Clear(); Presets.Add(CustomAutosplits); foreach (var item in loadedPresets.OrderBy(x => x.Name)) { Presets.Add(item); } return(success); }
/// <summary> /// Import presets from mod and local presets from disk. /// </summary> public void LoadPresets() { if (Presets.Count > 0) { Presets.Clear(); } // Get presets from mod if (mod.HasAsset(presetsFileName)) { List <Preset> modPresets = new List <Preset>(); if (TryDeserialize(mod, presetsFileName, ref modPresets)) { Presets.AddRange(modPresets); } } // Local presets (managed from gui) Directory.CreateDirectory(mod.ConfigurationDirectory); string localPresetsPath = LocalPresetsPath; if (File.Exists(LegacyLocalPresetsPath)) { ModManager.MoveOldConfigFile(LegacyLocalPresetsPath, localPresetsPath); } if (File.Exists(localPresetsPath)) { List <Preset> localPresets = new List <Preset>(); if (TryDeserialize(localPresetsPath, ref localPresets)) { foreach (var preset in localPresets) { preset.IsLocal = true; } Presets.AddRange(localPresets); } } // Imported presets (readonly) Presets.AddRange(TextAssetReader.ReadAll <Preset>(string.Format("Presets/{0}", mod.FileName), "json")); // Legacy imported presets (readonly) foreach (string path in Directory.GetFiles(mod.DirPath, string.Format("{0}_presets_*.json", mod.FileName))) { List <Preset> importedPresets = new List <Preset>(); if (TryDeserialize(path, ref importedPresets)) { Presets.AddRange(importedPresets); } Debug.LogWarningFormat($"Imported legacy preset for {mod}."); } HasLoadedPresets = true; }
void UpdatePresetList() { Presets.Clear(); for (var a = 0; a < 128; ++a) { var name = BassMidi.FontGetPreset(_font, a, _drums ? 128 : 0) ?? ""; // get preset name Presets.Add(new KeyValuePair <int, string>(a, $"{a:D3}: {name}")); } Preset = 0; }
/// <summary> /// Import presets from path. /// </summary> public void LoadPresets(string path, bool merge = false) { if (!merge && Presets.Count > 0) { Presets.Clear(); } List <Preset> presetData = new List <Preset>(); if (TryDeserialize(path, ref presetData)) { Presets.AddRange(presetData); } }
void ReloadPresets() { Presets.Clear(); subscription.Add(CurrentSession.GetPresets(profileToken) .ObserveOnCurrentDispatcher() .Subscribe(presets => { presets.ForEach(pres => { Presets.Add(pres); }); }, err => { dbg.Error(err); SetErrorMessage(err.Message); })); }
/// <summary> /// Import presets from mod and local presets from disk. /// </summary> public void LoadPresets() { if (Presets.Count > 0) { Presets.Clear(); } // Get presets from mod if (mod.AssetBundle.Contains(presetsFileName)) { List <Preset> modPresets = new List <Preset>(); if (TryDeserialize(mod, presetsFileName, ref modPresets)) { Presets.AddRange(modPresets); } } // Local presets (managed from gui) string localPresetsPath = LocalPresetsPath; if (File.Exists(localPresetsPath)) { List <Preset> localPresets = new List <Preset>(); if (TryDeserialize(localPresetsPath, ref localPresets)) { foreach (var preset in localPresets) { preset.IsLocal = true; } Presets.AddRange(localPresets); } } // Other imported presets (readonly) foreach (string path in ImportedPresetsPaths) { List <Preset> importedPresets = new List <Preset>(); if (TryDeserialize(path, ref importedPresets)) { Presets.AddRange(importedPresets); } } HasLoadedPresets = true; }
public override void LoadFromResponse(string apiname, dynamic data) { switch (apiname) { case "api_get_member/preset_deck": { MaximumCount = (int)data.api_max_num; Presets.Clear(); foreach (KeyValuePair <string, dynamic> elem in data.api_deck) { var preset = new FleetPresetData(); preset.LoadFromResponse(apiname, elem.Value); Presets.Add(preset); } PresetChanged(); } break; case "api_req_hensei/preset_register": { int id = (int)data.api_preset_no; if (Presets.ContainsKey(id)) { Presets[id].LoadFromResponse(apiname, data); } else { var preset = new FleetPresetData(); preset.LoadFromResponse(apiname, data); Presets.Add(preset); } PresetChanged(); } break; } base.LoadFromResponse(apiname, (object)data); }
/// <summary> /// Try to parse a legacy ini file. /// </summary> public void ImportLegacyIni(IniData iniData) { Sections.Clear(); Presets.Clear(); foreach (SectionData section in iniData.Sections) { var dataSection = new Section(); dataSection.Name = section.SectionName; foreach (KeyData key in section.Keys) { Key dataKey; if (key.Value == "True" || key.Value == "False") { dataKey = new ToggleKey(); } else { dataKey = new TextKey(); } if (section.SectionName == "Internal" && key.KeyName == "SettingsVersion") { Version = key.Value; continue; } dataKey.Name = key.KeyName; dataKey.TextValue = key.Value; dataSection.Keys.Add(dataKey); } if (dataSection.Keys.Count > 0) { Sections.Add(dataSection); } } }
public void SetConfig(CCModConfig.CharacterProject characterConfig) { CharacterConfig = characterConfig; Item chestItem = new Item(Category.Chest); Item braItem = new Item(Category.Bra); Item pantyItem = new Item(Category.Panty); Item skirtItem = new Item(Category.Skirt); Item glovesItem = new Item(Category.Gloves); Item shoesItem = new Item(Category.Shoes); Item acc1Item = new Item(Category.Accessory1); Item acc2Item = new Item(Category.Accessory2); Item acc3Item = new Item(Category.Accessory3); Item acc4Item = new Item(Category.Accessory4); foreach (CCModConfig.Item item in characterConfig.Items) { switch (item.ItemCategory) { case Category.Chest: chestItem = item; break; case Category.Bra: braItem = item; break; case Category.Panty: pantyItem = item; break; case Category.Skirt: skirtItem = item; break; case Category.Gloves: glovesItem = item; break; case Category.Shoes: shoesItem = item; break; case Category.Accessory1: acc1Item = item; break; case Category.Accessory2: acc2Item = item; break; case Category.Accessory3: acc3Item = item; break; case Category.Accessory4: acc4Item = item; break; } } this.itemBuilderChest.SetConfig(chestItem, characterConfig.Model); this.itemBuilderBra.SetConfig(braItem, characterConfig.Model); this.itemBuilderPanties.SetConfig(pantyItem, characterConfig.Model); this.itemBuilderSkirt.SetConfig(skirtItem, characterConfig.Model); this.itemBuilderGloves.SetConfig(glovesItem, characterConfig.Model); this.itemBuilderShoes.SetConfig(shoesItem, characterConfig.Model); this.itemBuilderAcc1.SetConfig(acc1Item, characterConfig.Model); this.itemBuilderAcc2.SetConfig(acc2Item, characterConfig.Model); this.itemBuilderAcc3.SetConfig(acc3Item, characterConfig.Model); this.itemBuilderAcc4.SetConfig(acc4Item, characterConfig.Model); Presets.Clear(); foreach (Preset aPreset in characterConfig.Presets) { Presets.Add(aPreset); } textBoxIcon.Text = characterConfig.IconFile; UpdateIcon(); textBoxPreview.Text = characterConfig.PreviewFile; UpdatePreview(); // Combo Boxes must be synced before its bound. SyncComboBoxes(); BindingSource presetBindSource = new BindingSource(); presetBindSource.DataSource = Presets; this.listBox1.DataSource = presetBindSource; this.listBox1.DisplayMember = "Name"; }
private void CreateDspObjects() { Debug.Console(2, "Creating DSP Objects"); var props = JsonConvert.DeserializeObject <TesiraDspPropertiesConfig>(_dc.Properties.ToString()); if (props == null) { return; } Debug.Console(2, this, "Props Exists"); Debug.Console(2, this, "Here's the props string\n {0}", _dc.Properties.ToString()); Faders.Clear(); Presets.Clear(); Dialers.Clear(); States.Clear(); Switchers.Clear(); ControlPointList.Clear(); Meters.Clear(); RoomCombiners.Clear(); if (props.FaderControlBlocks != null) { Debug.Console(2, this, "levelControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count()); foreach (var block in props.FaderControlBlocks) { var key = block.Key; Debug.Console(2, this, "LevelControlBlock Key - {0}", key); var value = block.Value; Faders.Add(key, new TesiraDspFaderControl(key, value, this)); Debug.Console(2, this, "Added LevelControlPoint {0} LevelTag: {1} MuteTag: {2}", key, value.LevelInstanceTag, value.MuteInstanceTag); if (block.Value.Enabled) { //Add ControlPoint to the list for the watchdog ControlPointList.Add(Faders[key]); } } } if (props.SwitcherControlBlocks != null) { Debug.Console(2, this, "switcherControlBlocks is not null - There are {0} of them", props.FaderControlBlocks.Count()); foreach (var block in props.SwitcherControlBlocks) { var key = block.Key; Debug.Console(2, this, "SwitcherControlBlock Key - {0}", key); var value = block.Value; Switchers.Add(key, new TesiraDspSwitcher(key, value, this)); Debug.Console(2, this, "Added TesiraSwitcher {0} InstanceTag {1}", key, value.SwitcherInstanceTag); if (block.Value.Enabled) { //Add ControlPoint to the list for the watchdog ControlPointList.Add(Switchers[key]); } } } if (props.DialerControlBlocks != null) { Debug.Console(2, this, "DialerControlBlocks is not null - There are {0} of them", props.DialerControlBlocks.Count()); foreach (var block in props.DialerControlBlocks) { var key = block.Key; Debug.Console(2, this, "LevelControlBlock Key - {0}", key); var value = block.Value; Dialers.Add(key, new TesiraDspDialer(key, value, this)); Debug.Console(2, this, "Added DspDialer {0} ControlStatusTag: {1} DialerTag: {2}", key, value.ControlStatusInstanceTag, value.DialerInstanceTag); if (block.Value.Enabled) { ControlPointList.Add(Dialers[key]); } } } if (props.StateControlBlocks != null) { Debug.Console(2, this, "stateControlBlocks is not null - There are {0} of them", props.StateControlBlocks.Count()); foreach (var block in props.StateControlBlocks) { var key = block.Key; var value = block.Value; States.Add(key, new TesiraDspStateControl(key, value, this)); Debug.Console(2, this, "Added DspState {0} InstanceTag: {1}", key, value.StateInstanceTag); if (block.Value.Enabled) { ControlPointList.Add(States[key]); } } } if (props.Presets != null) { foreach (var preset in props.Presets) { var value = preset.Value; var key = preset.Key; Presets.Add(key, value); Debug.Console(2, this, "Added Preset {0} {1}", value.Label, value.PresetName); } } if (props.MeterControlBlocks != null) { foreach (var meter in props.MeterControlBlocks) { var key = meter.Key; var value = meter.Value; Meters.Add(key, new TesiraDspMeter(key, value, this)); Debug.Console(2, this, "Adding Meter {0} InstanceTag: {1}", key, value.MeterInstanceTag); if (value.Enabled) { ControlPointList.Add(Meters[key]); } } } if (props.CrosspointStateControlBlocks != null) { foreach (var mixer in props.CrosspointStateControlBlocks) { var key = mixer.Key; var value = mixer.Value; CrosspointStates.Add(key, new TesiraDspCrosspointState(key, value, this)); Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.MatrixInstanceTag); if (value.Enabled) { ControlPointList.Add(CrosspointStates[key]); } } } if (props.RoomCombinerControlBlocks == null) { return; } foreach (var roomCombiner in props.RoomCombinerControlBlocks) { var key = roomCombiner.Key; var value = roomCombiner.Value; RoomCombiners.Add(key, new TesiraDspRoomCombiner(key, value, this)); Debug.Console(2, this, "Adding Mixer {0} InstanceTag: {1}", key, value.RoomCombinerInstanceTag); if (value.Enabled) { ControlPointList.Add(RoomCombiners[key]); } } //Keep me at the end of this method! DeviceManager.AddDevice(new TesiraDspDeviceInfo(String.Format("{0}--DeviceInfo", Key), String.Format("{0}--DeviceInfo", Name, Presets), this, Presets)); }
public void Clear() { Presets.Clear(); Keys.Clear(); presets.Clear(); }
/// <summary> /// Import presets from mod and local presets from disk. /// </summary> public void LoadPresets() { if (Presets.Count > 0) { Presets.Clear(); } // Get presets from mod if (mod.HasAsset(presetsFileName)) { List <Preset> modPresets = new List <Preset>(); if (TryDeserialize(mod, presetsFileName, ref modPresets)) { Presets.AddRange(modPresets); } } // Local presets (managed from gui) Directory.CreateDirectory(mod.ConfigurationDirectory); string localPresetsPath = LocalPresetsPath; if (File.Exists(LegacyLocalPresetsPath)) { ModManager.MoveOldConfigFile(LegacyLocalPresetsPath, localPresetsPath); } if (File.Exists(localPresetsPath)) { List <Preset> localPresets = new List <Preset>(); if (TryDeserialize(localPresetsPath, ref localPresets)) { foreach (var preset in localPresets) { preset.IsLocal = true; } Presets.AddRange(localPresets); } } // Other imported presets (readonly) foreach (string path in Directory.GetFiles(mod.DirPath, string.Format("{0}_presets_*.json", mod.FileName))) { List <Preset> importedPresets = new List <Preset>(); if (TryDeserialize(path, ref importedPresets)) { Presets.AddRange(importedPresets); } } string presetsDirectory = Path.Combine(mod.ConfigurationDirectory, "Presets"); if (Directory.Exists(presetsDirectory)) { foreach (string path in Directory.GetFiles(presetsDirectory, "*.json")) { List <Preset> importedPresets = new List <Preset>(); if (TryDeserialize(path, ref importedPresets)) { Presets.AddRange(importedPresets); } } } HasLoadedPresets = true; }