Ejemplo n.º 1
0
        public InteractionHelper(Control control)
        {
            Debug.Assert(control != null, "control should not be null!");
            Control            = control;
            _updateVisualState = control as IUpdateVisualState;

            control.Loaded           += OnLoaded;
            control.IsEnabledChanged += OnIsEnabledChanged;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the InteractionHelper class.
        /// </summary>
        /// <param name="control">Control receiving interaction.</param>
        public InteractionHelper(Control control)
        {
            Debug.Assert(control != null, "control should not be null!");
            Control            = control;
            _updateVisualState = control as IUpdateVisualState;

            // Wire up the event handlers for events without a virtual override
            control.Loaded           += OnLoaded;
            control.IsEnabledChanged += OnIsEnabledChanged;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the InteractionHelper class.
        /// </summary>
        /// <param name="control">Control receiving interaction.</param>
        public InteractionHelper(Control control)
        {
            Debug.Assert(control != null, "control should not be null!");
            Control = control;
            _updateVisualState = control as IUpdateVisualState;

            // Wire up the event handlers for events without a virtual override
            control.Loaded += OnLoaded;
            control.IsEnabledChanged += OnIsEnabledChanged;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the hover states of the rating items.
        /// </summary>
        private void UpdateHoverStates()
        {
            if (HoveredRatingItem != null && IsEnabled)
            {
                IList <RatingItem> ratingItems = GetRatingItems().ToList();
                int indexOfItem = ratingItems.IndexOf(HoveredRatingItem);

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

                this.DisplayValue = filled / total;

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

                foreach (IUpdateVisualState updateVisualState in GetRatingItems().OfType <IUpdateVisualState>())
                {
                    updateVisualState.UpdateVisualState(true);
                }
            }
        }
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);
                }
            }
        }