private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "SelectedIndices")
            {
                bool?oldValue  = IsSelected;
                var  indexPath = GetIndexPath();
                bool?newValue  = IsRealized(indexPath) ? SelectionModel.IsSelectedAt(indexPath) : false;

                if (oldValue != newValue)
                {
                    IsSelected = newValue;
                    bool oldValueAsBool = oldValue.HasValue && oldValue.Value;
                    bool newValueAsBool = newValue.HasValue && newValue.Value;
                    if (oldValueAsBool != newValueAsBool)
                    {
                        // AutomationEvents.PropertyChanged is used as a value that means dont raise anything
                        AutomationEvents eventToRaise =
                            oldValueAsBool ?
                            (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) :
                            (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection);

                        if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise))
                        {
                            var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this);
                            peer.RaiseAutomationEvent(eventToRaise);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void ValidateOneLevelMultipleSelection()
        {
            RunOnUIThread.Execute(() =>
            {
                SelectionModel selectionModel = new SelectionModel();
                selectionModel.Source         = Enumerable.Range(0, 10).ToList();

                Select(selectionModel, 4, true);
                ValidateSelection(selectionModel, new List <IndexPath>()
                {
                    Path(4)
                }, new List <IndexPath>()
                {
                    Path()
                });
                SelectRangeFromAnchor(selectionModel, 8, true /* select */);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(4),
                    Path(5),
                    Path(6),
                    Path(7),
                    Path(8)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                ClearSelection(selectionModel);
                SetAnchorIndex(selectionModel, 6);
                SelectRangeFromAnchor(selectionModel, 3, true /* select */);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4),
                    Path(5),
                    Path(6)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                SetAnchorIndex(selectionModel, 4);
                SelectRangeFromAnchor(selectionModel, 5, false /* select */);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(6)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });
            });
        }
Beispiel #3
0
        public void SelectRangeRegressionTest()
        {
            RunOnUIThread.Execute(() =>
            {
                var selectionModel = new SelectionModel()
                {
                    Source = CreateNestedData(1, 2, 3)
                };

                // length of start smaller than end used to cause an out of range error.
                selectionModel.SelectRange(IndexPath.CreateFrom(0), IndexPath.CreateFrom(1, 1));

                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(0, 0),
                    Path(0, 1),
                    Path(0, 2),
                    Path(0),
                    Path(1, 0),
                    Path(1, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1)
                },
                                  1 /* selectedInnerNodes */);
            });
        }
Beispiel #4
0
        public void ValidateSelectionChangedEvent()
        {
            RunOnUIThread.Execute(() =>
            {
                SelectionModel selectionModel = new SelectionModel();
                selectionModel.Source         = Enumerable.Range(0, 10).ToList();

                int selectionChangedFiredCount   = 0;
                selectionModel.SelectionChanged += delegate(SelectionModel sender, SelectionModelSelectionChangedEventArgs args)
                {
                    selectionChangedFiredCount++;
                    ValidateSelection(selectionModel, new List <IndexPath>()
                    {
                        Path(4)
                    }, new List <IndexPath>()
                    {
                        Path()
                    });
                };

                Select(selectionModel, 4, true);
                ValidateSelection(selectionModel, new List <IndexPath>()
                {
                    Path(4)
                }, new List <IndexPath>()
                {
                    Path()
                });
                Verify.AreEqual(1, selectionChangedFiredCount);
            });
        }
Beispiel #5
0
        public void ValidateClear()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = new ObservableCollection <int>(Enumerable.Range(0, 10));
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(3);
                selectionModel.Select(4);
                selectionModel.Select(5);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4),
                    Path(5),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                data.Clear();
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
        protected override void OnKeyUp(KeyRoutedEventArgs e)
        {
            if (SelectionModel != null)
            {
                if (e.Key == VirtualKey.Escape)
                {
                    SelectionModel.ClearSelection();
                }
                else if (e.Key == VirtualKey.Space)
                {
                    SelectionModel.Select(RepeatedIndex);
                }
                else if (!SelectionModel.SingleSelect)
                {
                    var isShiftPressed = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Shift).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down);
                    var isCtrlPressed  = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Control).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down);
                    if (e.Key == VirtualKey.A && isCtrlPressed)
                    {
                        SelectionModel.SelectAll();
                    }
                    else if (isShiftPressed)
                    {
                        SelectionModel.SelectRangeFromAnchor(RepeatedIndex);
                    }
                }
            }

            base.OnKeyUp(e);
        }
        protected override void OnPointerPressed(PointerRoutedEventArgs e)
        {
            if (SelectionModel != null)
            {
                if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Shift) && !SelectionModel.SingleSelect)
                {
                    if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control))
                    {
                        SelectionModel.DeselectRangeFromAnchor(RepeatedIndex);
                    }
                    else
                    {
                        SelectionModel.SelectRangeFromAnchor(RepeatedIndex);
                    }
                }
                else if (e.KeyModifiers.HasFlag(VirtualKeyModifiers.Control))
                {
                    if (SelectionModel.IsSelected(RepeatedIndex).Value)
                    {
                        SelectionModel.Deselect(RepeatedIndex);
                    }
                    else
                    {
                        SelectionModel.Select(RepeatedIndex);
                    }
                }
                else
                {
                    SelectionModel.Select(RepeatedIndex);
                    this.Focus(FocusState.Keyboard);
                }
            }

            base.OnPointerPressed(e);
        }
