Exemplo n.º 1
0
        internal void ProcessProjectElementsChanged(Modding.ElementCollectionChangedEventArgs e)
        {
            if (ExecutingUndoRedo)
            {
                return;
            }

            var action = new CollectionChangeAction(e);

            AddActionCore(action);
        }
Exemplo n.º 2
0
        private BatchChangeAction CombineBatchChanges(IEnumerable <ChangeAction> actions)
        {
            var combinedChanges = new List <ChangeAction>();
            CollectionChangeAction prevColChange = null;

            foreach (var action in actions)
            {
                if (action is CollectionChangeAction colChange)
                {
                    if (prevColChange != null)
                    {
                        if (colChange.Data.Collection == prevColChange.Data.Collection &&
                            colChange.Data.Action == prevColChange.Data.Action)
                        {
                            //var prevElements = prevColChange.Data.AddedElements.Concat(prevColChange.Data.RemovedElements);
                            //var currElements = colChange.Data.AddedElements.Concat(colChange.Data.RemovedElements);

                            prevColChange = new CollectionChangeAction(
                                new Modding.ElementCollectionChangedEventArgs(
                                    colChange.Data.Collection, colChange.Data.Action,
                                    prevColChange.Data.ChangedItems.Concat(colChange.Data.ChangedItems)
                                    ));
                        }
                        else
                        {
                            combinedChanges.Add(prevColChange);
                            prevColChange = colChange;
                        }
                    }
                    else
                    {
                        prevColChange = colChange;
                    }
                }
                else
                {
                    if (prevColChange != null)
                    {
                        combinedChanges.Add(prevColChange);
                        prevColChange = null;
                    }

                    combinedChanges.Add(action);
                }
            }

            if (prevColChange != null)
            {
                combinedChanges.Add(prevColChange);
            }

            return(new BatchChangeAction(combinedChanges));
        }
Exemplo n.º 3
0
        internal void ProcessProjectElementsChanged(Modding.Editing.ElementCollectionChangedEventArgs e)
        {
            if (ExecutingUndoRedo)
            {
                return;
            }

            var action = new CollectionChangeAction(e);

            if (IsInBatch)
            {
                BatchChanges.Add(action);
            }
            else
            {
                AddAction(action);
            }
        }