public override object GetProperty(string propertyName) { if (propertyName == "IsVisible") { return((object)(bool)(!GroupCommandHelpers.IsGrouping2D(this.SceneViewModel) ? true : false)); } return(base.GetProperty(propertyName)); }
private SceneElement GroupElements() { ReadOnlyCollection <SceneElement> selection = this.SceneViewModel.ElementSelectionSet.Selection; if (selection[0] is BaseFrameworkElement) { return((SceneElement)null); } if (!(selection[0] is Base3DElement)) { return((SceneElement)null); } SceneElement primarySelection = this.SceneViewModel.ElementSelectionSet.PrimarySelection; this.SceneViewModel.ElementSelectionSet.Clear(); List <SceneElement> list = new List <SceneElement>((IEnumerable <SceneElement>)selection); Base3DElement base3Delement1 = (Base3DElement)null; int num = int.MaxValue; Viewport3DElement viewport = ((Base3DElement)list[0]).Viewport; foreach (Base3DElement base3Delement2 in list) { if (base3Delement2.Viewport == viewport) { int depthFromViewport3D = base3Delement2.DepthFromViewport3D; if (depthFromViewport3D < num) { base3Delement1 = base3Delement2; num = depthFromViewport3D; } } } SceneElement parentElement = base3Delement1.ParentElement; Matrix3D matrix3D = Matrix3D.Identity; if (parentElement is Base3DElement) { matrix3D = ((Base3DElement)parentElement).GetComputedTransformFromViewport3DToElement(); matrix3D.Invert(); } Base3DElement parent = (Base3DElement)null; if (list[0] is Model3DElement) { Model3DGroup model3Dgroup = new Model3DGroup(); Model3DCollection model3Dcollection = new Model3DCollection(); model3Dgroup.Children = model3Dcollection; parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)model3Dgroup); } else if (list[0] is Visual3DElement) { parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)new ModelVisual3D()); } SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(this.SceneViewModel, (SceneNode)this.SceneViewModel.ActiveSceneInsertionPoint.SceneElement.StoryboardContainer); string validElementId = sceneNodeIdHelper.GetValidElementID((SceneNode)parent, "group3D"); sceneNodeIdHelper.SetLocalName((SceneNode)parent, validElementId); using (this.SceneViewModel.ForceBaseValue()) { Matrix3D[] matrix3DArray = new Matrix3D[list.Count]; for (int index = 0; index < list.Count; ++index) { matrix3DArray[index] = ((Base3DElement)list[index]).GetComputedTransformFromViewport3DToElement(); } foreach (Base3DElement base3Delement2 in list) { if (base3Delement2 != primarySelection) { base3Delement2.Remove(); } } int insertAt = primarySelection.GetCollectionContainer().IndexOf((SceneNode)primarySelection); primarySelection.Remove(); if (parentElement is Viewport3DElement) { GroupCommandHelpers.InsertElement(parentElement, (SceneNode)parent, insertAt); } else { GroupCommandHelpers.InsertElement(this.SceneViewModel, (Base3DElement)parentElement, (SceneNode)parent, new int?(insertAt)); } for (int index = 0; index < list.Count; ++index) { GroupCommandHelpers.InsertElement(this.SceneViewModel, parent, (SceneNode)list[index], new int?()); ((Base3DElement)list[index]).Transform = (Transform3D) new CanonicalTransform3D(matrix3DArray[index] * matrix3D); } } return((SceneElement)parent); }
private SceneNode[] Ungroup(Base3DElement group) { SceneElement parentElement = group.ParentElement; Matrix3D matrix3D = group.Transform.Value; Model3DGroupElement model3DgroupElement = group as Model3DGroupElement; ModelVisual3DElement modelVisual3Delement1 = group as ModelVisual3DElement; int index1 = 0; bool flag = false; if (model3DgroupElement != null) { index1 = model3DgroupElement.Children.Count; } else if (modelVisual3Delement1 != null) { index1 = modelVisual3Delement1.Children.Count; flag = modelVisual3Delement1.Model3DContent != null; } Base3DElement[] base3DelementArray = new Base3DElement[index1 + (flag ? true : false)]; Matrix3D[] matrix3DArray = new Matrix3D[index1 + (flag ? true : false)]; if (model3DgroupElement != null) { for (int index2 = 0; index2 < model3DgroupElement.Children.Count; ++index2) { base3DelementArray[index2] = (Base3DElement)model3DgroupElement.Children[index2]; } } else if (modelVisual3Delement1 != null) { for (int index2 = 0; index2 < modelVisual3Delement1.Children.Count; ++index2) { base3DelementArray[index2] = (Base3DElement)modelVisual3Delement1.Children[index2]; } if (flag) { base3DelementArray[index1] = (Base3DElement)modelVisual3Delement1.Model3DContent; matrix3DArray[index1] = modelVisual3Delement1.Transform.Value; } } for (int index2 = 0; index2 < index1; ++index2) { Base3DElement base3Delement = base3DelementArray[index2]; matrix3DArray[index2] = base3Delement.Transform.Value; } using (this.SceneViewModel.ForceBaseValue()) { int insertAt = group.GetCollectionContainer().IndexOf((SceneNode)group); if (group.ParentElement is Base3DElement) { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(group.ParentElement); } else { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)group); } this.SceneViewModel.RemoveElement((SceneNode)group); for (int index2 = index1 - 1; index2 >= 0; --index2) { Base3DElement base3Delement = base3DelementArray[index2]; base3Delement.Remove(); CanonicalTransform3D canonicalTransform3D = new CanonicalTransform3D(matrix3DArray[index2] * matrix3D); base3Delement.Transform = (Transform3D)canonicalTransform3D.ToTransform(); if (parentElement is Base3DElement) { GroupCommandHelpers.InsertElement(this.SceneViewModel, (Base3DElement)parentElement, (SceneNode)base3Delement, new int?(insertAt)); } else { GroupCommandHelpers.InsertElement(parentElement, (SceneNode)base3Delement, insertAt); } } if (flag) { ModelVisual3DElement modelVisual3Delement2 = parentElement as ModelVisual3DElement; base3DelementArray[index1].Remove(); CanonicalTransform3D canonicalTransform3D = new CanonicalTransform3D(matrix3DArray[index1] * matrix3D); base3DelementArray[index1].Transform = (Transform3D)canonicalTransform3D.ToTransform(); ModelVisual3DElement modelVisual3Delement3 = (ModelVisual3DElement)this.SceneViewModel.CreateSceneNode(typeof(ModelVisual3D)); modelVisual3Delement2.Children.Add((Visual3DElement)modelVisual3Delement3); modelVisual3Delement3.Content = (SceneNode)base3DelementArray[index1]; } } return((SceneNode[])base3DelementArray); }