public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitReleaseCompoundPath))
     {
         SceneElementSelectionSet   elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
         ICollection <SceneElement> collection          = (ICollection <SceneElement>)elementSelectionSet.Selection;
         elementSelectionSet.Clear();
         SceneElementCollection elementCollection = new SceneElementCollection();
         foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)collection)
         {
             PathElement pathElement1 = sceneElement as PathElement;
             if (ReleaseCompoundPathCommand.GetFigureCount(pathElement1) > 1)
             {
                 foreach (PathElement pathElement2 in PathCommandHelper.ReleaseCompoundPaths(pathElement1, editTransaction))
                 {
                     elementCollection.Add((SceneElement)pathElement2);
                 }
             }
             else
             {
                 elementCollection.Add(sceneElement);
             }
         }
         elementSelectionSet.SetSelection((ICollection <SceneElement>)elementCollection, (SceneElement)null);
         editTransaction.Commit();
     }
 }
        private void GetClipperAndElementToBeClipped(SceneElementSelectionSet selectionSet, out SceneElement clipper, out SceneElement elementToBeClipped)
        {
            clipper            = (SceneElement)null;
            elementToBeClipped = (SceneElement)null;
            SceneElement primarySelection = selectionSet.PrimarySelection;

            if (selectionSet.Count == 1)
            {
                if (!this.CanBeClipper(primarySelection))
                {
                    return;
                }
                clipper = primarySelection;
            }
            else
            {
                SceneElement element = selectionSet.Selection[0] == primarySelection ? selectionSet.Selection[1] : selectionSet.Selection[0];
                if (this.CanBeClipper(primarySelection) && this.CanBeClipped(element))
                {
                    clipper            = primarySelection;
                    elementToBeClipped = element;
                }
                else
                {
                    if (!this.CanBeClipper(element) || !this.CanBeClipped(primarySelection))
                    {
                        return;
                    }
                    clipper            = element;
                    elementToBeClipped = primarySelection;
                }
            }
        }
Beispiel #3
0
        private void AmbientPropertyReferenceChanged(object sender, PropertyReferenceChangedEventArgs e)
        {
            SceneElementSelectionSet elementSelectionSet = this.designerContext.SelectionManager.ElementSelectionSet;

            if (elementSelectionSet == null || elementSelectionSet.PrimarySelection == null)
            {
                return;
            }
            this.UpdateAmbientValueFromSceneElement(elementSelectionSet.PrimarySelection, new PropertyReference(e.PropertyReference[0]));
        }
        internal static bool IsGrouping2D(SceneViewModel model)
        {
            SceneElementSelectionSet elementSelectionSet = model.ElementSelectionSet;

            if (elementSelectionSet.Count > 0)
            {
                return(elementSelectionSet.PrimarySelection is Base2DElement);
            }
            return(false);
        }
Beispiel #5
0
        public override void Select()
        {
            SceneElementSelectionSet elementSelectionSet = this.TimelineItemManager.ViewModel.ElementSelectionSet;

            if (!this.IsSelectable)
            {
                elementSelectionSet.Clear();
            }
            else
            {
                elementSelectionSet.SetSelection((SceneElement)this.StyleNode);
            }
        }
        public override void Select()
        {
            SelectionManagerPerformanceHelper.MeasurePerformanceUntilPipelinePostSceneUpdate(this.TimelineItemManager.ViewModel.DesignerContext.SelectionManager, PerformanceEvent.SelectElement);
            SceneElementSelectionSet elementSelectionSet = this.TimelineItemManager.ViewModel.ElementSelectionSet;

            if (!this.IsSelectable)
            {
                elementSelectionSet.Clear();
            }
            else
            {
                elementSelectionSet.SetSelection(this.Element);
            }
        }
Beispiel #7
0
        private SceneElement GetSelection()
        {
            SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel;

            if (activeSceneViewModel != null && activeSceneViewModel.IsEditable && activeSceneViewModel.DefaultView.IsDesignSurfaceVisible)
            {
                SceneElementSelectionSet elementSelectionSet = activeSceneViewModel.ElementSelectionSet;
                if (elementSelectionSet.Count == 1 && (elementSelectionSet.Selection[0] is BaseFrameworkElement || elementSelectionSet.Selection[0] is UIElement3DElement))
                {
                    return(elementSelectionSet.Selection[0]);
                }
            }
            return((SceneElement)null);
        }
