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

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

            if (e.PropertyName == "Position")
            {
                Position = Position + parent.Position - parent.OldPosition;
            }
        }
Example #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);
 }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
        }
Example #9
0
 private DragDropEffects GetDropEffects(MeshViewModel mesh)
 {
     return(DragDropEffects.Move);
 }
Example #10
0
 private object GetData(MeshViewModel mesh)
 {
     return(this);
 }
Example #11
0
 private void Drop(MeshViewModel child)
 {
     child.SetNewParent(this);
     OnPropertyChanged("Parent");
 }
Example #12
0
 private DragDropEffects GetDragEffects(MeshViewModel mesh)
 {
     // Only allow the drag and drop to start if we have any cookies
     return(DragDropEffects.Move);
 }