private void AddAction(int actionPanel, KeyValuePair <string, MakerSquare.FrontFacingECS.Tuple <string, string> > action, InputComponentControl component) { StackPanel child = (StackPanel)component.KeyActionsPanel.Children[actionPanel]; ComboBox keyBox = (ComboBox)child.Children[1]; ComboBox keyStateBox = (ComboBox)child.Children[2]; ComboBox methodBox = (ComboBox)child.Children[3]; string keyBoxValue = action.Key.Substring("Ultraviolet.Input.Key.".Length); string keyStateBoxValue = action.Value.Item1.Substring("OnKey.".Length); string methodBoxValue = action.Value.Item2; int i = 0; foreach (ComboBoxItem item in keyBox.Items) { if (item.ToString().Substring("System.Windows.Controls.ComboBoxItem: ".Length) == keyBoxValue) { keyBox.SelectedIndex = i; break; } i++; } i = 0; foreach (ComboBoxItem item in keyStateBox.Items) { if (item.ToString().Substring("System.Windows.Controls.ComboBoxItem: ".Length) == keyStateBoxValue) { keyStateBox.SelectedIndex = i; break; } i++; } i = 0; foreach (ComboBoxItem item in methodBox.Items) { if (item.ToString().Substring("System.Windows.Controls.ComboBoxItem: ".Length) == methodBoxValue) { methodBox.SelectedIndex = i; break; } i++; } }
public void SetComponentData(Entity entity) { var component = new InputComponentControl(entity); for (int i = 1; i < actions.Count; i++) { component.KeyActionsPanel.Children.Add(DeepCopy <StackPanel> .DeepCopyMethod(component.ActionPanel)); } int actionPanel = 0; foreach (var action in actions) { AddAction(actionPanel, action, component); actionPanel++; } entity.AddComponent(component); }