public void AddMesh() { MeshViewModel mesh = new MeshViewModel(); MeshList.Add(mesh); RootLevel.Add(mesh); }
private void Drop(MeshViewModel child) { if (child.Parent != null) { child.SetNewParent(null); RootLevel.Add(child); } }
private DragDropEffects GetDropEffects(MeshViewModel mesh) { if (HasChild(mesh)) { return(DragDropEffects.None); } return(DragDropEffects.Move); }
private void _parent_PropertyChanged(object sender, PropertyChangedEventArgs e) { MeshViewModel parent = (MeshViewModel)sender; if (e.PropertyName == "Position") { Position = Position + parent.Position - parent.OldPosition; } }
private bool HasChild(MeshViewModel mesh) { if (mesh == this) { return(true); } foreach (MeshViewModel m in mesh.Children) { if (HasChild(m)) { return(true); } } return(false); }
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); } }
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); } }
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); }
private DragDropEffects GetDropEffects(MeshViewModel mesh) { return(DragDropEffects.Move); }
private object GetData(MeshViewModel mesh) { return(this); }
private void Drop(MeshViewModel child) { child.SetNewParent(this); OnPropertyChanged("Parent"); }
private DragDropEffects GetDragEffects(MeshViewModel mesh) { // Only allow the drag and drop to start if we have any cookies return(DragDropEffects.Move); }