private void RoomProfilesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Add) { foreach (var roomProfile in notifyCollectionChangedEventArgs.NewItems.OfType <RoomSet>()) { TestRoomSet testRoomSet = new TestRoomSet() { RoomSet = roomProfile, Patches = new Dictionary <Direction, RoomSetPatch>() }; TestRoomProfiles.Add(testRoomSet); } } else if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Remove) { var roomSets = notifyCollectionChangedEventArgs.OldItems.OfType <RoomSet>().ToArray(); foreach (var testRoomSet in TestRoomProfiles.Where(_ => roomSets.Contains(_.RoomSet)).ToArray()) { TestRoomProfiles.Remove(testRoomSet); } } else if (notifyCollectionChangedEventArgs.Action == NotifyCollectionChangedAction.Reset) { TestRoomProfiles.Clear(); } }
public DesignTimeRoomEditorViewModel() { RoomProfiles.Add(new RoomSet { Name = "Room U", Rooms = new [] { true, false, true, true, false, true, true, true, true }.Select((value, index) => new Room(index % RoomSize, index / RoomSize, value)) .ToArray() }); RoomProfiles.Add(new RoomSet { Name = "T", Rooms = new [] { true, true, true, false, true, false, false, true, false }.Select((value, index) => new Room(index % RoomSize, index / RoomSize, value)) .ToArray() }); RoomProfiles.Add(new RoomSet { Name = "V", Rooms = new[] { true, false, true, true, false, true, false, true, false }.Select((value, index) => new Room(index % RoomSize, index / RoomSize, value)) .ToArray() }); this.CurrentRoomSet = RoomProfiles.First(); this.TestRoomSet = TestRoomProfiles.Last(); }