Names and helpers for visual states in the controls.
Ejemplo n.º 1
0
        internal void ApplyState(bool useTransitions)
        {
            // Common States
            if (this.IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            // Current States
            if (this.IsCurrent)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCurrent, VisualStates.StateRegular);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateRegular);
            }

            // Expanded States
            if (this.RowGroupInfo.CollectionViewGroup.ItemCount == 0)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateEmpty);
            }
            else
            {
                if (this.RowGroupInfo.Visibility == Visibility.Visible)
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded, VisualStates.StateEmpty);
                }
                else
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed, VisualStates.StateEmpty);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Update the current visual state of the button.
        /// </summary>
        /// <param name="useTransitions">
        ///     True to use transitions when updating the visual state, false to
        ///     snap directly to the new visual state.
        /// </param>
        internal virtual void UpdateVisualState(bool useTransitions)
        {
            if (IsLocked)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateLocked);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnlocked);
            }

            switch (ExpandDirection)
            {
            case ExpandDirection.Down:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandDown);
                break;

            case ExpandDirection.Up:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandUp);
                break;

            case ExpandDirection.Left:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandLeft);
                break;

            default:
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpandRight);
                break;
            }

            // let the header know a change has possibly occured.
            if (ExpanderButton != null)
            {
                ExpanderButton.UpdateVisualState(useTransitions);
            }

            // Handle the Common and Focused states
            _interaction.UpdateVisualStateBase(useTransitions);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     TransitionProperty property changed handler.
        /// </summary>
        /// <param name="d">TransitioningContentControl that changed its Transition.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnTransitionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var source        = (TransitioningContentControl)d;
            var oldTransition = e.NewValue as string;
            var newTransition = e.NewValue as string;

            if (source.IsTransitioning)
            {
                source.AbortTransition();
            }

            // find new transition
            Storyboard newStoryboard = source.GetStoryboard(newTransition);

            // unable to find the transition.
            if (newStoryboard == null)
            {
                // could be during initialization of xaml that presentationgroups was not yet defined
                if (VisualStates.TryGetVisualStateGroup(source, PresentationGroup) == null)
                {
                    // will delay check
                    source.CurrentTransition = null;
                }
                else
                {
                    // revert to old value
                    source.SetValue(TransitionProperty, oldTransition);

                    throw new ArgumentException(
                              string.Format(CultureInfo.CurrentCulture,
                                            Properties.Resources.TransitioningContentControl_TransitionNotFound, newTransition));
                }
            }
            else
            {
                source.CurrentTransition = newStoryboard;
            }
        }
Ejemplo n.º 4
0
        //-------------------------------------------------------------------
        //
        //  Protected Methods
        //
        //-------------------------------------------------------------------

        #region Protected Methods

        internal override void ChangeVisualState(bool useTransitions)
        {
            if (!IsEnabled)
            {
                VisualStateManager.GoToState(this, VisualStates.StateDisabled, useTransitions);
            }
            else if (IsMouseOver)
            {
                VisualStateManager.GoToState(this, VisualStates.StateMouseOver, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateNormal, useTransitions);
            }

            // Update the SelectionStates group
            if (IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnselected, useTransitions);
            }

            if (IsKeyboardFocused)
            {
                VisualStateManager.GoToState(this, VisualStates.StateFocused, useTransitions);
            }
            else
            {
                VisualStateManager.GoToState(this, VisualStates.StateUnfocused, useTransitions);
            }

            base.ChangeVisualState(useTransitions);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Updates the hover states of the rating items.
        /// </summary>
        private void UpdateHoverStates()
        {
            if (HoveredRatingItem != null && !IsReadOnly)
            {
                IList <RatingItem> ratingItems = GetRatingItems().ToList();
                int indexOfItem = ratingItems.IndexOf(HoveredRatingItem);

                double total  = ratingItems.Count();
                double filled = indexOfItem + 1;

                DisplayValue = filled / total;

                for (int cnt = 0; cnt < ratingItems.Count; cnt++)
                {
                    RatingItem ratingItem = ratingItems[cnt];
                    if (cnt <= indexOfItem && SelectionMode == RatingSelectionMode.Continuous)
                    {
                        VisualStates.GoToState(ratingItem, true, VisualStates.StateMouseOver);
                    }
                    else
                    {
                        IUpdateVisualState updateVisualState = ratingItem;
                        updateVisualState.UpdateVisualState(true);
                    }
                }
            }
            else
            {
                DisplayValue = Value.GetValueOrDefault();

                foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>())
                {
                    updateVisualState.UpdateVisualState(true);
                }
            }
        }
Ejemplo n.º 6
0
 // Token: 0x06005335 RID: 21301 RVA: 0x001723D4 File Offset: 0x001705D4
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Disabled",
             "Normal"
         });
     }
     else if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     if (base.IsKeyboardFocused)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Unfocused", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
Ejemplo n.º 7
0
        /// <summary>
        ///     DisplayValueProperty property changed handler.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="newValue">The new value.</param>
        private void OnDisplayValueChanged(double oldValue, double newValue)
        {
            if (!_settingDisplayValue)
            {
                _settingDisplayValue = true;

                DisplayValue = oldValue;

                throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture,
                                                                  Properties.Resources.InvalidAttemptToChangeReadOnlyProperty, "DisplayValue"));
            }
            if (newValue <= 0.0)
            {
                VisualStates.GoToState(this, true, StateEmpty);
            }
            else if (newValue >= 1.0)
            {
                VisualStates.GoToState(this, true, StateFilled);
            }
            else
            {
                VisualStates.GoToState(this, true, StatePartial);
            }
        }
