Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overrides toolbox & enum control #2020

Merged
merged 3 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c="clr-namespace:Aurora.Controls"
xmlns:u="clr-namespace:Aurora.Utils"
Loaded="UserControl_Loaded"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal">
<c:GameStateParameterPicker SelectedPath="{Binding StatePath}" PropertyType="Enum" Application="{u:AttachedApplicationBinding}" VerticalAlignment="Center" SelectedPathChanged="GameStateParameterPicker_SelectedPathChanged" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public partial class Control_BooleanGSIEnum : UserControl {
public Control_BooleanGSIEnum(BooleanGSIEnum context) {
InitializeComponent();
((FrameworkElement)Content).DataContext = context;
UpdateEnumDropDown();
}

/// <summary>Updates the enum value dropdown with a list of enum values for the current application and selected variable path.</summary>
Expand All @@ -28,6 +27,12 @@ private void UpdateEnumDropDown() {
EnumVal.ItemsSource = isValid ? Utils.EnumUtils.GetEnumItemsSource(selectedEnumType) : null;
}

// We don't do UpdateEnumDropDown in the constructor because it won't have been added to the visual tree at the point and therefore
// the attached application property won't be set. If we wait til the control has added to the tree, the property is set.
private void UserControl_Loaded(object sender, RoutedEventArgs e) {
UpdateEnumDropDown();
}

// Update the enum dropdown when the user selects a different enum path
private void GameStateParameterPicker_SelectedPathChanged(object sender, Controls.SelectedPathChangedEventArgs e) {
UpdateEnumDropDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai
/// </summary>
public class TemplateEvaluatableTypeSelector : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value.GetType().GetGenericInterfaceTypes(typeof(Evaluatable<>))[0];
value.GetType().GetGenericParentTypes(typeof(Evaluatable<>))[0];
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}
}