Exemplo n.º 1
0
        internal void UpdateSelectedIndex(LoopingListSelectionChangeReason reason)
        {
            int index = this.GetIndexFromCurrentValueForComponentType(this.componentType);

            //Ensure that list is with valid count when swithcing between months with diferent number of days.
            if (this.IsTemplateApplied && this.itemsPanel.VisualCount > 0)
            {
                this.UpdateLogicalCount(false);
                this.UpdateListWithStep();
            }

            this.UpdateSelection(index, this.GetVisualIndex(index), reason);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Applies the specified index as currently selected.
        /// </summary>
        /// <param name="newSelectedIndex">The desired selected index.</param>
        /// <param name="reason">The reason of the change.</param>
        internal virtual void UpdateSelection(int newSelectedIndex, LoopingListSelectionChangeReason reason)
        {
            if (this.selectedIndex == newSelectedIndex)
            {
                return;
            }

            if (!this.CanChangeSelectedIndex(newSelectedIndex))
            {
                this.selectionChangeReason = LoopingListSelectionChangeReason.PrivateNoNotify;
                this.SetValue(SelectedIndexProperty, this.selectedIndex);
            }
            else
            {
                if (reason == LoopingListSelectionChangeReason.User)
                {
                    this.selectionChangeReason = LoopingListSelectionChangeReason.Private;
                }
                else
                {
                    this.selectionChangeReason = reason;
                }

                int oldIndex = this.selectedIndex;

                // do the actual selection change
                this.selectedIndex = newSelectedIndex;
                this.SetValue(SelectedIndexProperty, newSelectedIndex);

                // examine the selection change reason
                switch (reason)
                {
                case LoopingListSelectionChangeReason.User:
                case LoopingListSelectionChangeReason.Private:
                case LoopingListSelectionChangeReason.PrivateNoNotify:
                    this.SelectCurrentItem();
                    break;
                }

                this.UpdateItemsIsSelectedState();
            }

            if (reason != LoopingListSelectionChangeReason.PrivateNoNotify)
            {
                this.RaiseSelectedIndexChanged();
            }

            this.selectionChangeReason = LoopingListSelectionChangeReason.User;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Selects the specified visual item.
        /// </summary>
        /// <param name="item">The item to be selected.</param>
        /// <param name="reason">The reason that caused the select request.</param>
        internal virtual bool SelectItem(LoopingListItem item, LoopingListSelectionChangeReason reason)
        {
            if (!this.CanChangeSelectedIndex(item.LogicalIndex))
            {
                return(false);
            }

            if (!item.IsSelected)
            {
                // update the selected index
                this.UpdateSelection(item.LogicalIndex, item.VisualIndex, reason);
            }
            else
            {
                this.UpdateItemsIsSelectedState();
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        internal override void UpdateSelection(int newSelectedLogicalIndex, int newSelectedVisualIndex, LoopingListSelectionChangeReason reason)
        {
            if (reason == LoopingListSelectionChangeReason.PrivateNoNotify)
            {
                if (!this.CanChangeSelectedIndex(newSelectedLogicalIndex))
                {
                    newSelectedLogicalIndex++;
                }
            }

            if (reason == LoopingListSelectionChangeReason.VisualItemClick ||
                reason == LoopingListSelectionChangeReason.VisualItemSnappedToMiddle ||
                reason == LoopingListSelectionChangeReason.Private ||
                reason == LoopingListSelectionChangeReason.PrivateNoNotify)
            {
                this.UpdateValue(newSelectedLogicalIndex);
            }

            base.UpdateSelection(newSelectedLogicalIndex, newSelectedVisualIndex, reason);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Applies the specified index as currently selected.
        /// </summary>
        /// <param name="newSelectedLogicalIndex">The desired selected logical index.</param>
        /// <param name="newSelectedVisualIndex">The desired selected visual index.</param>
        /// <param name="reason">The reason of the change.</param>
        internal virtual void UpdateSelection(int newSelectedLogicalIndex, int newSelectedVisualIndex, LoopingListSelectionChangeReason reason)
        {
            if (this.selectedVisualIndex == newSelectedVisualIndex && this.selectedIndex == newSelectedLogicalIndex)
            {
                return;
            }

            if (!this.CanChangeSelectedIndex(newSelectedLogicalIndex))
            {
                this.selectionChangeReason = LoopingListSelectionChangeReason.PrivateNoNotify;
                this.SetValue(SelectedIndexProperty, this.selectedIndex);
            }
            else
            {
                if (reason == LoopingListSelectionChangeReason.User)
                {
                    this.selectionChangeReason = LoopingListSelectionChangeReason.Private;
                }
                else
                {
                    this.selectionChangeReason = reason;
                }

                // do the actual selection change
                this.selectedIndex       = newSelectedLogicalIndex;
                this.selectedVisualIndex = newSelectedVisualIndex;
                this.SetValue(SelectedIndexProperty, newSelectedLogicalIndex);

                // examine the selection change reason
                switch (reason)
                {
                case LoopingListSelectionChangeReason.User:
                case LoopingListSelectionChangeReason.Private:
                case LoopingListSelectionChangeReason.PrivateNoNotify:
                    this.SelectCurrentItem();
                    break;
                }

                this.UpdateItemsIsSelectedState();

                if (this.ItemsPanel != null)
                {
                    var loopingListItem = this.ItemsPanel.ItemFromLogicalIndex(this.selectedIndex) as LoopingListItem;
                    if (loopingListItem != null)
                    {
                        loopingListItem.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection,
                                                             AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection,
                                                             AutomationEvents.SelectionItemPatternOnElementSelected,
                                                             AutomationEvents.SelectionPatternOnInvalidated,
                                                             AutomationEvents.AutomationFocusChanged);
                    }
                }
            }

            if (reason != LoopingListSelectionChangeReason.PrivateNoNotify)
            {
                this.RaiseSelectedIndexChanged();
            }

            this.selectionChangeReason = LoopingListSelectionChangeReason.User;
        }