예제 #1
0
        public void RemoveSelection(IListSelection selection)
        {
            if (selection is null)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            if (selection.Count == 0)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            var values = BaseList.GetSelectionData(selection);

            WriteData(
                () => BaseList.RemoveSelection(values.Selection),
                () => BaseList.InsertSelection(values));
        }
예제 #2
0
        public void Cut(IListSelection selection)
        {
            if (!CanCut)
            {
                return;
            }

            var e = new CancelEventArgs();

            OnBeginCut(e);
            if (e.Cancel)
            {
                return;
            }

            CopyData = this.GetSelectionData(selection);
            Parent.Cut(GetByteSelection(selection));
            OnCutComplete(EventArgs.Empty);
        }
예제 #3
0
        public void TransformSelection(
            IListSelection selection,
            Func <T, T> func)
        {
            if (selection is null)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            if (selection.Count == 0)
            {
                return;
            }

            var values = BaseList.GetSelectionData(selection);

            WriteData(
                () => BaseList.TransformSelection(selection, func),
                () => BaseList.WriteSelection(values));
        }
예제 #4
0
        public static int FindLastIndex <T>(
            this IReadOnlyList <T> list,
            IListSelection selection,
            Predicate <T> match)
        {
            if (list is null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            if (selection is null)
            {
                throw new ArgumentNullException(nameof(selection));
            }

            if (match is null)
            {
                throw new ArgumentNullException(nameof(match));
            }

            for (var i = selection.Count; --i >= 0;)
            {
                var index = selection[i];
                if ((uint)index >= list.Count)
                {
                    continue;
                }

                if (match(list[index]))
                {
                    return(index);
                }
            }

            return(-1);
        }
예제 #5
0
 public void TransformSelection(IListSelection selection, Func <byte, byte> func)
 {
     BaseList.TransformSelection(selection, func);
 }
예제 #6
0
 public void RemoveSelection(IListSelection selection)
 {
     BaseList.RemoveSelection(selection);
 }
예제 #7
0
 public KeyCollection(IListSelection selection)
 {
     Selection = selection;
 }
예제 #8
0
 public static void ClearSelection <T>(
     this List <T> list,
     IListSelection selection)
 {
     TransformSelection(list, selection, _ => default);
 }
예제 #9
0
 public static ListSelectionData <T> GetSelectionData <T>(
     this IReadOnlyList <T> list,
     IListSelection selection)
 {
     return(new ListSelectionData <T>(selection, list));
 }