// This source file is adapted from the WinUI project.
// (https://github.com/microsoft/microsoft-ui-xaml)
//
// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace Avalonia.Controls
{
///
/// Holds the selected items for a control.
///
public interface ISelectionModel : INotifyPropertyChanged
{
///
/// Gets or sets the anchor index.
///
IndexPath AnchorIndex { get; set; }
///
/// Gets or set the index of the first selected item.
///
IndexPath SelectedIndex { get; set; }
///
/// Gets or set the indexes of the selected items.
///
IReadOnlyList SelectedIndices { get; }
///
/// Gets the first selected item.
///
object SelectedItem { get; }
///
/// Gets the selected items.
///
IReadOnlyList SelectedItems { get; }
///
/// Gets a value indicating whether the model represents a single or multiple selection.
///
bool SingleSelect { get; set; }
///
/// Gets a value indicating whether to always keep an item selected where possible.
///
bool AutoSelect { get; set; }
///
/// Gets or sets the collection that contains the items that can be selected.
///
object Source { get; set; }
///
/// Raised when the children of a selection are required.
///
event EventHandler ChildrenRequested;
///
/// Raised when the selection has changed.
///
event EventHandler SelectionChanged;
///
/// Clears the selection.
///
void ClearSelection();
///
/// Deselects an item.
///
/// The index of the item.
void Deselect(int index);
///
/// Deselects an item.
///
/// The index of the item group.
/// The index of the item in the group.
void Deselect(int groupIndex, int itemIndex);
///
/// Deselects an item.
///
/// The index of the item.
void DeselectAt(IndexPath index);
///
/// Deselects a range of items.
///
/// The start index of the range.
/// The end index of the range.
void DeselectRange(IndexPath start, IndexPath end);
///
/// Deselects a range of items, starting at .
///
/// The end index of the range.
void DeselectRangeFromAnchor(int index);
///
/// Deselects a range of items, starting at .
///
///
/// The index of the item group that represents the end of the selection.
///
///
/// The index of the item in the group that represents the end of the selection.
///
void DeselectRangeFromAnchor(int endGroupIndex, int endItemIndex);
///
/// Deselects a range of items, starting at .
///
/// The end index of the range.
void DeselectRangeFromAnchorTo(IndexPath index);
///
/// Disposes the object and clears the selection.
///
void Dispose();
///
/// Checks whether an item is selected.
///
/// The index of the item
bool IsSelected(int index);
///
/// Checks whether an item is selected.
///
/// The index of the item group.
/// The index of the item in the group.
bool IsSelected(int groupIndex, int itemIndex);
///
/// Checks whether an item is selected.
///
/// The index of the item
public bool IsSelectedAt(IndexPath index);
///
/// Checks whether an item or its descendents are selected.
///
/// The index of the item
///
/// True if the item and all its descendents are selected, false if the item and all its
/// descendents are deselected, or null if a combination of selected and deselected.
///
bool? IsSelectedWithPartial(int index);
///
/// Checks whether an item or its descendents are selected.
///
/// The index of the item group.
/// The index of the item in the group.
///
/// True if the item and all its descendents are selected, false if the item and all its
/// descendents are deselected, or null if a combination of selected and deselected.
///
bool? IsSelectedWithPartial(int groupIndex, int itemIndex);
///
/// Checks whether an item or its descendents are selected.
///
/// The index of the item
///
/// True if the item and all its descendents are selected, false if the item and all its
/// descendents are deselected, or null if a combination of selected and deselected.
///
bool? IsSelectedWithPartialAt(IndexPath index);
///
/// Selects an item.
///
/// The index of the item
void Select(int index);
///
/// Selects an item.
///
/// The index of the item group.
/// The index of the item in the group.
void Select(int groupIndex, int itemIndex);
///
/// Selects an item.
///
/// The index of the item
void SelectAt(IndexPath index);
///
/// Selects all items.
///
void SelectAll();
///
/// Selects a range of items.
///
/// The start index of the range.
/// The end index of the range.
void SelectRange(IndexPath start, IndexPath end);
///
/// Selects a range of items, starting at .
///
/// The end index of the range.
void SelectRangeFromAnchor(int index);
///
/// Selects a range of items, starting at .
///
///
/// The index of the item group that represents the end of the selection.
///
///
/// The index of the item in the group that represents the end of the selection.
///
void SelectRangeFromAnchor(int endGroupIndex, int endItemIndex);
///
/// Selects a range of items, starting at .
///
/// The end index of the range.
void SelectRangeFromAnchorTo(IndexPath index);
///
/// Sets the .
///
/// The anchor index.
void SetAnchorIndex(int index);
///
/// Sets the .
///
/// The index of the item group.
/// The index of the item in the group.
void SetAnchorIndex(int groupIndex, int index);
///
/// Begins a batch update of the selection.
///
/// An that finishes the batch update.
IDisposable Update();
}
}