Beispiel #8
0
        protected void FlipElements(BasisComponent basisComponent, string description)
        {
            SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
            PropertyReference        propertyReference   = (PropertyReference)null;

            foreach (SceneElement sceneElement in elementSelectionSet.Selection)
            {
                if (sceneElement is BaseFrameworkElement || sceneElement is StyleNode)
                {
                    propertyReference = new PropertyReference((ReferenceStep)sceneElement.ProjectContext.ResolveProperty(Base2DElement.RenderTransformProperty));
                    break;
                }
                if (sceneElement is Base3DElement)
                {
                    propertyReference = new PropertyReference((ReferenceStep)sceneElement.ProjectContext.ResolveProperty((sceneElement as Base3DElement).TransformPropertyId));
                    break;
                }
            }
            if (propertyReference == null)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(description))
            {
                foreach (SceneElement sceneElement in elementSelectionSet.Selection)
                {
                    object             computedValueAsWpf = sceneElement.GetComputedValueAsWpf(propertyReference);
                    object             obj = new ReflectTransform(basisComponent).ApplyRelativeTransform(computedValueAsWpf);
                    CanonicalTransform canonicalTransform = obj as CanonicalTransform;
                    if (canonicalTransform != (CanonicalTransform)null)
                    {
                        sceneElement.SetValue(propertyReference, canonicalTransform.GetPlatformTransform(sceneElement.Platform.GeometryHelper));
                        if (sceneElement.IsSet(Base2DElement.RenderTransformOriginProperty) == PropertyState.Unset)
                        {
                            sceneElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)new Point(0.5, 0.5));
                        }
                    }
                    else
                    {
                        CanonicalTransform3D canonicalTransform3D = obj as CanonicalTransform3D;
                        if (canonicalTransform3D != (CanonicalTransform3D)null)
                        {
                            sceneElement.SetValue(propertyReference, (object)canonicalTransform3D.ToTransform());
                        }
                    }
                }
                editTransaction.Commit();
            }
        }
Beispiel #9
0
 private void ViewModel_EarlySceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
 {
     if (this.IsSuspended)
     {
         return;
     }
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ElementSelection))
     {
         SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
         BaseFrameworkElement     frameworkElement    = (BaseFrameworkElement)null;
         if (elementSelectionSet != null && elementSelectionSet.PrimarySelection != null && TextEditProxyFactory.IsEditableElement(elementSelectionSet.PrimarySelection))
         {
             frameworkElement = elementSelectionSet.PrimarySelection as BaseFrameworkElement;
         }
         if (this.TextSource != frameworkElement)
         {
             this.PopSelfOrExitEditMode();
             return;
         }
     }
     if (this.editProxy == null)
     {
         return;
     }
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.EntireScene))
     {
         foreach (DocumentNodeChange change in args.DocumentChanges.DistinctChanges)
         {
             if ((change.ParentNode == this.TextSource.DocumentNode || change.OldChildNode == this.TextSource.DocumentNode) && !this.editProxy.IsTextChange(change))
             {
                 this.PopSelfOrExitEditMode();
                 return;
             }
         }
     }
     foreach (DocumentNodeChange change in args.DocumentChanges.DistinctChanges)
     {
         if ((change.ParentNode == this.TextSource.DocumentNode || change.OldChildNode == this.TextSource.DocumentNode) && this.editProxy.IsTextChange(change))
         {
             this.editProxy.ApplyPropertyChange(change);
             this.textChangesApplied = true;
         }
     }
     if (!this.editProxy.TextSource.IsViewObjectValid)
     {
         return;
     }
     this.SetIsTextEditingProperty(this.editProxy.TextSource, true);
 }
Beispiel #10
0
        public override void Execute()
        {
            SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;

            using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.show ? StringTable.UndoUnitShow : StringTable.UndoUnitHide))
            {
                foreach (SceneElement sceneElement in elementSelectionSet.Selection)
                {
                    if (sceneElement.CanHide)
                    {
                        sceneElement.IsHidden = !this.show;
                    }
                }
                editTransaction.Commit();
            }
        }
Beispiel #11
0
        public override void Execute()
        {
            SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;

            using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitLock))
            {
                foreach (SceneElement sceneElement in elementSelectionSet.Selection)
                {
                    if (sceneElement.CanLock)
                    {
                        sceneElement.IsLocked = this.locked;
                    }
                }
                editTransaction.Commit();
            }
        }
