コード例 #1
0
 public IEnumerable <ICombatObject> AllAliveCombatObjects()
 {
     return
         (BackingList.SelectMany(
              group =>
              group.Where(combatObject => !combatObject.IsDead)
              .Select(combatObject => combatObject)));
 }
コード例 #2
0
 private CopyOnWriteList(CopyOnWriteList <T> other)
 {
     _backing = other._backing;
     if (_backing != null)
     {
         lock (((ICollection)_backing).SyncRoot) {
             _backing.AddRef();
         }
     }
 }
コード例 #3
0
        private void OnDependencyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
        {
            T item = (T)(LiveShapingItem <T>)dependencyObject;

            switch (GetCategoryOfDependencyProperty(args.Property))
            {
            case LiveShapingCategory.Sorting:
                int originalBinarySearchIndex = InternalBinarySearchWithEqualityCheck(item);
                int actualIndex;
                int targetIndex;

                if (originalBinarySearchIndex >= 0)
                {
                    Debug.Assert(BackingList[originalBinarySearchIndex].Equals(item));

                    actualIndex = originalBinarySearchIndex;
                    targetIndex = FindCorrectLocation(item);
                }
                else
                {
                    actualIndex = LinearSearch(item);
                    targetIndex = ~originalBinarySearchIndex;
                }

                LiveShapingItems[item].IsSortDirty = false;
                if (actualIndex >= 0)
                {
                    // adjust targetIndex if the item at actualIndex will no longer be there
                    if (actualIndex < targetIndex)
                    {
                        targetIndex--;
                    }
                    if (targetIndex != actualIndex)
                    {
                        BackingList.Move(actualIndex, targetIndex);
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, item, targetIndex,
                                                                                 actualIndex));
                    }
                }
                break;

            case LiveShapingCategory.Filtering:
                var passesFilter = PassesFilter(item);

                if (passesFilter)
                {
                    if (FilteredItems.Remove(item))
                    {
                        var insertionIndex = base.Add(item);
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, insertionIndex));
                    }
                }
                else
                {
                    if (!FilteredItems.Contains(item))
                    {
                        var removalIndex = IndexOf(item);

                        // It is possible that the liveshapingitem has been registered but the item has not yet been added to this collection (causing index = -1), in which case this is a noop
                        if (removalIndex >= 0)
                        {
                            base.RemoveAt(removalIndex);
                            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, removalIndex));
                            FilteredItems.Add(item);
                        }
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            /* Debug.WriteLine(args.Property + "  " + string.Join(", ",
             *                   BackingList.OfType<GameFolderPair>()
             *                              .Select(
             *                                  folderPair => {
             *                                      if (folderPair.DestinationEntry == null) return "-99";
             *
             *                                      return SizeToStringConverter.Instance.Convert(folderPair.DestinationEntry?.Size)
             + (LiveShapingItems[folderPair as T].IsSortDirty ? "" : "✓");
             +                                  })
             +               ));*/
        }
コード例 #4
0
 private int LinearSearch(T item) => BackingList.IndexOf(item);
コード例 #5
0
 public override string ToString()
 {
     return(string.Join(" ", BackingList.ToArray()));
 }
コード例 #6
0
        public override void WriteXml(XmlWriter writer)
        {
            writer.WriteAttributeString("override", Override.ToString().ToLower());

            writer.WriteString(string.Join(" ", BackingList.ToArray()));
        }
コード例 #7
0
 public override void WriteXml(XmlWriter writer)
 {
     writer.WriteString(string.Join(" ", BackingList.ToArray()));
 }
コード例 #8
0
 public Enumerator(BackingList backing)
 {
     _backing = backing;
     _inner   = _backing.GetEnumerator();
     _backing.AddRef();
 }
コード例 #9
0
 public override string ToString()
 {
     return(new string(BackingList.ToArray()));
 }
コード例 #10
0
 private void ObjectAdded(PersistableObjectList <ICombatObject> persistableObjectList, ICombatObject combatObject)
 {
     combatObject.GroupId = Id;
     BackingList.Sort((combatObject1, combatObject2) => combatObject1.Id.CompareTo(combatObject2.Id));
     CombatObjectAdded(this, combatObject);
 }
コード例 #11
0
 public bool IsDead()
 {
     return(BackingList.All(combatObject => combatObject.IsDead));
 }
コード例 #12
0
 private void ObjectAdded(PersistableObjectList <ICombatGroup> list, ICombatGroup item)
 {
     BackingList.Sort((combatGroup1, combatGroup2) => combatGroup1.Id.CompareTo(combatGroup2.Id));
 }
コード例 #13
0
 public IEnumerable <ICombatObject> AllCombatObjects()
 {
     return(BackingList.SelectMany(group => group.Select(combatObject => combatObject)));
 }