예제 #1
0
        public void AddMesh()
        {
            MeshViewModel mesh = new MeshViewModel();

            MeshList.Add(mesh);
            RootLevel.Add(mesh);
        }
예제 #2
0
 private void Drop(MeshViewModel child)
 {
     if (child.Parent != null)
     {
         child.SetNewParent(null);
         RootLevel.Add(child);
     }
 }
예제 #3
0
 private DragDropEffects GetDropEffects(MeshViewModel mesh)
 {
     if (HasChild(mesh))
     {
         return(DragDropEffects.None);
     }
     return(DragDropEffects.Move);
 }
예제 #4
0
        private void _parent_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            MeshViewModel parent = (MeshViewModel)sender;

            if (e.PropertyName == "Position")
            {
                Position = Position + parent.Position - parent.OldPosition;
            }
        }
예제 #5
0
 private bool HasChild(MeshViewModel mesh)
 {
     if (mesh == this)
     {
         return(true);
     }
     foreach (MeshViewModel m in mesh.Children)
     {
         if (HasChild(m))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #6
0
        public void RemoveMesh(MeshViewModel mesh)
        {
            foreach (MeshViewModel vm in mesh.Children)
            {
                vm.Parent = mesh.Parent;
            }

            if (mesh.Parent == null)
            {
                RootLevel.Remove(mesh);
            }
            else
            {
                mesh.Parent.Children.Remove(mesh);
            }
        }
예제 #7
0
        public void SetNewParent(MeshViewModel parent)
        {
            //remove current parent
            if (_parent != null)
            {
                _parent.Children.Remove(this);
                _parent.Model.children.Remove(_mesh);
            }

            //set parent
            _parent      = parent;
            _mesh.parent = (parent == null)? null : parent.Model;


            // add this mesh to parent's children & subscribe to parent's properties
            if (parent != null)
            {
                _parent.PropertyChanged += _parent_PropertyChanged;
                parent.Children.Add(this);
                parent.Model.children.Add(_mesh);
            }
        }
예제 #8
0
        public MeshTreeViewModel(MeshCollection meshList)
        {
            _meshList = meshList;
            MeshList  = new ObservableCollection <MeshViewModel>();
            RootLevel = new ObservableCollection <MeshViewModel>();


            AddMeshCommand    = new DelegateCommand(AddMesh);
            RemoveMeshCommand = new DelegateCommand <MeshViewModel>(RemoveMesh);

            // Instantiate meshes
            foreach (Mesh mesh in _meshList.meshes)
            {
                MeshViewModel mv = new MeshViewModel(mesh);
                MeshList.Add(mv);
                mv.PropertyChanged += new PropertyChangedEventHandler(Mesh_PropertyChanged);
            }


            // Linking Tree
            foreach (MeshViewModel mv in MeshList)
            {
                mv.Model.LinkToParent(_meshList.meshes);
                MeshViewModel parent = MeshList.FirstOrDefault(x => (x.Model == mv.Model.parent));
                mv.Parent = parent;
                if (mv.Parent != null)
                {
                    if (!parent.Children.Contains(mv))
                    {
                        parent.Children.Add(mv);
                    }
                }
                mv.PropertyChanged += Mv_PropertyChanged;
            }

            // Create Scene
            Scene = new OGLScene(_meshList.meshes);
        }
예제 #9
0
 private DragDropEffects GetDropEffects(MeshViewModel mesh)
 {
     return(DragDropEffects.Move);
 }
예제 #10
0
 private object GetData(MeshViewModel mesh)
 {
     return(this);
 }
예제 #11
0
 private void Drop(MeshViewModel child)
 {
     child.SetNewParent(this);
     OnPropertyChanged("Parent");
 }
예제 #12
0
 private DragDropEffects GetDragEffects(MeshViewModel mesh)
 {
     // Only allow the drag and drop to start if we have any cookies
     return(DragDropEffects.Move);
 }