Beispiel #12
0
        private void SetCameraTypeOnSelection(Type cameraType)
        {
            if (this.selectedCameras.Count == 0 || this.cameraType.Equals((object)cameraType))
            {
                return;
            }
            this.cameraType = (object)cameraType;
            SceneViewModel           viewModel           = this.selectedCameras[0].ViewModel;
            SceneElementSelectionSet elementSelectionSet = viewModel.ElementSelectionSet;

            using (SceneEditTransaction editTransaction = viewModel.Document.CreateEditTransaction(StringTable.UndoUnitChangeCameraType))
            {
                foreach (ProjectionCameraElement projectionCameraElement1 in this.selectedCameras)
                {
                    if (!(projectionCameraElement1.TargetType == cameraType))
                    {
                        ProjectionCameraElement projectionCameraElement2;
                        if (typeof(OrthographicCamera).IsAssignableFrom(cameraType))
                        {
                            projectionCameraElement2 = (ProjectionCameraElement)OrthographicCameraElement.Factory.Instantiate(projectionCameraElement1.ViewModel);
                            projectionCameraElement2.SetValue(OrthographicCameraElement.WidthProperty, (object)10.0);
                        }
                        else if (typeof(PerspectiveCamera).IsAssignableFrom(cameraType))
                        {
                            projectionCameraElement2 = (ProjectionCameraElement)PerspectiveCameraElement.Factory.Instantiate(projectionCameraElement1.ViewModel);
                            projectionCameraElement2.SetValue(PerspectiveCameraElement.FieldOfViewProperty, (object)45.0);
                        }
                        else
                        {
                            continue;
                        }
                        projectionCameraElement1.ViewModel.AnimationEditor.DeleteAllAnimations((SceneNode)projectionCameraElement1);
                        Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)projectionCameraElement1);
                        elementSelectionSet.RemoveSelection((SceneElement)projectionCameraElement1);
                        SceneElement parentElement = projectionCameraElement1.ParentElement;
                        ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)parentElement.GetPropertyForChild((SceneNode)projectionCameraElement1));
                        int index = collectionForProperty.IndexOf((SceneNode)projectionCameraElement1);
                        collectionForProperty[index] = (SceneNode)projectionCameraElement2;
                        SceneElementHelper.ApplyProperties((SceneNode)projectionCameraElement2, properties);
                        elementSelectionSet.ExtendSelection((SceneElement)projectionCameraElement2);
                    }
                }
                editTransaction.Commit();
            }
            this.OnPropertyChanged("IsCameraOrthographic");
            this.OnPropertyChanged("IsCameraPerspective");
        }
        private SceneElement GetAnimationTarget(SceneElementSelectionSet selection)
        {
            SceneElement sceneElement = (SceneElement)null;

            if (selection.Count == 2)
            {
                SceneElement primarySelection = selection.PrimarySelection;
                SceneElement element          = selection.Selection[0] == primarySelection ? selection.Selection[1] : selection.Selection[0];
                if (PathConversionHelper.CanConvert(element))
                {
                    sceneElement = primarySelection;
                }
                else if (PathConversionHelper.CanConvert(primarySelection))
                {
                    sceneElement = element;
                }
            }
            return(sceneElement);
        }
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeCompoundPath))
     {
         SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
         List <PathElement>       otherElements       = new List <PathElement>();
         foreach (SceneElement element in elementSelectionSet.Selection)
         {
             PathElement pathElement = element as PathElement;
             if (pathElement != null)
             {
                 otherElements.Add(pathElement);
             }
             else if (PathConversionHelper.CanConvert(element))
             {
                 otherElements.Add(PathCommandHelper.ConvertToPath((BaseFrameworkElement)element));
             }
         }
         editTransaction.Update();
         this.DesignerContext.ActiveView.UpdateLayout();
         otherElements.Sort((IComparer <PathElement>) new ZOrderComparer <PathElement>(this.SceneViewModel.RootNode));
         elementSelectionSet.Clear();
         PathElement                      mainElement        = otherElements[0];
         BaseFrameworkElement             frameworkElement   = (BaseFrameworkElement)otherElements[otherElements.Count - 1];
         ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement);
         int       num       = collectionForChild.IndexOf((SceneNode)frameworkElement);
         SceneNode sceneNode = num + 1 < collectionForChild.Count ? collectionForChild[num + 1] : (SceneNode)null;
         otherElements.RemoveAt(0);
         PathCommandHelper.MakeCompoundPath(mainElement, otherElements, editTransaction);
         mainElement.Remove();
         if (sceneNode == null)
         {
             collectionForChild.Add((SceneNode)mainElement);
         }
         else
         {
             collectionForChild.Insert(collectionForChild.IndexOf(sceneNode), (SceneNode)mainElement);
         }
         elementSelectionSet.SetSelection((SceneElement)mainElement);
         editTransaction.Commit();
     }
 }