Beispiel #8
0
        private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "SelectedIndices")
            {
                bool oldValue   = IsSelected;
                var  groupIndex = GetGroupIndex();
                bool newValue   = groupIndex >= 0 ? SelectionModel.IsSelected(groupIndex, RepeatedIndex).Value : false;

                if (oldValue != newValue)
                {
                    IsSelected = newValue;

                    // AutomationEvents.PropertyChanged is used as a value that means dont raise anything
                    AutomationEvents eventToRaise =
                        oldValue ?
                        (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) :
                        (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection);

                    if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise))
                    {
                        var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this);
                        peer.RaiseAutomationEvent(eventToRaise);
                    }
                }
            }
        }
 private void OnSelectionChanged(SelectionModel sender, SelectionModelSelectionChangedEventArgs args)
 {
     if (AutomationPeer.ListenerExists(AutomationEvents.SelectionPatternOnInvalidated))
     {
         var peer = (SelectionContainerAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(this);
         peer.SelectionChanged(args);
     }
 }
Beispiel #10
0
 public void ValidateCanSetSelectedIndex()
 {
     RunOnUIThread.Execute(() =>
     {
         var model           = new SelectionModel();
         var ip              = IndexPath.CreateFrom(34);
         model.SelectedIndex = ip;
         Verify.AreEqual(0, ip.CompareTo(model.SelectedIndex));
     });
 }
Beispiel #11
0
        public void ValidateGroupRemoves()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                selectionModel.Select(1, 2);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                    Path(1, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Remove before selected range: Removing item at group index 0");
                data.RemoveAt(0);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(0, 1),
                    Path(0, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(0),
                });

                Log.Comment("Remove after selected range: Removing item at group index 1");
                data.RemoveAt(1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(0, 1),
                    Path(0, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(0),
                });

                Log.Comment("Remove group containing selected items");
                data.RemoveAt(0);
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Beispiel #12
0
        private object GetData(SelectionModel selectionModel, IndexPath indexPath)
        {
            var data = selectionModel.Source;

            for (int i = 0; i < indexPath.GetSize(); i++)
            {
                var listData = data as IList;
                data = listData[indexPath.GetAt(i)];
            }

            return(data);
        }
Beispiel #13
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);
     }
 }
Beispiel #14
0
 private void SelectRangeFromAnchor(SelectionModel manager, int groupIndex, int itemIndex, bool select)
 {
     Log.Comment("SelectRangeFromAnchor " + groupIndex + "." + itemIndex + " select:" + select.ToString());
     if (select)
     {
         manager.SelectRangeFromAnchor(groupIndex, itemIndex);
     }
     else
     {
         manager.DeselectRangeFromAnchor(groupIndex, itemIndex);
     }
 }
Beispiel #15
0
 private void Select(SelectionModel manager, IndexPath index, bool select)
 {
     Log.Comment((select ? "Selecting " : "DeSelecting ") + index);
     if (select)
     {
         manager.SelectAt(index);
     }
     else
     {
         manager.DeselectAt(index);
     }
 }
Beispiel #16
0
 private void Select(SelectionModel manager, int groupIndex, int itemIndex, bool select)
 {
     Log.Comment((select ? "Selecting " : "DeSelecting ") + groupIndex + "." + itemIndex);
     if (select)
     {
         manager.Select(groupIndex, itemIndex);
     }
     else
     {
         manager.Deselect(groupIndex, itemIndex);
     }
 }
