コード例 #1
0
        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);
                }
            );
        }