Beispiel #15
0
        private void EditDifferentElement(BaseFrameworkElement element)
        {
            this.EndTextEdit();
            if (element != null && !TextEditProxyFactory.IsEditableElement((SceneElement)element))
            {
                element = (BaseFrameworkElement)null;
            }
            bool flag1 = false;

            if (element != null && element.IsViewObjectValid)
            {
                SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
                if (elementSelectionSet != null)
                {
                    elementSelectionSet.SetSelection((SceneElement)element);
                }
                flag1 = true;
                this.BeginTextEdit(element);
            }
            TextSelectionSet textSelectionSet = this.ActiveSceneViewModel.TextSelectionSet;
            bool             flag2            = false;

            if (textSelectionSet != null)
            {
                flag2 = this.ActiveSceneViewModel.TextSelectionSet.IsActive;
                int num = flag1 ? true : false;
                textSelectionSet.TextEditProxy = this.editProxy;
                textSelectionSet.IsActive      = flag1;
            }
            if (flag1 != flag2)
            {
                this.ActiveSceneViewModel.RefreshSelection();
            }
            if (flag1)
            {
                return;
            }
            this.ActiveView.ReturnFocus();
        }
Beispiel #16
0
        private void SelectionManager_LateActiveSceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
        {
            this.designerContext.ResourceManager.OnSceneUpdate(args);
            TextSelectionSet         textSelectionSet    = this.designerContext.SelectionManager.TextSelectionSet;
            SceneElementSelectionSet elementSelectionSet = this.designerContext.SelectionManager.ElementSelectionSet;

            if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.IsEditable | SceneViewModel.ViewStateBits.ActiveTrigger | SceneViewModel.ViewStateBits.ActiveTimeline | SceneViewModel.ViewStateBits.ElementSelection | SceneViewModel.ViewStateBits.TextSelection | SceneViewModel.ViewStateBits.KeyFrameSelection | SceneViewModel.ViewStateBits.AnimationSelection | SceneViewModel.ViewStateBits.StoryboardSelection | SceneViewModel.ViewStateBits.CurrentValues | SceneViewModel.ViewStateBits.ChildPropertySelection | SceneViewModel.ViewStateBits.BehaviorSelection))
            {
                this.FireAllPropertyChangedEvents(args);
            }
            else
            {
                if (args.DocumentChanges.Count <= 0)
                {
                    return;
                }
                foreach (DocumentNodeChange documentNodeChange in args.DocumentChanges.DistinctChanges)
                {
                    if (documentNodeChange.ParentNode != null && documentNodeChange.ParentNode.TargetType == typeof(DictionaryEntry))
                    {
                        this.FireAllPropertyChangedEvents(args);
                        return;
                    }
                }
                this.changedPropertyReferences = new List <PropertyReference>();
                foreach (SceneChange sceneChange in SceneChange.ChangesOfType <SceneChange>(args.DocumentChanges, args.ViewModel.RootNode))
                {
                    if (sceneChange is StyleSceneChange)
                    {
                        this.FireAllPropertyChangedEvents(args);
                        return;
                    }
                }
                this.FireSelectivePropertyChangedEvents(args);
            }
        }
Beispiel #17
0
        public static void ConvertSelectionToPathIfNeeded(SceneElementSelectionSet sceneSelectionSet, SceneElementFilter isConversionNeeded)
        {
            ReadOnlyCollection <SceneElement> selection = sceneSelectionSet.Selection;
            SceneElement primarySelection1 = sceneSelectionSet.PrimarySelection;
            SceneElement primarySelection2 = (SceneElement)null;

            sceneSelectionSet.Clear();
            List <SceneElement> list = new List <SceneElement>(selection.Count);

            foreach (SceneElement element in selection)
            {
                SceneElement sceneElement = element;
                if (isConversionNeeded(element))
                {
                    sceneElement = (SceneElement)PathCommandHelper.ConvertToPath((BaseFrameworkElement)element);
                }
                if (element == primarySelection1)
                {
                    primarySelection2 = sceneElement;
                }
                list.Add(sceneElement);
            }
            sceneSelectionSet.SetSelection((ICollection <SceneElement>)list, primarySelection2);
        }
