Beispiel #1
0
 private void SelectRangeFromAnchor(SelectionModel manager, IndexPath index, bool select)
 {
     Log.Comment("SelectRangeFromAnchor " + index + " select: " + select.ToString());
     if (select)
     {
         manager.SelectRangeFromAnchorTo(index);
     }
     else
     {
         manager.DeselectRangeFromAnchorTo(index);
     }
 }
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            if (!e.Handled)
            {
                var indexPath = GetIndexPath();
                Debug.WriteLine("OnPointerPressed:" + indexPath.ToString());

                if (SelectionModel != null)
                {
                    if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift) && !SelectionModel.SingleSelect)
                    {
                        if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control))
                        {
                            SelectionModel.DeselectRangeFromAnchorTo(GetIndexPath());
                        }
                        else
                        {
                            SelectionModel.SelectRangeFromAnchorTo(GetIndexPath());
                        }
                    }
                    else if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control))
                    {
                        var path = GetIndexPath();
                        if (SelectionModel.IsSelectedAt(path).Value)
                        {
                            SelectionModel.SelectAt(path);
                        }
                        else
                        {
                            SelectionModel.SelectAt(path);
                        }
                    }
                    else
                    {
                        SelectionModel.SelectAt(GetIndexPath());
                        this.Focus(FocusState.Keyboard);
                    }
                }

                e.Handled = true;
                base.OnPointerPressed(e);
            }
        }