Beispiel #1
0
        public void RemoveAttribute()
        {
            int eventsFired = 0;

            Scene scene = new Scene("Test Scene");
            scene.Attributes.CollectionChanged += (sender, e) => eventsFired++;

            Attribute attribute = new Attribute("test");
            scene.AddAttribute(attribute);
            scene.RemoveAttribute(attribute);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(0, scene.Attributes.Count(x => x.Name == "test"));
        }
        public SceneViewModel(Scene scene)
        {
            this.scene = scene;

            Entities = new ComputedObservableCollection<Entity, EntityViewModel>(scene.Entities, (entity) => new EntityViewModel(entity));

            scene.PropertyChanged += Scene_PropertyChanged;

            AddAttributeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    scene.CreateAttribute();
                }
            );

            RemoveAttributeCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Attribute attribute = parameter as Attribute;
                    scene.RemoveAttribute(attribute);
                }
            );

            AddEntityCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Entity entity = new Entity();
                    scene.AddEntity(entity);
                }
            );

            RemoveEntityCommand = new DelegateCommand(null,
                (parameter) =>
                {
                    Entity entity = parameter as Entity;
                    scene.RemoveEntity(entity);
                }
            );
        }