Beispiel #18
0
 public static void ConvertSelectionToPath(SceneElementSelectionSet sceneSelectionSet)
 {
     PathCommandHelper.ConvertSelectionToPathIfNeeded(sceneSelectionSet, (SceneElementFilter)(element => true));
 }
 private void SelectionManager_LateActiveSceneUpdatePhase(object sender, SceneUpdatePhaseEventArgs args)
 {
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ActiveEditingContainer) || args.IsDirtyViewState(SceneViewModel.ViewStateBits.IsEditable))
     {
         this.UpdateFromEditingContainerChange(false);
     }
     this.triggerSubscription.Update(args.ViewModel, args.DocumentChanges, args.DocumentChangeStamp);
     foreach (SubSubscription subSubscription in this.delayedUpdates)
     {
         subSubscription.ProcessChanges(args.DocumentChangeStamp);
     }
     this.delayedUpdates.Clear();
     if (args.IsDirtyViewState(SceneViewModel.ViewStateBits.ActiveTrigger | SceneViewModel.ViewStateBits.RecordMode) && this.ActiveSceneViewModel != null)
     {
         this.UpdateActiveTrigger();
         if (this.SelectedItem == null || this.SelectedItem is NoneTriggerModel)
         {
             if (this.locked3DElements.Count != 0)
             {
                 using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction("Unlock3DElements", true))
                 {
                     SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
                     if (elementSelectionSet != null && this.selectionChangesSinceLock <= 2)
                     {
                         foreach (Base3DElement base3Delement in this.locked3DElements)
                         {
                             if (base3Delement.IsAttached)
                             {
                                 elementSelectionSet.ExtendSelection((SceneElement)base3Delement);
                             }
                         }
                     }
                     editTransaction.Commit();
                 }
                 this.locked3DElements.Clear();
             }
         }
         else if (this.locked3DElements.Count == 0)
         {
             this.selectionChangesSinceLock = 0;
             SceneElementSelectionSet elementSelectionSet = this.ActiveSceneViewModel.ElementSelectionSet;
             if (elementSelectionSet != null)
             {
                 using (SceneEditTransaction editTransaction = this.ActiveSceneViewModel.CreateEditTransaction("Lock3DElements", true))
                 {
                     foreach (SceneElement sceneElement in elementSelectionSet.Selection)
                     {
                         Base3DElement base3Delement = sceneElement as Base3DElement;
                         if (base3Delement != null)
                         {
                             this.locked3DElements.Add(base3Delement);
                             elementSelectionSet.RemoveSelection((SceneElement)base3Delement);
                         }
                     }
                     editTransaction.Commit();
                 }
             }
         }
     }
     if (!args.IsDirtyViewState(SceneViewModel.ViewStateBits.ElementSelection))
     {
         return;
     }
     ++this.selectionChangesSinceLock;
 }
