public static void TestBlueprintSelection(BlueprintSearchedArgs e) { // Check if the comboBox has a selected item if (e.SearchComboBox.SelectedItem != null) { Blueprint bp = Data.DefaultBlueprints.Where(x => x.BlueprintType == e.SearchComboBox.SelectedItem.ToString()).First(); CreatePanelComponents(e, bp); } }
public static void PlaceHolder(BlueprintSearchedArgs e) { }
public static void CreatePanelComponents(BlueprintSearchedArgs e, Blueprint _selectedBlueprint) { // Assigning the choosen blueprint to a variable to build off of Data.userBlueprint = _selectedBlueprint; // Need to clear the MainGrid of the old UI elements e.BlueprintCreationGrid.Children.RemoveRange(REMOVE_OUTDATED_UI_ELEMENTS_INDEX, e.BlueprintCreationGrid.Children.Count); int topMargin = 70; // Creating a foreach to loop through all resources required to craft an instance of this blueprint foreach (var resource in _selectedBlueprint.Resources) { //var meow = resource.ResourceType.Contains<char>('_') ? spaceCharacterAdder() : resource.ResourceType; // Creating a textbox that will show the resource type text e.BlueprintCreationGrid.Children.Add(new Label() { // If the resource's name contains a space, we need to replace it to a '_' <- contructor for Label is picky Content = resource.ResourceType.Contains <char>('_') ? spaceCharacterAdder() : resource.ResourceType, Width = 100, Height = 20, Margin = new Thickness(5, topMargin, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, BorderThickness = new Thickness(0), Padding = new Thickness(0), IsTabStop = false }); // If the name has a _ we need to replace it with a ' ' instead string spaceCharacterAdder() { string[] s = new string[2]; s = resource.ResourceType.Split('_'); return(s[0] + " " + s[1]); } // Creating a textbox for user input and adding it to the display panel e.BlueprintCreationGrid.Children.Add(new TextBox() { Name = resource.ResourceType, Width = 75, Height = 20, Margin = new Thickness(200, topMargin, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, BorderThickness = new Thickness(1), ToolTip = "Enter a whole number." }); topMargin += 25; } // Creating the "Create" button e.BlueprintCreationGrid.Children.Add(new Button() { Content = "Create", Width = 55, Height = 20, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(5, topMargin, 0, 0), Padding = new Thickness(0) }); // Wiring up event for when the user attempts to create a new instance of a blueprint ((Button)e.BlueprintCreationGrid.Children[e.BlueprintCreationGrid.Children.Count - 1]).Click += e.MainWindow.CreateBlueprintButton_Clicked; }
public static void OnTestBlueprintSelection(BlueprintSearchedArgs e) { TestBlueprintSelection(e); }