private void PopulateComboBox() { int selectedIndex = this.GuidesComboBox.SelectedIndex; this.GuidesComboBox.Items.Clear(); // This could be null if the property is set in the designer. if (mGumProjectSave != null) { List <string> availableGuides = AvailableGuidesTypeConverter.GetAvailableValues( mGumProjectSave, true, true); foreach (string value in availableGuides) { this.GuidesComboBox.Items.Add(value); } if (selectedIndex != -1 && selectedIndex < GuidesComboBox.Items.Count) { this.GuidesComboBox.SelectedIndex = selectedIndex; } // If it's -1, that means that this may be the first // time that this UI was shown. // If there are more than 2 items (None and New Guide) // then we should select the first one if (selectedIndex == -1 && GuidesComboBox.Items.Count > 2) { this.GuidesComboBox.SelectedIndex = 0; } } }
public static TypeConverter GetTypeConverter(this VariableSave variableSave, ElementSave container = null) { ElementSave categoryContainer; StateSaveCategory category; if (variableSave.CustomTypeConverter != null) { return(variableSave.CustomTypeConverter); } else if (variableSave.IsFont) { return(new FontTypeConverter()); } else if (variableSave.Name == "Guide") { AvailableGuidesTypeConverter availableGuidesTypeConverter = new AvailableGuidesTypeConverter(); availableGuidesTypeConverter.GumProjectSave = ObjectFinder.Self.GumProjectSave; availableGuidesTypeConverter.ShowNewGuide = false; return(availableGuidesTypeConverter); } else if (variableSave.IsState(container, out categoryContainer, out category)) { string categoryName = null; if (category != null) { categoryName = category.Name; } AvailableStatesConverter converter = new AvailableStatesConverter(categoryName); converter.ElementSave = categoryContainer; return(converter); } else { // We should see if it's an exposed variable, and if so, let's look to the source object's type converters bool foundInRoot = false; if (!string.IsNullOrEmpty(variableSave.SourceObject) && container != null) { InstanceSave instance = container.GetInstance(variableSave.SourceObject); if (instance != null) { // see if the instance has a variable var foundElementSave = ObjectFinder.Self.GetRootStandardElementSave(instance); if (foundElementSave != null) { VariableSave rootVariableSave = foundElementSave.DefaultState.GetVariableSave(variableSave.GetRootName()); if (rootVariableSave != null) { return(rootVariableSave.GetTypeConverter((ElementSave)null)); } } } } } Type type = variableSave.GetRuntimeType(); return(variableSave.GetTypeConverter(type)); }
public static TypeConverter GetTypeConverter(this VariableSave variableSave, ElementSave container = null) { ElementSave categoryContainer; StateSaveCategory category; if (variableSave.CustomTypeConverter != null) { return variableSave.CustomTypeConverter; } else if (variableSave.IsFont) { return new FontTypeConverter(); } else if (variableSave.Name == "Guide") { AvailableGuidesTypeConverter availableGuidesTypeConverter = new AvailableGuidesTypeConverter(); availableGuidesTypeConverter.GumProjectSave = ObjectFinder.Self.GumProjectSave; availableGuidesTypeConverter.ShowNewGuide = false; return availableGuidesTypeConverter; } else if(variableSave.IsState(container, out categoryContainer, out category )) { string categoryName = null; if(category != null) { categoryName = category.Name; } AvailableStatesConverter converter = new AvailableStatesConverter(categoryName); converter.ElementSave = categoryContainer; return converter; } else { // We should see if it's an exposed variable, and if so, let's look to the source object's type converters bool foundInRoot = false; if (!string.IsNullOrEmpty(variableSave.SourceObject) && container != null) { InstanceSave instance = container.GetInstance(variableSave.SourceObject); if (instance != null) { // see if the instance has a variable var foundElementSave = ObjectFinder.Self.GetRootStandardElementSave(instance); if (foundElementSave != null) { VariableSave rootVariableSave = foundElementSave.DefaultState.GetVariableSave(variableSave.GetRootName()); if (rootVariableSave != null) { return rootVariableSave.GetTypeConverter((ElementSave)null); } } } } } Type type = variableSave.GetRuntimeType(); return variableSave.GetTypeConverter(type); }