public void RemoveStateCategory(StateSaveCategory category, IStateCategoryListContainer stateCategoryListContainer) { // This category can only be removed if no behaviors require it var behaviorsNeedingCategory = GetBehaviorsNeedingCategory(category, stateCategoryListContainer as ComponentSave); if (behaviorsNeedingCategory.Any()) { string message = "This category cannot be removed because it is needed by the following behavior(s):"; foreach (var behavior in behaviorsNeedingCategory) { message += "\n" + behavior.Name; } MessageBox.Show(message); } else { var response = MessageBox.Show($"Are you sure you want to delete the category {category.Name}?", "Delete category?", MessageBoxButtons.YesNo); if (response == DialogResult.Yes) { Remove(category); } } }
public StateSaveCategory AddCategory(IStateCategoryListContainer objectToAddTo, string name) { if (objectToAddTo == null) { throw new Exception("Could not add category " + name + " because no element or behavior is selected"); } StateSaveCategory category = new StateSaveCategory(); category.Name = name; objectToAddTo.Categories.Add(category); // September 20, 2018 // Not sure why we have // this category add itself // as a variable to the default // state. States can't set other // states, and I don't think the rest // of Gum depends on this. Commenting it // out to see. // Update - even though the element can't set // it's own categorized state in the default state, // instances use this variable to determine if a variable // should be shown. if (objectToAddTo is ElementSave) { string categoryName = category.Name + "State"; var elementToAddTo = objectToAddTo as ElementSave; elementToAddTo.DefaultState.Variables.Add(new VariableSave() { Name = categoryName, Type = categoryName, Value = null #if GUM , CustomTypeConverter = new Gum.PropertyGridHelpers.Converters.AvailableStatesConverter(category.Name) #endif }); elementToAddTo.DefaultState.Variables.Sort((first, second) => first.Name.CompareTo(second.Name)); } return(category); }
public void RemoveStateCategory(StateSaveCategory category, IStateCategoryListContainer stateCategoryListContainer) { DeleteLogic.Self.RemoveStateCategory(category, stateCategoryListContainer); }