From 265cd2eb8400863f857f08b4a078f6962fdcb8d6 Mon Sep 17 00:00:00 2001 From: Will Bennion Date: Mon, 18 May 2020 11:13:04 +0100 Subject: [PATCH 1/2] Fixed crash when trying to save evaluatables in the toolbox. --- .../Settings/Overrides/Logic/Control_EvaluatableToolbox.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Control_EvaluatableToolbox.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Control_EvaluatableToolbox.xaml.cs index 2c8dae225..2d1cc936e 100644 --- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Control_EvaluatableToolbox.xaml.cs +++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Control_EvaluatableToolbox.xaml.cs @@ -130,7 +130,7 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai /// 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(); } } From 9390db9c465ca19fb9e6f4a91a3c29d33066fee5 Mon Sep 17 00:00:00 2001 From: Will Bennion Date: Mon, 18 May 2020 11:18:59 +0100 Subject: [PATCH 2/2] Fixed enum control not showing loaded enum value. --- .../Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml | 1 + .../Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml index 3aa3674e5..a454682f5 100644 --- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml +++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml @@ -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"> diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs index 3885430b0..3539daada 100644 --- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs +++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs @@ -11,7 +11,6 @@ public partial class Control_BooleanGSIEnum : UserControl { public Control_BooleanGSIEnum(BooleanGSIEnum context) { InitializeComponent(); ((FrameworkElement)Content).DataContext = context; - UpdateEnumDropDown(); } /// Updates the enum value dropdown with a list of enum values for the current application and selected variable path. @@ -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();