Ejemplo n.º 8
0
Archivo: Slider.cs Proyecto: ynkbt/moon
        /// <summary>
        /// Change to the correct visual state for the Slider.
        /// </summary>
        /// <param name="useTransitions">
        /// true to use transitions when updating the visual state, false to
        /// snap directly to the new visual state.
        /// </param>
        internal void ChangeVisualState(bool useTransitions)
        {
            if (!IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if (IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            if (IsFocused && IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused);
            }
        }
 // Token: 0x060046EC RID: 18156 RVA: 0x00141BBC File Offset: 0x0013FDBC
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (this.DataGridOwner == null)
     {
         return;
     }
     if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Normal", useTransitions);
     }
     if (this.IsSelected)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Selected",
             "Unselected"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unselected"
         });
     }
     if (this.DataGridOwner.IsKeyboardFocusWithin)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Unfocused", useTransitions);
     }
     if (this.IsCurrent)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Current",
             "Regular"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Regular", useTransitions);
     }
     if (this.IsEditing)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Editing",
             "Display"
         });
     }
     else
     {
         VisualStateManager.GoToState(this, "Display", useTransitions);
     }
     base.ChangeVisualState(useTransitions);
 }
 // Token: 0x06005937 RID: 22839 RVA: 0x0018A714 File Offset: 0x00188914
 internal override void ChangeVisualState(bool useTransitions)
 {
     if (!base.IsEnabled)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Disabled",
             "Normal"
         });
     }
     else if (base.IsMouseOver)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "MouseOver",
             "Normal"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Normal"
         });
     }
     if (base.IsKeyboardFocused)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Focused",
             "Unfocused"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unfocused"
         });
     }
     if (this.IsExpanded)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Expanded"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Collapsed"
         });
     }
     if (base.HasItems)
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "HasItems"
         });
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "NoItems"
         });
     }
     if (this.IsSelected)
     {
         if (this.IsSelectionActive)
         {
             VisualStates.GoToState(this, useTransitions, new string[]
             {
                 "Selected"
             });
         }
         else
         {
             VisualStates.GoToState(this, useTransitions, new string[]
             {
                 "SelectedInactive",
                 "Selected"
             });
         }
     }
     else
     {
         VisualStates.GoToState(this, useTransitions, new string[]
         {
             "Unselected"
         });
     }
     base.ChangeVisualState(useTransitions);
 }
Ejemplo n.º 11
0
        internal override void ChangeVisualState(bool useTransitions)
        {
            // Handle the Common states
            if (!IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateDisabled, VisualStates.StateNormal);
            }
            else if (IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
            }

            // Handle the Focused states
            if (IsKeyboardFocused)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnfocused);
            }

            // Handle the Expansion states
            if (IsExpanded)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed);
            }

            // Handle the HasItems states
            if (HasItems)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateHasItems);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateNoItems);
            }

            // Handle the Selected states
            if (IsSelected)
            {
                if (IsSelectionActive)
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected);
                }
                else
                {
                    VisualStates.GoToState(this, useTransitions, VisualStates.StateSelectedInactive, VisualStates.StateSelected);
                }
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateUnselected);
            }

            base.ChangeVisualState(useTransitions);
        }
Ejemplo n.º 12
0
        internal void ApplyCellState(bool animate)
        {
            if (this.OwningGrid == null || this.OwningColumn == null || this.OwningRow == null || this.OwningRow.Visibility == Visibility.Collapsed || this.OwningRow.Slot == -1)
            {
                return;
            }

            // CommonStates
            if (this.IsMouseOver)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateMouseOver, VisualStates.StateNormal);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateNormal);
            }

            // SelectionStates
            if (this.OwningRow.IsSelected)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateSelected, VisualStates.StateUnselected);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateUnselected);
            }

            // FocusStates
            if (this.OwningGrid.ContainsFocus)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateFocused, VisualStates.StateUnfocused);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateUnfocused);
            }

            // CurrentStates
            if (this.IsCurrent)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateCurrent, VisualStates.StateRegular);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateRegular);
            }

            // Interaction states
            if (this.IsEdited)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateEditing, VisualStates.StateDisplay);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateDisplay);
            }

            // Validation states
            if (this.IsValid)
            {
                VisualStates.GoToState(this, animate, VisualStates.StateValid);
            }
            else
            {
                VisualStates.GoToState(this, animate, VisualStates.StateInvalid, VisualStates.StateValid);
            }
        }
Ejemplo n.º 13
0
        // Token: 0x06004B0D RID: 19213 RVA: 0x00152590 File Offset: 0x00150790
        internal override void ChangeVisualState(bool useTransitions)
        {
            if (!base.IsEnabled)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Disabled",
                    "Normal"
                });
            }
            else if (base.IsMouseOver)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "MouseOver",
                    "Normal"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Normal"
                });
            }
            if (base.IsKeyboardFocused)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Focused",
                    "Unfocused"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Unfocused"
                });
            }
            if (this.IsExpanded)
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Expanded"
                });
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "Collapsed"
                });
            }
            switch (this.ExpandDirection)
            {
            case ExpandDirection.Down:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandDown"
                });
                break;

            case ExpandDirection.Up:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandUp"
                });
                break;

            case ExpandDirection.Left:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandLeft"
                });
                break;

            default:
                VisualStates.GoToState(this, useTransitions, new string[]
                {
                    "ExpandRight"
                });
                break;
            }
            base.ChangeVisualState(useTransitions);
        }