Beispiel #20
0
        private void SetLightTypeOnSelection(Type lightType)
        {
            if (this.selectedLights.Count == 0 || this.lightType != null && this.lightType.Equals((object)lightType))
            {
                return;
            }
            this.lightType = (object)lightType;
            SceneViewModel           viewModel                     = this.selectedLights[0].ViewModel;
            SceneElementSelectionSet elementSelectionSet           = viewModel.ElementSelectionSet;
            List <KeyValuePair <LightElement, LightElement> > list = new List <KeyValuePair <LightElement, LightElement> >();

            foreach (LightElement key in (IEnumerable <LightElement>)elementSelectionSet.GetFilteredSelection <LightElement>())
            {
                if (!(key.TargetType == lightType))
                {
                    LightElement lightElement = (LightElement)key.ViewModel.CreateSceneNode(lightType);
                    DocumentNode documentNode = (DocumentNode)null;
                    if (typeof(SpotLight).Equals(lightType))
                    {
                        DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(SpotLightElement.DirectionProperty);
                        documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                    }
                    else if (typeof(DirectionalLight).Equals(lightType))
                    {
                        DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(DirectionalLightElement.DirectionProperty);
                        documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                    }
                    if (typeof(DirectionalLight).Equals(lightType))
                    {
                        if (documentNode != null)
                        {
                            lightElement.SetValue(DirectionalLightElement.DirectionProperty, (object)documentNode);
                        }
                    }
                    else if (typeof(PointLightBase).IsAssignableFrom(lightType))
                    {
                        if (!typeof(PointLightBase).IsAssignableFrom(key.TargetType))
                        {
                            lightElement.SetValue(LightElement.PositionProperty, (object)new Point3D(0.0, 0.0, 0.0));
                            lightElement.SetValue(LightElement.RangeProperty, (object)10.0);
                            lightElement.SetValue(LightElement.ConstantAttenuationProperty, (object)1.0);
                            lightElement.SetValue(LightElement.LinearAttenuationProperty, (object)0.0);
                            lightElement.SetValue(LightElement.QuadraticAttenuationProperty, (object)0.0);
                        }
                        if (typeof(SpotLight).Equals(lightType))
                        {
                            if (documentNode != null)
                            {
                                lightElement.SetValue(SpotLightElement.DirectionProperty, (object)documentNode);
                            }
                            lightElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)40.0);
                            lightElement.SetValue(SpotLightElement.InnerConeAngleProperty, (object)30.0);
                        }
                    }
                    list.Add(new KeyValuePair <LightElement, LightElement>(key, lightElement));
                }
            }
            if (list.Count != 0)
            {
                using (SceneEditTransaction editTransaction = viewModel.Document.CreateEditTransaction(StringTable.UndoUnitChangeLightType))
                {
                    foreach (KeyValuePair <LightElement, LightElement> keyValuePair in list)
                    {
                        LightElement key          = keyValuePair.Key;
                        LightElement lightElement = keyValuePair.Value;
                        viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)key);
                        Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)key);
                        elementSelectionSet.RemoveSelection((SceneElement)key);
                        SceneElement parentElement = key.ParentElement;
                        ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)parentElement.GetPropertyForChild((SceneNode)key));
                        int index = collectionForProperty.IndexOf((SceneNode)key);
                        collectionForProperty[index] = (SceneNode)lightElement;
                        SceneElementHelper.ApplyProperties((SceneNode)lightElement, properties);
                        elementSelectionSet.ExtendSelection((SceneElement)lightElement);
                    }
                    editTransaction.Commit();
                }
            }
            this.OnPropertyChanged("IsAmbientLight");
            this.OnPropertyChanged("IsPointLight");
            this.OnPropertyChanged("IsDirectionalLight");
            this.OnPropertyChanged("IsSpotLight");
        }
Beispiel #21
0
        public override void Draw(DrawingContext drawingContext, Matrix matrix)
        {
            if (!this.ShouldDraw)
            {
                return;
            }
            SceneElementSelectionSet elementSelectionSet = this.DesignerContext.ActiveSceneViewModel.ElementSelectionSet;
            AdornerLayer             adornerLayer        = this.DesignerContext.ActiveView.AdornerLayer;
            Tool      adornerOwnerTool = this.DesignerContext.ToolManager.ActiveTool.AdornerOwnerTool;
            SceneView activeView       = this.DesignerContext.ActiveView;
            Transform transform        = activeView.Artboard.CalculateTransformFromContentToArtboard();
            bool      flag1            = this.ElementSet.AdornsMultipleElements && (adornerOwnerTool.GetSelectionAdornerUsages((SceneElement)null) & SelectionAdornerUsages.ShowBoundingBox) != SelectionAdornerUsages.None;
            bool      flag2            = false;
            bool      flag3            = true;
            Rect      rectangle        = new Rect();

            foreach (SceneElement element in this.ElementSet.Elements)
            {
                IViewObject viewTargetElement = element.ViewTargetElement;
                if (!(element is Base3DElement) && !element.IsHiddenOrCollapsedOrAncestorHiddenOrCollapsed && (viewTargetElement != null && element.Visual != null))
                {
                    Rect actualBounds = this.DesignerContext.ActiveView.GetActualBounds(viewTargetElement);
                    bool flag4        = element == this.ElementSet.PrimaryElement;
                    if ((adornerOwnerTool.GetSelectionAdornerUsages(element) & SelectionAdornerUsages.ShowBoundingBox) != SelectionAdornerUsages.None && this.ElementSet.Elements.Count < 100 || flag4)
                    {
                        Pen pen = flag4 ? this.MediumPen : this.BorderPen;
                        System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(this.DesignerContext.ActiveView, element, actualBounds, pen.Thickness, true);
                        drawingContext.DrawGeometry((Brush)null, pen, rectangleGeometry);
                    }
                    if (flag1)
                    {
                        Rect rect1 = activeView.TransformBounds(element.Visual, (IViewObject)activeView.HitTestRoot, actualBounds);
                        Rect rect2 = transform.TransformBounds(rect1);
                        if (!flag2)
                        {
                            flag2 = Adorner.NonAffineTransformInParentStack(element);
                        }
                        if (flag3)
                        {
                            rectangle = rect2;
                            flag3     = false;
                        }
                        else
                        {
                            rectangle.Union(rect2);
                        }
                    }
                }
            }
            if (!flag1)
            {
                return;
            }
            if (flag2)
            {
                rectangle.Inflate(this.MediumPen.Thickness / 2.0, this.MediumPen.Thickness / 2.0);
                drawingContext.DrawRectangle((Brush)null, this.MediumPen, rectangle);
            }
            else
            {
                System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(this.ElementSet.ElementBounds, this.ElementSet.GetTransformMatrixToAdornerLayer(), this.MediumPen.Thickness);
                drawingContext.DrawGeometry((Brush)null, this.MediumPen, rectangleGeometry);
            }
        }
