/// <summary> /// Sets the settings from the UI values /// </summary> public void SetSettingsFromUI(HydraSettings settings) { var grid = (Grid)Content; foreach (var item in grid.Children) { if (item is CheckBox checkbox) { settings[checkbox.Name] = checkbox.IsChecked == true ? "Yes" : "No"; } else if (item is TextBox box) { if (box.Name.StartsWith("Float")) { settings[box.Name.Substring(5)] = float.TryParse(box.Text, out var val) ? box.Text : "1.0"; } else if (box.Name.StartsWith("Integer")) { settings[box.Name.Substring(7)] = int.TryParse(box.Text, out var val) ? box.Text : "1"; } else { settings[box.Name] = box.Text; } } } }
/// <summary> /// Sets up the UI from settings /// </summary> public void SetUIFromSettings(HydraSettings settings) { var grid = (Grid)Content; foreach (var item in grid.Children) { if (item is CheckBox checkbox) { checkbox.IsChecked = settings[checkbox.Name, checkbox.IsChecked == true ? "Yes" : "No"] == "Yes"; } else if (item is TextBox box) { if (box.Name.StartsWith("Float")) { box.Text = settings[box.Name.Substring(5), "1.0"]; } else if (box.Name.StartsWith("Integer")) { box.Text = settings[box.Name.Substring(7), "1"]; } else { box.Text = settings[box.Name, ""]; } } } }