Пример #1
0
        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 UpdatePathCombobox()
        {
            bool isTriggerBoolean = AnimationLayerHandler.IsTriggerBooleanValueBased(Context.Properties.TriggerMode);

            // If the trigger items are currently all booleans, and the trigger is now boolean, don't re-populate the list (it will clear the user's selection).
            // Same goes for if it already contains numeric items and we are now in a numeric mode.
            if (triggerPathItemsAreBoolean.HasValue && triggerPathItemsAreBoolean == isTriggerBoolean)
            {
                return;
            }
            triggerPathItemsAreBoolean = isTriggerBoolean;

            // Get a list of the parameters. If trigger is boolean mode, filters to only boolean values, else does numeric values
            var parameters = profile.ParameterLookup?.Where(kvp => isTriggerBoolean
                ? kvp.Value.Item1 == typeof(bool)
                : TypeUtils.IsNumericType(kvp.Value.Item1)
                                                            );

            // Add the items to the trigger path combobox
            triggerPath.Items.Clear();
            foreach (var item in parameters)
            {
                triggerPath.Items.Add(item.Key);
            }
        }
        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;
        }
Пример #4
0
        public Control_AnimationLayer(AnimationLayerHandler datacontext)
        {
            InitializeComponent();
            DataContext = datacontext;

            // Populate comboboxs
            var triggerModeLCV = new ListCollectionView(Enum.GetValues(typeof(AnimationTriggerMode))
                                                        .Cast <AnimationTriggerMode>()
                                                        .Select(mode => new { Key = mode.GetDescription(), Value = mode, Description = mode.GetCategory() })
                                                        .ToList()
                                                        );

            triggerModeLCV.GroupDescriptions.Add(new PropertyGroupDescription("Description"));
            triggerModeCb.ItemsSource = triggerModeLCV;
            stackModeCb.ItemsSource   = EnumUtils.GetEnumItemsSource <AnimationStackMode>();

            UpdateUI();
        }
Пример #5
0
        private void UpdatePathCombobox()
        {
            bool isTriggerBoolean = AnimationLayerHandler.IsTriggerBooleanValueBased(Context.Properties.TriggerMode);

            // If the trigger items are currently all booleans, and the trigger is now boolean, don't re-populate the list (it will clear the user's selection).
            // Same goes for if it already contains numeric items and we are now in a numeric mode.
            //if (triggerPathItemsAreBoolean.HasValue && triggerPathItemsAreBoolean == isTriggerBoolean)
            //    return;
            triggerPathItemsAreBoolean = isTriggerBoolean;

            // Get a list of the parameters. If trigger is boolean mode, filters to only boolean values, else does numeric values

            /*triggerPath.ItemsSource = profile?.ParameterLookup?
             *  .Where(kvp => isTriggerBoolean
             *      ? kvp.Value.Item1 == typeof(bool)
             *      : TypeUtils.IsNumericType(kvp.Value.Item1)
             *  )
             *  .Select(kvp => kvp.Key)
             *  .ToList();*/
        }
        private void triggerMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            AnimationTriggerMode selectedItem = ((KeyValuePair <string, AnimationTriggerMode>)(sender as ComboBox).SelectedItem).Value;

            if (CanSet)
            {
                Context.Properties._TriggerMode = selectedItem;
            }

            // Only show trigger path when one of the path-like modes is set
            triggerGridLayout.RowDefinitions[1].Height = new GridLength(AnimationLayerHandler.IsTriggerNumericValueBased(selectedItem) || AnimationLayerHandler.IsTriggerBooleanValueBased(selectedItem) ? 28 : 0);
            // Only show tigger keys when one of the key-like modes is set
            triggerGridLayout.RowDefinitions[2].Height = new GridLength(AnimationLayerHandler.IsTriggerKeyBased(selectedItem) ? 160 : 0);
            triggerGridLayout.RowDefinitions[3].Height = new GridLength(AnimationLayerHandler.IsTriggerKeyBased(selectedItem) ? 28 : 0);
            // Only show the stack mode setting if the trigger mode is NOT "AlwaysOn"
            triggerGridLayout.RowDefinitions[4].Height = new GridLength(selectedItem == 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[5].Height = new GridLength(selectedItem == AnimationTriggerMode.OnKeyPress || selectedItem == AnimationTriggerMode.WhileKeyHeld ? 28 : 0);

            // Update the combobox
            UpdatePathCombobox();
        }
Пример #7
0
        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();
        }
 public Control_AnimationLayer(AnimationLayerHandler datacontext) : this()
 {
     this.DataContext = datacontext;
 }
Пример #9
0
        public Control_AnimationLayer(AnimationLayerHandler datacontext)
        {
            InitializeComponent();

            this.DataContext = datacontext;
        }