private void MoveHighlight(IEasingFunctionDefinition targetFunction, int buttonNumber)
        {
            if (targetFunction == null)
            {
                return;
            }
            ComboBoxItem comboBoxItem = (ComboBoxItem)this.ItemContainerGenerator.ContainerFromItem((object)targetFunction);

            if (comboBoxItem == null)
            {
                return;
            }
            ContentPresenter contentPresenter = Enumerable.FirstOrDefault <ContentPresenter>(Enumerable.OfType <ContentPresenter>(ElementUtilities.GetVisualTree((Visual)comboBoxItem)));
            DataTemplate     contentTemplate  = contentPresenter.ContentTemplate;

            if (buttonNumber < 0 || buttonNumber >= this.buttonOrder.Count)
            {
                return;
            }
            EasingFunctionSelectionButton functionSelectionButton = contentTemplate.FindName(this.buttonOrder[buttonNumber].ToString() + "Button", (FrameworkElement)contentPresenter) as EasingFunctionSelectionButton;

            if (functionSelectionButton == null)
            {
                return;
            }
            this.LastHighlightedButton = functionSelectionButton;
        }
Esempio n. 2
0
        private static void OnSelectedEasingFunctionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EasingFunctionSelectionButton functionSelectionButton = d as EasingFunctionSelectionButton;
            IEasingFunctionDefinition     selectedEasingFunction  = functionSelectionButton.SelectedEasingFunction;
            IEasingFunctionDefinition     ownEasingFunction       = functionSelectionButton.OwnEasingFunction;
            bool flag = functionSelectionButton.CanBeEnabled && (selectedEasingFunction == null || ownEasingFunction == null ? selectedEasingFunction == null && ownEasingFunction == null : ownEasingFunction.PlatformSpecificObject.GetType() == selectedEasingFunction.PlatformSpecificObject.GetType() && functionSelectionButton.Easing == selectedEasingFunction.EasingMode);

            functionSelectionButton.MatchesSelection = flag;
        }
        private void HandleMouseOverChanged(object sender, RoutedEventArgs args)
        {
            EasingFunctionSelectionButton functionSelectionButton = args.OriginalSource as EasingFunctionSelectionButton;

            if (functionSelectionButton != null)
            {
                if (functionSelectionButton.IsMouseOver)
                {
                    this.LastHighlightedButton = functionSelectionButton;
                }
                functionSelectionButton.IsHighlighted = functionSelectionButton.IsMouseOver;
            }
            args.Handled = true;
        }
Esempio n. 4
0
        private void OnEasingFunctionSelected(object sender, RoutedEventArgs args)
        {
            this.EasingFunctionSelectionComboBox.IsDropDownOpen = false;
            EasingFunctionSelectionButton functionSelectionButton = sender as EasingFunctionSelectionButton;

            if (functionSelectionButton == null || this.easingFunctionProperty == null)
            {
                return;
            }
            IEasingFunctionDefinition ownEasingFunction = functionSelectionButton.OwnEasingFunction;
            SceneViewModel            viewModel         = this.easingFunctionProperty.SceneNodeObjectSet.ViewModel;

            if (viewModel == null)
            {
                return;
            }
            foreach (SceneNode sceneNode in this.easingFunctionProperty.SceneNodeObjectSet.Objects)
            {
                if (!sceneNode.IsAttached)
                {
                    return;
                }
            }
            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.ChangeEasingFunctionUndoUnit, false))
            {
                if (ownEasingFunction != null)
                {
                    ownEasingFunction.EasingMode = functionSelectionButton.Easing;
                    this.easingFunctionProperty.PropertyValue.Value = ownEasingFunction.PlatformSpecificObject;
                }
                else
                {
                    this.easingFunctionProperty.PropertyValue.ClearValue();
                }
                editTransaction.Commit();
            }
        }
 private void KeyDownEventHandler(object sender, KeyEventArgs args)
 {
     if (!this.IsDropDownOpen)
     {
         return;
     }
     if (args.Key == Key.Left || args.Key == Key.Right || (args.Key == Key.Down || args.Key == Key.Up))
     {
         if (this.lastHighlightedButton == null)
         {
             IEasingFunctionDefinition functionDefinition = this.Tag as IEasingFunctionDefinition;
             if (functionDefinition == null)
             {
                 this.LastHighlightedButton = this.nullButton;
             }
             else
             {
                 foreach (object obj in (IEnumerable)this.Items)
                 {
                     IEasingFunctionDefinition targetFunction = obj as IEasingFunctionDefinition;
                     if (targetFunction != null && targetFunction.PlatformSpecificObject.GetType() == functionDefinition.PlatformSpecificObject.GetType())
                     {
                         this.MoveHighlight(targetFunction, this.buttonOrder.IndexOf((object)functionDefinition.EasingMode));
                         break;
                     }
                 }
             }
         }
         if (this.LastHighlightedButton == this.nullButton)
         {
             if (args.Key != Key.Down)
             {
                 return;
             }
             this.MoveHighlight(this.Items[0] as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)EasingMode.In));
         }
         else if (args.Key == Key.Left || args.Key == Key.Right)
         {
             this.MoveHighlight(this.LastHighlightedButton.DataContext as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)this.LastHighlightedButton.Easing) + (args.Key == Key.Left ? -1 : 1));
         }
         else
         {
             int index = this.Items.IndexOf(this.LastHighlightedButton.DataContext) + (args.Key == Key.Down ? 1 : -1);
             if (index < 0)
             {
                 this.LastHighlightedButton = this.nullButton;
             }
             else
             {
                 if (index == this.Items.Count)
                 {
                     index = this.Items.Count - 1;
                 }
                 this.MoveHighlight(this.Items[index] as IEasingFunctionDefinition, this.buttonOrder.IndexOf((object)this.LastHighlightedButton.Easing));
             }
         }
     }
     else
     {
         if (args.Key != Key.Return && args.Key != Key.Space)
         {
             return;
         }
         if (this.LastHighlightedButton == null)
         {
             this.nullButton.FireButtonPressed();
         }
         else
         {
             this.LastHighlightedButton.FireButtonPressed();
         }
     }
 }
 private void HandlePopupClosed(object sender, RoutedEventArgs args)
 {
     this.LastHighlightedButton = (EasingFunctionSelectionButton)null;
 }
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.nullButton = this.Template.FindName("PopUpDisplayNullEasingFunctionButton", (FrameworkElement)this) as EasingFunctionSelectionButton;
 }