Exemplo n.º 1
0
            private string GetCandidateName(SceneElement element)
            {
                if (element == null)
                {
                    return(string.Empty);
                }
                SceneNode         root = element.StoryboardContainer as SceneNode ?? this.view.ViewModel.RootNode;
                SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(element.ViewModel, root);
                string            namePrefix        = SceneNodeIDHelper.DefaultNamePrefixForType((ITypeId)element.Type);

                return(sceneNodeIdHelper.GetValidElementID((SceneNode)element, namePrefix));
            }
Exemplo n.º 2
0
        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);
        }