예제 #1
0
        public virtual Color? GetItemBackgroundColor(AdaptiveSelector selector, object selectorIdentifier, object item, bool isSelected)
        {
            var group = GetItemGroup(selector, selectorIdentifier, item);

            if (group != null)
                return group.Color;

            return null;
        }
        public override Color? GetItemBackgroundColor(AdaptiveSelector selector, object selectorIdentifier, object item, bool isSelected)
        {
            if (object.Equals(ModeOneItem, item))
                return ModeOneColor;

            if (object.Equals(ModeTwoItem, item))
                return ModeTwoColor;

            return base.GetItemBackgroundColor(selector, selectorIdentifier, item, isSelected);
        }
        public override void OnItemUnselected(AdaptiveSelector selector, object selectorIdentifier, object unselectedItem)
        {
            if(object.Equals(ModeOneItem, unselectedItem))
            {
                ModeOneItem = null;
            }
            else if(object.Equals(ModeTwoItem, unselectedItem))
            {
                ModeTwoItem = null;
            }

            base.OnItemUnselected(selector, selectorIdentifier, unselectedItem);
        }
        public override IReadOnlyList<IUserAction> GetAvailableUserAction(AdaptiveSelector selector, object selectorIdentifier, object item)
        {
            var result = new List<IUserAction>();

            var ua = new UserAction("set Mode One", (x) =>
            {
                selector.UnselectItem(ModeOneItem);

                ModeOneItem = item;

                selector.EnsureItemSelected(item);
            });

            if(!object.Equals(item, ModeOneItem))
                result.Add(ua);

            ua = new UserAction("set Mode Two", (x) =>
            {
                selector.UnselectItem(ModeTwoItem);

                ModeTwoItem = item;

                selector.EnsureItemSelected(item);
            });

            if (!object.Equals(item, ModeTwoItem))
                result.Add(ua);

            ua = new UserAction("swap", (x) =>
            {
                var one = ModeOneItem;
                var two = ModeTwoItem;

                selector.UnselectItem(one);
                selector.UnselectItem(two);

                ModeOneItem = two;
                ModeTwoItem = one;

                selector.EnsureItemSelected(ModeOneItem);
                selector.EnsureItemSelected(ModeTwoItem);
            });

            if(ModeOneItem != null && ModeTwoItem != null)
                result.Add(ua);

            return result;
        }
        // this behavior allows up to two selected items to have custom mode (Mode 1 and Mode 2).
        // different modes will be distinguished by colour (Red and Blue)
        // First selected item wil lalways be mode 1, second will always be mode 2 (if mode from first item have not been removed)

        public override void OnItemSelected(AdaptiveSelector selector, object selectorIdentifier, object selectedItem)
        {
            base.OnItemSelected(selector, selectorIdentifier, selectedItem);

            if (object.Equals(ModeOneItem, selectedItem) || object.Equals(ModeTwoItem, selectedItem))
                return;

            if (ModeOneItem == null)
            {
                ModeOneItem = selectedItem;
            }
            else if(ModeTwoItem == null)
            {
                ModeTwoItem = selectedItem;
            }
        }
예제 #6
0
        public virtual Visibility GetSelectionMarkersVisibility(AdaptiveSelector selector, object selectorIdentifier, int allItemsCount, int selectedItemsCount)
        {            
            // 0 or 1 item, don't show markers
            if (allItemsCount < 2)
            {
                return Visibility.Collapsed;
            }

            // not all items selected, show markers
            if (selectedItemsCount < allItemsCount)
            {
                return Visibility.Visible;
            }
            else // all items selected, don't show markers
            {
                return Visibility.Collapsed;
            }
        }
예제 #7
0
 public virtual void OnItemUnselected(AdaptiveSelector selector, object selectorIdentifier, object unselectedItem)
 { }
예제 #8
0
 public virtual IAdaptiveSelectorItemGroup GetItemGroup(AdaptiveSelector selector, object selectorIdentifier, object item)
 {
     return null;
 }
예제 #9
0
 public virtual IReadOnlyList<IUserAction> GetAvailableUserAction(AdaptiveSelector selector, object selectorIdentifier, object item)
 {
     return new IUserAction[0];
 }