Beispiel #17
0
        public void ValidatePropertyChangedEventIsRaised()
        {
            RunOnUIThread.Execute(() =>
            {
                var selectionModel = new SelectionModel();
                Log.Comment("Set the source to 10 items");
                selectionModel.Source = Enumerable.Range(0, 10).ToList();

                bool selectedIndexChanged       = false;
                bool selectedIndicesChanged     = false;
                bool SelectedItemChanged        = false;
                bool SelectedItemsChanged       = false;
                bool AnchorIndexChanged         = false;
                selectionModel.PropertyChanged += (sender, args) =>
                {
                    switch (args.PropertyName)
                    {
                    case "SelectedIndex":
                        selectedIndexChanged = true;
                        break;

                    case "SelectedIndices":
                        selectedIndicesChanged = true;
                        break;

                    case "SelectedItem":
                        SelectedItemChanged = true;
                        break;

                    case "SelectedItems":
                        SelectedItemsChanged = true;
                        break;

                    case "AnchorIndex":
                        AnchorIndexChanged = true;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                };

                Select(selectionModel, 3, true);

                Verify.IsTrue(selectedIndexChanged);
                Verify.IsTrue(selectedIndicesChanged);
                Verify.IsTrue(SelectedItemChanged);
                Verify.IsTrue(SelectedItemsChanged);
                Verify.IsTrue(AnchorIndexChanged);
            });
        }
 public void Select(bool select)
 {
     if (SelectionModel != null)
     {
         var indexPath = GetIndexPath();
         if (select)
         {
             SelectionModel.SelectAt(indexPath);
         }
         else
         {
             SelectionModel.DeselectAt(indexPath);
         }
     }
 }
Beispiel #19
0
        public void CanReadSelectedItemViaICustomPropertyProvider()
        {
            RunOnUIThread.Execute(() =>
            {
                var selectionModel = new SelectionModel();
                Log.Comment("Set the source to 10 items");
                selectionModel.Source = Enumerable.Range(0, 10).ToList();

                selectionModel.Select(3);

                var icpp = (ICustomPropertyProvider)selectionModel;
                var selectedItemProperty = icpp.GetCustomProperty("SelectedItem");
                Verify.IsTrue(selectedItemProperty.CanRead);
                Verify.AreEqual(3, selectedItemProperty.GetValue(selectionModel));
            });
        }
Beispiel #20
0
        public void ValidateGroupInserts()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Insert before selected range: Inserting item at group index 0");
                data.Insert(0, 100);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(2, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(2),
                });

                Log.Comment("Insert after selected range: Inserting item at group index 3");
                data.Insert(3, 1000);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(2, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(2),
                });
            });
        }
        protected override void OnKeyUp(KeyRoutedEventArgs e)
        {
            var indexPath = GetIndexPath();

            Debug.WriteLine("OnKeyUp:" + indexPath.ToString());

            if (SelectionModel != null)
            {
                if (e.Key == VirtualKey.Escape)
                {
                    SelectionModel.ClearSelection();
                }
                else if (e.Key == VirtualKey.Space)
                {
                    SelectionModel.SelectAt(indexPath);
                }
                else if (!SelectionModel.SingleSelect)
                {
                    var isShiftPressed = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Shift).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down);
                    var isCtrlPressed  = Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Control).HasFlag(Windows.UI.Core.CoreVirtualKeyStates.Down);
                    if (e.Key == VirtualKey.A && isCtrlPressed)
                    {
                        SelectionModel.SelectAll();
                    }
                    else if (isCtrlPressed && e.Key == VirtualKey.Space)
                    {
                        if (SelectionModel.IsSelectedAt(indexPath).Value)
                        {
                            SelectionModel.DeselectAt(indexPath);
                        }
                        else
                        {
                            SelectionModel.SelectAt(indexPath);
                        }
                    }
                    else if (isShiftPressed)
                    {
                        SelectionModel.SelectRangeFromAnchorTo(GetIndexPath());
                    }
                }
            }

            base.OnKeyUp(e);
        }
        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);
            }
        }
Beispiel #23
0
 public void ValidateNestedSingleSelection()
 {
     RunOnUIThread.Execute(() =>
     {
         SelectionModel selectionModel = new SelectionModel()
         {
             SingleSelect = true
         };
         Log.Comment("Setting the source");
         selectionModel.Source = CreateNestedData(3 /* levels */, 2 /* groupsAtLevel */, 2 /* countAtLeaf */);
         var path = Path(1, 0, 1, 1);
         Select(selectionModel, path, true);
         ValidateSelection(selectionModel,
                           new List <IndexPath>()
         {
             path
         },
                           new List <IndexPath>()
         {
             Path(),
             Path(1),
             Path(1, 0),
             Path(1, 0, 1),
         });
         Select(selectionModel, Path(0, 0, 1, 0), true);
         ValidateSelection(selectionModel,
                           new List <IndexPath>()
         {
             Path(0, 0, 1, 0)
         },
                           new List <IndexPath>()
         {
             Path(),
             Path(0),
             Path(0, 0),
             Path(0, 0, 1)
         });
         Select(selectionModel, Path(0, 0, 1, 0), false);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
         });
     });
 }
