Beispiel #1
0
        private void UndoServiceOnActiveStateChanged(object sender, ActiveStateChangedEventArgs e)
        {
            foreach (var change in e.ChangeSet.Where(c => c.OwnerId == Id))
            {
                APlay.Common.Logging.Logger.LogDesigned(2,
                                                        "ActiveStateChanged received and updated state. OwnerId: " + change.OwnerId,
                                                        "AplayTest.Server.Sheet");


                if (change.ChangeReason == ChangeReason.InsertAt)
                {
                    if (change.Undoable is BlockSymbolUndoable)
                    {
                        BlockSymbols.Insert(change.IndexAt,
                                            _blockSymbolFactory.Create((BlockSymbolUndoable)change.Undoable, e.ChangeSet));
                    }
                    else if (change.Undoable is ConnectionUndoable)
                    {
                        Connections.Insert(change.IndexAt,
                                           _connectionFactory.Create((ConnectionUndoable)change.Undoable, e.ChangeSet));
                    }
                }
                else if (change.ChangeReason == ChangeReason.RemoveAt)
                {
                    if (change.Undoable is BlockSymbolUndoable)
                    {
                        BlockSymbols.RemoveAt(change.IndexAt);
                        _blockSymbolFactory.Remove(change.Undoable.Id);
                    }
                    else if (change.Undoable is ConnectionUndoable)
                    {
                        Connections.RemoveAt(change.IndexAt);
                        _connectionFactory.Remove(change.Undoable.Id);
                    }
                }

                var storedObject = change.Undoable as SheetUndoable;

                if (storedObject != null)
                {
                    if (change.ChangeReason == ChangeReason.Update)
                    {
                        Name = storedObject.Name;
                    }
                }

                Dump();
            }
        }