Beispiel #22
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.undoDescription))
     {
         this.ConvertSelectedElementsToPathIfNecessary();
         editTransaction.Update();
         this.SceneViewModel.DefaultView.UpdateLayout();
         SceneElementSelectionSet      elementSelectionSet   = this.SceneViewModel.ElementSelectionSet;
         SceneElement                  primarySelection      = elementSelectionSet.PrimarySelection;
         System.Windows.Media.Geometry renderedGeometryAsWpf = this.SceneView.GetRenderedGeometryAsWpf(primarySelection);
         if (renderedGeometryAsWpf == null)
         {
             return;
         }
         this.Initialize(renderedGeometryAsWpf);
         SceneElementCollection elementCollection = new SceneElementCollection();
         foreach (SceneElement shapeElement in elementSelectionSet.Selection)
         {
             if (shapeElement != primarySelection)
             {
                 elementCollection.Add(shapeElement);
                 System.Windows.Media.Geometry secondaryGeometry = this.SceneView.GetRenderedGeometryAsWpf(shapeElement);
                 if (secondaryGeometry == null)
                 {
                     return;
                 }
                 Matrix transformToElement = shapeElement.GetComputedTransformToElement(primarySelection);
                 if (!transformToElement.IsIdentity)
                 {
                     MatrixTransform matrixTransform = new MatrixTransform(transformToElement);
                     matrixTransform.Freeze();
                     GeometryGroup geometryGroup = new GeometryGroup();
                     geometryGroup.Children.Add(secondaryGeometry);
                     geometryGroup.Transform = (Transform)matrixTransform;
                     secondaryGeometry       = (System.Windows.Media.Geometry)geometryGroup;
                 }
                 this.Combine(secondaryGeometry);
             }
         }
         PathGeometry result = this.GetResult();
         BooleanCommand.CleanUpPathGeometry(ref result);
         PathGeometry pathGeometry = PathConversionHelper.RemoveDegeneratePoints((System.Windows.Media.Geometry)result);
         elementSelectionSet.Clear();
         PathGeometryUtilities.CollapseSingleSegmentsToPolySegments(pathGeometry);
         PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path);
         Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null;
         using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
         {
             this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(primarySelection);
             properties = SceneElementHelper.StoreProperties((SceneNode)primarySelection);
             ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer();
             int index = collectionContainer.IndexOf((SceneNode)primarySelection);
             collectionContainer[index] = (SceneNode)pathElement;
         }
         foreach (SceneElement element in elementCollection)
         {
             this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
             element.Remove();
         }
         using (this.SceneViewModel.ForceBaseValue())
         {
             if (properties != null)
             {
                 SceneElementHelper.ApplyProperties((SceneNode)pathElement, properties);
             }
             pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.Fill);
             PathCommandHelper.ReplacePathGeometry(pathElement, pathGeometry, editTransaction);
         }
         elementSelectionSet.SetSelection((SceneElement)pathElement);
         editTransaction.Commit();
     }
 }