Nez.Portable/UI/Utils/Selection.cs
/// <summary>
/// Selects or deselects the specified item based on how the selection is configured, whether ctrl is currently pressed, etc.
/// This is typically invoked by user interaction.
/// </summary>
/// <param name="item">Item.</param>
Selects or deselects the specified item based on how the selection is configured, whether ctrl is currently pressed, etc.
This is typically invoked by user interaction.
Selects or deselects the specified item based on how the selection is configured whether ctrl is currently pressed etc . This is typically invoked by user interaction .
public virtual void choose(T item)
        {
            Assert.isNotNull(item, "item cannot be null");
            if (_isDisabled)
                return;
            snapshot();
            try
            {
                if ((toggle || (!required && selected.Count == 1) || InputUtils.isControlDown())
                    && selected.Contains(item))
                {
                    if (required && selected.Count == 1)
                        return;
                    selected.Remove(item);
                    lastSelected = null;
                }
                else
                {
                    bool modified = false;
                    if (!multiple || (!toggle && !InputUtils.isControlDown()))
                    {
                        if (selected.Count == 1 && selected.Contains(item))
                            return;
                        modified = selected.Count > 0;
                        selected.Clear();
                    }
                    if (!selected.addIfNotPresent(item) && !modified)
                        return;
                    lastSelected = item;
                }
                if (fireChangeEvent())
                    revert();
                else
                    changed();
            }
            finally
            {
                cleanup();
            }
        }
public virtual void choose ( T item ) { Assert . isNotNull ( item , " " ) ; if ( _isDisabled ) return ; snapshot ( ) ; try { if ( ( toggle || ( ! required && selected . Count == 1 ) || InputUtils . isControlDown ( ) ) && selected . Contains ( item ) ) { if ( required && selected . Count == 1 ) return ; selected . Remove ( item ) ; lastSelected = null ; } else { bool modified = false ; if ( ! multiple || ( ! toggle && ! InputUtils . isControlDown ( ) ) ) { if ( selected . Count == 1 && selected . Contains ( item ) ) return ; modified = selected . Count > 0 ; selected . Clear ( ) ; } if ( ! selected . addIfNotPresent ( item ) && ! modified ) return ; lastSelected = item ; } if ( fireChangeEvent ( ) ) revert ( ) ; else changed ( ) ; } finally { cleanup ( ) ; } }
Selects or deselects the specified item based on how the selection is configured, whether ctrl is currently pressed, etc.
Selects or deselects the specified item based on how the selection is configured whether ctrl is currently pressed etc .
item
T
None