private void triggerMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedItem = (AnimationTriggerMode)(sender as ComboBox).SelectedValue; if (CanSet) { Context.Properties._TriggerMode = selectedItem; } UpdateUI(); // If the evaluatable is not the correct type or it is null, then create the default Evaluatable for it if (AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(selectedItem) && !typeof(IEvaluatable <double>).IsAssignableFrom(Context.Properties._EvaluatableTrigger?.GetType())) { Context.Properties._EvaluatableTrigger = EvaluatableDefaults.Get <double>(); } else if (AnimationLayerHandler.IsTriggerEvaluatableBooleanValueBased(selectedItem) && !typeof(IEvaluatable <bool>).IsAssignableFrom(Context.Properties._EvaluatableTrigger?.GetType())) { Context.Properties._EvaluatableTrigger = EvaluatableDefaults.Get <bool>(); } // Update the evaluatable control triggerEvaluatable.EvalType = AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(selectedItem) ? typeof(double) : typeof(bool); triggerEvaluatable.Expression = Context.Properties._EvaluatableTrigger; }
private void triggerMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedItem = (AnimationTriggerMode)(sender as ComboBox).SelectedValue; if (CanSet) { Context.Properties._TriggerMode = selectedItem; } UpdateUI(); // If the evaluatable is not the correct type or it is null, then create the default Evaluatable for it if (AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(selectedItem) && !TypeUtils.IsInterface(Context.Properties._EvaluatableTrigger?.GetType(), typeof(IEvaluatable <double>))) { Context.Properties._EvaluatableTrigger = EvaluatableTypeResolver.GetDefault(EvaluatableType.Number); } else if (AnimationLayerHandler.IsTriggerEvaluatableBooleanValueBased(selectedItem) && !TypeUtils.IsInterface(Context.Properties._EvaluatableTrigger?.GetType(), typeof(IEvaluatable <bool>))) { Context.Properties._EvaluatableTrigger = EvaluatableTypeResolver.GetDefault(EvaluatableType.Boolean); } // Update the evaluatable control triggerEvaluatable.EvalType = AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(selectedItem) ? EvaluatableType.Number : EvaluatableType.Boolean; triggerEvaluatable.Expression = Context.Properties._EvaluatableTrigger; }
private void UpdateUI() { // Shortcut to the trigger mode var trigMode = Context.Properties.TriggerMode; // Only show trigger path when one of the path-like modes is set triggerGridLayout.RowDefinitions[1].Height = new GridLength(AnimationLayerHandler.IsTriggerNumericValueBased(trigMode) || AnimationLayerHandler.IsTriggerBooleanValueBased(trigMode) ? 28 : 0); // Only show IEvaluatable<object>when one of the evaluatable modes is set triggerGridLayout.RowDefinitions[2].Height = new GridLength(0, AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(trigMode) || AnimationLayerHandler.IsTriggerEvaluatableBooleanValueBased(trigMode) ? GridUnitType.Auto : GridUnitType.Pixel); // Only show tigger keys when one of the key-like modes is set triggerGridLayout.RowDefinitions[3].Height = new GridLength(AnimationLayerHandler.IsTriggerKeyBased(trigMode) ? 160 : 0); triggerGridLayout.RowDefinitions[4].Height = new GridLength(AnimationLayerHandler.IsTriggerKeyBased(trigMode) ? 28 : 0); // Only show the stack mode setting if the trigger mode is NOT "AlwaysOn" triggerGridLayout.RowDefinitions[5].Height = new GridLength(trigMode == AnimationTriggerMode.AlwaysOn ? 0 : 28); // Only show the force terminate setting if the trigger mode is key press or when key held (not released) triggerGridLayout.RowDefinitions[6].Height = new GridLength(trigMode == AnimationTriggerMode.OnKeyPress || trigMode == AnimationTriggerMode.WhileKeyHeld ? 28 : 0); // Use all available space when in an evaluatable mode (since these controls use a lot of space) triggerGroupbox.Width = AnimationLayerHandler.IsTriggerEvaluatableBooleanValueBased(trigMode) || AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(trigMode) ? double.NaN : 333; triggerGroupbox.HorizontalAlignment = AnimationLayerHandler.IsTriggerEvaluatableBooleanValueBased(trigMode) || AnimationLayerHandler.IsTriggerEvaluatableNumericValueBased(trigMode) ? HorizontalAlignment.Stretch : HorizontalAlignment.Left; // Update the combobox UpdatePathCombobox(); }