Example #1
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);
        }
Example #2
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, $"Invalid attempt to change read-only property 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);
            }
        }
Example #3
0
        /// <summary>
        ///     Updates the state of the visual.
        /// </summary>
        /// <param name="useTransitions">If set to <c>true</c> use transitions.</param>
        /// <remarks>The header will follow the parent accordionitem states.</remarks>
        internal virtual void UpdateVisualState(bool useTransitions)
        {
            // the visualstate of the header is completely dependent on the parent state.
            if (ParentAccordionItem == null)
            {
                return;
            }

            if (ParentAccordionItem.IsSelected)
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded);
            }
            else
            {
                VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed);
            }

            switch (ParentAccordionItem.ExpandDirection)
            {
            // no animations on an expanddirection change.
            case ExpandDirection.Down:
                VisualStates.GoToState(this, false, VisualStates.StateExpandDown);
                break;

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

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

            default:
                VisualStates.GoToState(this, false, VisualStates.StateExpandRight);
                break;
            }
        }
Example #4
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);
                }
            }
        }