Beispiel #24
0
 public void ValidateOneLevelSingleSelectionNoSource()
 {
     RunOnUIThread.Execute(() =>
     {
         SelectionModel selectionModel = new SelectionModel()
         {
             SingleSelect = true
         };
         Log.Comment("No source set.");
         Select(selectionModel, 4, true);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
             Path(4)
         });
         Select(selectionModel, 4, false);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
         });
     });
 }
Beispiel #25
0
 public void ValidateTwoLevelSingleSelection()
 {
     RunOnUIThread.Execute(() =>
     {
         SelectionModel selectionModel = new SelectionModel();
         Log.Comment("Setting the source");
         selectionModel.Source = CreateNestedData(1 /* levels */, 2 /* groupsAtLevel */, 2 /* countAtLeaf */);
         Select(selectionModel, 1, 1, true);
         ValidateSelection(selectionModel,
                           new List <IndexPath>()
         {
             Path(1, 1)
         }, new List <IndexPath>()
         {
             Path(), Path(1)
         });
         Select(selectionModel, 1, 1, false);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
         });
     });
 }
Beispiel #26
0
        public void ValidateGroupClear()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1)
                });

                (data[1] as IList).Clear();
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Beispiel #27
0
        public void ValidateGroupReplaceLosesSelection()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1)
                });

                data[1] = new ObservableCollection <int>(Enumerable.Range(0, 5));
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Beispiel #28
0
 public void ValidateOneLevelSingleSelection()
 {
     RunOnUIThread.Execute(() =>
     {
         SelectionModel selectionModel = new SelectionModel()
         {
             SingleSelect = true
         };
         Log.Comment("Set the source to 10 items");
         selectionModel.Source = Enumerable.Range(0, 10).ToList();
         Select(selectionModel, 3, true);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
             Path(3)
         }, new List <IndexPath>()
         {
             Path()
         });
         Select(selectionModel, 3, false);
         ValidateSelection(selectionModel, new List <IndexPath>()
         {
         });
     });
 }
Beispiel #29
0
        public void ValidateEventWhenInnerNodeChangesSelectionState()
        {
            RunOnUIThread.Execute(() =>
            {
                bool selectionChangedRaised = false;
                var data                         = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel               = new SelectionModel();
                selectionModel.Source            = data;
                selectionModel.SelectionChanged += (sender, args) => { selectionChangedRaised = true; };

                selectionModel.Select(1, 0);
                selectionModel.Select(1, 1);
                selectionModel.Select(1, 2);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 0),
                    Path(1, 1),
                    Path(1, 2),
                    Path(1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                },
                                  1 /* selectedInnerNodes */);

                Log.Comment("Inserting 1.0");
                selectionChangedRaised = false;
                (data[1] as ObservableCollection <object>).Insert(0, 100);
                Verify.IsTrue(selectionChangedRaised, "SelectionChanged event was not raised");
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                    Path(1, 2),
                    Path(1, 3),
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Removing 1.0");
                selectionChangedRaised = false;
                (data[1] as ObservableCollection <object>).RemoveAt(0);
                Verify.IsTrue(selectionChangedRaised, "SelectionChanged event was not raised");
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 0),
                    Path(1, 1),
                    Path(1, 2),
                    Path(1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                },
                                  1 /* selectedInnerNodes */);
            });
        }
Beispiel #30
0
        public void ValidateRemoves()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = new ObservableCollection <int>(Enumerable.Range(0, 10));
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(6);
                selectionModel.Select(7);
                selectionModel.Select(8);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(6),
                    Path(7),
                    Path(8)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove before selected range: Removing item at index 0");
                data.RemoveAt(0);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(5),
                    Path(6),
                    Path(7)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove from before to middle of selected range: Removing items at index 3, 4, 5");
                data.RemoveAt(3);
                data.RemoveAt(3);
                data.RemoveAt(3);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove after selected range: Removing item at index 5");
                data.RemoveAt(5);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });
            });
        }