public override bool CopyToCompositeTransform(CompositeTransformNode compositeTransform)
        {
            if (!this.Platform.Metadata.IsCapabilitySet(PlatformCapability.SupportsCompositeTransform))
            {
                return(false);
            }
            ISceneNodeCollection <SceneNode> children = this.Children;

            if (children == null || children.Count == 0)
            {
                return(false);
            }
            if (children.Count == 1)
            {
                return(((TransformNode)children[0]).CopyToCompositeTransform(compositeTransform));
            }
            if (!this.IsCanonical)
            {
                return(false);
            }
            foreach (TransformNode transformNode in (IEnumerable <SceneNode>)children)
            {
                if (transformNode == null)
                {
                    return(false);
                }
                transformNode.CopyToCompositeTransform(compositeTransform);
            }
            return(true);
        }
Exemple #2
0
        private static Dictionary <IPropertyId, List <SceneNode> > StoreChildren(SceneElement sourceElement)
        {
            Dictionary <IPropertyId, List <SceneNode> > dictionary = new Dictionary <IPropertyId, List <SceneNode> >();

            foreach (IPropertyId propertyId in sourceElement.ContentProperties)
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = sourceElement.GetCollectionForProperty(propertyId);
                if (collectionForProperty != null)
                {
                    while (collectionForProperty.Count > 0)
                    {
                        SceneNode sceneNode = collectionForProperty[0];
                        if (sceneNode.DocumentNode != null)
                        {
                            DocumentNodeHelper.PreserveFormatting(sceneNode.DocumentNode);
                        }
                        sceneNode.Remove();
                        List <SceneNode> list = (List <SceneNode>)null;
                        if (!dictionary.TryGetValue(propertyId, out list))
                        {
                            list = new List <SceneNode>();
                            dictionary.Add(propertyId, list);
                        }
                        list.Add(sceneNode);
                    }
                }
            }
            return(dictionary);
        }
        internal void DeleteTriggerNode(SceneNodeProperty triggerProperty)
        {
            ISceneNodeCollection <SceneNode> collectionForProperty = this.behaviorNode.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
            SceneNode valueAsSceneNode = this.behaviorNode.GetLocalValueAsSceneNode(triggerProperty.Reference);
            int       position         = this.TriggerNodeView.CurrentPosition;
            int       num = this.TriggerNodes.IndexOf((PropertyEntry)triggerProperty);

            if (position > num)
            {
                --position;
            }
            else if (position == num)
            {
                position = -1;
            }
            using (SceneEditTransaction editTransaction = this.sceneViewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.DeleteBehaviorCommandTriggerUndo, new object[1]
            {
                (object)valueAsSceneNode.TargetType.Name
            })))
            {
                collectionForProperty.Remove(valueAsSceneNode);
                editTransaction.Commit();
            }
            this.Rebuild();
            this.TriggerNodeView.MoveCurrentToPosition(position);
        }
Exemple #4
0
        private void GenerateDataGridColumnsIfNeeded(DataGridElement dataGridElement, IProperty targetProperty)
        {
            if (!DataGridElement.ItemsSourceProperty.Equals((object)targetProperty) && !ItemsControlElement.ItemsSourceProperty.Equals((object)targetProperty) || this.DragModel.RelativeDropSchemaPath.IsProperty)
            {
                return;
            }
            IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths();

            if (relativeSchemaPaths.Count == 0)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitCreateTemplate))
            {
                dataGridElement.SetValue(DataGridElement.AutoGenerateColumnsProperty, (object)false);
                ISceneNodeCollection <SceneNode> columnCollection = dataGridElement.ColumnCollection;
                for (int index = 0; index < relativeSchemaPaths.Count; ++index)
                {
                    DataSchemaNodePath schemaPath = relativeSchemaPaths[index];
                    IType type = schemaPath.Type;
                    if (type.NullableType != null)
                    {
                        type = type.NullableType;
                    }
                    SceneNode sceneNode = !PlatformTypes.Boolean.IsAssignableFrom((ITypeId)type) ? (!PlatformTypes.IConvertible.IsAssignableFrom((ITypeId)type) ? this.CreateDataGridTemplateColumn(schemaPath) : this.CreateDataGridBoundColumn(schemaPath, ProjectNeutralTypes.DataGridTextColumn)) : this.CreateDataGridBoundColumn(schemaPath, ProjectNeutralTypes.DataGridCheckBoxColumn);
                    columnCollection.Add(sceneNode);
                }
                editTransaction.Commit();
            }
        }
Exemple #5
0
        public DocumentNode GetDocumentNodeValue(DocumentCompositeNode compositeNode, IPropertyId propertyKey, bool visualTriggerOnly)
        {
            DocumentNode documentNode = (DocumentNode)null;
            string       id           = this.GetID(compositeNode);

            if (id != null)
            {
                ISceneNodeCollection <SceneNode> setters = this.Setters;
                for (int index = setters.Count - 1; index >= 0; --index)
                {
                    DocumentCompositeNode setterNode = (DocumentCompositeNode)setters[index].DocumentNode;
                    if (this.IsSetter(setterNode, id, propertyKey))
                    {
                        documentNode = setterNode.Properties[SetterSceneNode.ValueProperty];
                        break;
                    }
                }
                if (visualTriggerOnly)
                {
                    return(documentNode);
                }
            }
            if (documentNode == null)
            {
                documentNode = compositeNode.Properties[propertyKey];
            }
            return(documentNode);
        }
Exemple #6
0
        public static void MoveStates(SceneElement source, SceneElement target)
        {
            if (source == null || target == null || source.ProjectContext.PlatformMetadata.IsNullType((ITypeId)source.ProjectContext.ResolveType(ProjectNeutralTypes.VisualStateManager)))
            {
                return;
            }
            IList <VisualStateGroupSceneNode> stateGroups = VisualStateManagerSceneNode.GetStateGroups((SceneNode)target);

            stateGroups.Clear();
            ISceneNodeCollection <SceneNode> collectionForProperty = source.GetCollectionForProperty(VisualStateManagerSceneNode.VisualStateGroupsProperty);
            List <VisualStateGroupSceneNode> list = new List <VisualStateGroupSceneNode>();

            foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)collectionForProperty)
            {
                if (sceneNode is VisualStateGroupSceneNode)
                {
                    list.Add((VisualStateGroupSceneNode)VisualStateGroupSceneNode.Factory.Instantiate(target.ViewModel, sceneNode.DocumentNode.Clone(target.DocumentContext)));
                }
            }
            collectionForProperty.Clear();
            foreach (VisualStateGroupSceneNode stateGroupSceneNode in list)
            {
                stateGroups.Add(stateGroupSceneNode);
            }
        }
Exemple #7
0
 private bool ReparentDraggedElements()
 {
     if (!this.InsertionPoint.IsEmpty)
     {
         IPropertyId pointChildProperty = this.GetInsertionPointChildProperty();
         if (pointChildProperty != null)
         {
             ISceneNodeCollection <SceneNode> collectionForProperty = this.InsertionPoint.Element.GetCollectionForProperty(pointChildProperty);
             if (collectionForProperty != null)
             {
                 this.AdjustIndexBeforeRemovingFromSceneView();
                 HashSet <BaseFrameworkElement> hashSet = new HashSet <BaseFrameworkElement>();
                 foreach (BaseFrameworkElement frameworkElement in this.DraggedElements)
                 {
                     hashSet.Add(frameworkElement);
                     frameworkElement.Remove();
                 }
                 this.Context.Transaction.UpdateEditTransaction();
                 this.AdjustIndexAfterRemovingFromSceneView();
                 foreach (BaseFrameworkElement frameworkElement in this.DraggedElements)
                 {
                     this.InsertionPoint.Insert(collectionForProperty, (SceneElement)frameworkElement);
                     ++this.InsertionPoint.Index;
                 }
                 this.Context.Transaction.UpdateEditTransaction();
                 this.AdjustLayoutAfterReparenting((ICollection <BaseFrameworkElement>)hashSet);
                 return(true);
             }
         }
     }
     return(false);
 }
 public SceneNodeModelItemCollection(ISceneNodeCollection <SceneNode> collection, SceneViewModel viewModel, SceneNode parent, IProperty property)
 {
     this.sceneNodeCollection = collection;
     this.viewModel           = viewModel;
     this.parent   = parent;
     this.property = property;
 }
Exemple #9
0
 public bool TryReplace(object source, SmartInsertionPoint insertionPoint, ISceneNodeCollection <SceneNode> destinationCollection)
 {
     if (insertionPoint != null && insertionPoint.SceneNode != null && (insertionPoint.SceneNode.ViewModel != null && destinationCollection != null) && destinationCollection.Count > 0 && destinationCollection.FixedCapacity.HasValue)
     {
         int?fixedCapacity = destinationCollection.FixedCapacity;
         int count         = destinationCollection.Count;
         if ((fixedCapacity.GetValueOrDefault() != count ? 0 : (fixedCapacity.HasValue ? true : false)) != 0)
         {
             this.IsReplacingChild = true;
             this.HideSplitter     = true;
             this.ReplacedChild    = destinationCollection[destinationCollection.Count - 1];
             SceneNode node  = source as SceneNode;
             Asset     asset = source as Asset;
             if (asset != null)
             {
                 node = asset.CreatePrototypeInstance((ISceneInsertionPoint)insertionPoint);
             }
             if (node != null && insertionPoint.ShouldNestContents(node))
             {
                 this.IsNestingContents = true;
             }
             return(true);
         }
     }
     return(false);
 }
 private void CleanConditionBehaviorReferences()
 {
     this.ClearConditionList();
     this.conditions = (ISceneNodeCollection <SceneNode>)null;
     this.conditionalExpressionNode = (ConditionalExpressionNode)null;
     this.conditionBehaviorNode     = (ConditionBehaviorNode)null;
 }
 public override void Insert(ISceneNodeCollection <SceneNode> children, SceneElement element)
 {
     if (this.Index > children.Count)
     {
         this.Index = children.Count;
     }
     children.Insert(this.Index, (SceneNode)element);
 }
Exemple #12
0
        public override void Execute()
        {
            BaseFrameworkElement selectedElement = this.SelectedElement;
            SceneViewModel       sceneViewModel1 = this.SceneViewModel;
            bool flag1 = true;
            BaseFrameworkElement frameworkElement = selectedElement;
            int             num1             = flag1 ? true : false;
            ILayoutDesigner designerForChild = sceneViewModel1.GetLayoutDesignerForChild((SceneElement)frameworkElement, num1 != 0);
            SceneNode       parent           = selectedElement.Parent;
            IProperty       propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement);
            ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild);
            int index = collectionForProperty.IndexOf((SceneNode)selectedElement);

            if (!BehaviorHelper.EnsureBlendSDKLibraryAssemblyReferenced(this.SceneViewModel, "Microsoft.Expression.Controls") || !ProjectContext.GetProjectContext(selectedElement.ProjectContext).IsTypeSupported(ProjectNeutralTypes.PathListBox))
            {
                return;
            }
            using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
            {
                SceneViewModel sceneViewModel2    = this.SceneViewModel;
                bool           flag2              = false;
                string         unitMakeLayoutPath = StringTable.UndoUnitMakeLayoutPath;
                int            num2 = flag2 ? true : false;
                using (SceneEditTransaction editTransaction = sceneViewModel2.CreateEditTransaction(unitMakeLayoutPath, num2 != 0))
                {
                    using (this.SceneViewModel.ForceBaseValue())
                    {
                        using (this.SceneViewModel.DisableDrawIntoState())
                        {
                            this.SceneViewModel.ElementSelectionSet.Clear();
                            Rect childRect = designerForChild.GetChildRect(selectedElement);
                            selectedElement.EnsureNamed();
                            PathListBoxElement pathListBoxElement = (PathListBoxElement)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.PathListBox);
                            LayoutPathNode     layoutPathNode     = (LayoutPathNode)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath);
                            BindingSceneNode   bindingSceneNode   = (BindingSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Binding);
                            bindingSceneNode.ElementName = selectedElement.Name;
                            layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode);
                            pathListBoxElement.LayoutPaths.Add((SceneNode)layoutPathNode);
                            if (!collectionForProperty.FixedCapacity.HasValue || collectionForProperty.Count < collectionForProperty.FixedCapacity.Value)
                            {
                                collectionForProperty.Insert(index, (SceneNode)pathListBoxElement);
                            }
                            else
                            {
                                GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid);
                                collectionForProperty[index] = (SceneNode)gridElement;
                                gridElement.Children.Add((SceneNode)pathListBoxElement);
                                gridElement.Children.Add((SceneNode)selectedElement);
                            }
                            editTransaction.Update();
                            designerForChild.SetChildRect((BaseFrameworkElement)pathListBoxElement, childRect);
                            this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)pathListBoxElement);
                            editTransaction.Commit();
                        }
                    }
                }
            }
        }
Exemple #13
0
 internal void ShowSplitAdorner(bool showFeedback, TimelineDragDescriptor descriptor)
 {
     if (showFeedback && descriptor != null && (descriptor.TargetItem != null && !descriptor.HideSplitter))
     {
         TimelineItem timelineItem = (TimelineItem)null;
         bool         flag         = false;
         double       num1         = 0.0;
         if (descriptor.AllowBetween)
         {
             timelineItem = descriptor.TargetItem;
             flag         = (descriptor.ResultDropEffects & TimelineDropEffects.Before) != TimelineDropEffects.None;
             num1         = (double)(timelineItem.Depth + descriptor.RelativeDepth);
         }
         else if (descriptor.TargetItem.IsExpanded && descriptor.DropInDefaultContent)
         {
             ElementTimelineItem elementTimelineItem = descriptor.TargetItem as ElementTimelineItem;
             if (elementTimelineItem != null)
             {
                 ISceneNodeCollection <SceneNode> defaultContent = elementTimelineItem.Element.DefaultContent;
                 if (defaultContent != null)
                 {
                     if (defaultContent.Count > 0 && !this.TimelineItemManager.SortByZOrder)
                     {
                         flag = true;
                         num1 = (double)(descriptor.TargetItem.Depth + 1);
                         int index = this.TimelineItemManager.ItemList.IndexOf((TimelineItem)elementTimelineItem);
                         int count = this.TimelineItemManager.ItemList.Count;
                         while (index < count - 1 && (double)this.TimelineItemManager.ItemList[index + 1].Depth >= num1)
                         {
                             ++index;
                         }
                         timelineItem = this.TimelineItemManager.ItemList[index];
                     }
                     else
                     {
                         timelineItem = descriptor.TargetItem;
                         flag         = true;
                         num1         = (double)(timelineItem.Depth + 1);
                     }
                 }
             }
         }
         if (timelineItem != null)
         {
             Point  point            = ((Visual)this.ElementTree.ItemContainerGenerator.ContainerFromItem((object)timelineItem)).TransformToVisual((Visual)this).Transform(new Point(0.0, 0.0));
             bool   sortByZorder     = this.TimelineItemManager.SortByZOrder;
             double indentMultiplier = this.IndentMultiplier;
             double left             = num1 * this.IndentMultiplier + point.X + indentMultiplier;
             double num2             = (double)((int)(this.DropSplitAdorner.ActualHeight - 1.0) / 2);
             double num3             = (double)this.Resources[(object)"RowMinHeight"];
             double top = point.Y - num2 + (sortByZorder ^ flag ? num3 : 0.0);
             this.DropSplitAdorner.Margin     = new Thickness(left, top, 0.0, 0.0);
             this.DropSplitAdorner.Visibility = Visibility.Visible;
             return;
         }
     }
     this.DropSplitAdorner.Visibility = Visibility.Collapsed;
 }
Exemple #14
0
        public static SceneNode CreateTrigger(SceneNode targetNode, IType triggerType)
        {
            ProjectContext projectContext = ProjectContext.GetProjectContext(targetNode.ProjectContext);

            BehaviorHelper.EnsureSystemWindowsInteractivityReferenced((ITypeResolver)projectContext);
            targetNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            using (SceneEditTransaction editTransaction = targetNode.ViewModel.CreateEditTransaction(StringTable.CreateTriggerActionUndoString))
            {
                SceneNode sceneNode1 = targetNode;
                ISceneNodeCollection <SceneNode> collectionForProperty   = sceneNode1.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
                BehaviorTriggerBaseNode          behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)null;
                SceneViewModel viewModel        = targetNode.ViewModel;
                object         triggerAttribute = BehaviorHelper.CreateTriggerFromDefaultTriggerAttribute((IEnumerable)TypeUtilities.GetAttributes(triggerType.RuntimeType), targetNode.TargetType);
                if (triggerAttribute != null)
                {
                    behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.CreateSceneNode(triggerAttribute);
                }
                if (behaviorTriggerBaseNode == null)
                {
                    BehaviorEventTriggerNode eventTriggerNode = (BehaviorEventTriggerNode)sceneNode1.ViewModel.CreateSceneNode(ProjectNeutralTypes.BehaviorEventTrigger);
                    string result;
                    if (!PlatformNeutralAttributeHelper.TryGetAttributeValue <string>(targetNode.TargetType, PlatformTypes.DefaultEventAttribute, "Name", out result))
                    {
                        result = "Loaded";
                    }
                    eventTriggerNode.EventName = result;
                    behaviorTriggerBaseNode    = (BehaviorTriggerBaseNode)eventTriggerNode;
                }
                bool flag = false;
                viewModel.BehaviorSelectionSet.Clear();
                foreach (SceneNode sceneNode2 in (IEnumerable <SceneNode>)collectionForProperty)
                {
                    if (BehaviorHelper.CompareTriggerNodes(behaviorTriggerBaseNode.DocumentNode as DocumentCompositeNode, sceneNode2.DocumentNode as DocumentCompositeNode))
                    {
                        behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)sceneNode2;
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
                }
                BehaviorTriggerActionNode triggerActionNode = (BehaviorTriggerActionNode)sceneNode1.ViewModel.CreateSceneNode((ITypeId)triggerType);
                if (projectContext.IsCapabilitySet(PlatformCapability.SupportsAttachingToRootElements) && ProjectNeutralTypes.BehaviorTargetedTriggerAction.IsAssignableFrom((ITypeId)triggerActionNode.Type) && targetNode.ViewModel.ActiveEditingContainer.Equals((object)targetNode))
                {
                    IProperty property = projectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty);
                    if (property != null)
                    {
                        BehaviorHelper.CreateAndSetElementNameBinding((IPropertyId)property, (SceneNode)triggerActionNode, targetNode);
                    }
                }
                behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode);
                viewModel.BehaviorSelectionSet.SetSelection((BehaviorBaseNode)triggerActionNode);
                editTransaction.Commit();
                return((SceneNode)triggerActionNode);
            }
        }
        internal void AddConditionNode()
        {
            if (!this.EnsureInteractionsAssemblyReferenced() || this.behaviorTriggerBaseNode == null)
            {
                return;
            }
            BehaviorTriggerBaseNode newTriggerParent = this.CloneCurrentTrigger();

            using (SceneEditTransaction editTransaction = this.sceneViewModel.CreateEditTransaction(StringTable.AddConditionUndo))
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = newTriggerParent.GetCollectionForProperty(BehaviorHelper.BehaviorsProperty);
                this.conditionalExpressionNode = (ConditionalExpressionNode)null;
                this.conditionBehaviorNode     = (ConditionBehaviorNode)null;
                foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)collectionForProperty)
                {
                    if (ProjectNeutralTypes.ConditionBehavior.IsAssignableFrom((ITypeId)sceneNode.TrueTargetTypeId))
                    {
                        ConditionBehaviorNode     conditionBehaviorNode     = (ConditionBehaviorNode)sceneNode;
                        ConditionalExpressionNode conditionalExpressionNode = conditionBehaviorNode.ConditionAsConditionalExpressionNode;
                        if (conditionalExpressionNode != null)
                        {
                            this.conditionBehaviorNode     = conditionBehaviorNode;
                            this.conditionalExpressionNode = conditionalExpressionNode;
                            break;
                        }
                    }
                }
                if (this.conditionBehaviorNode == null)
                {
                    this.conditionBehaviorNode = (ConditionBehaviorNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ConditionBehavior);
                    collectionForProperty.Add((SceneNode)this.conditionBehaviorNode);
                    this.conditionalExpressionNode = (ConditionalExpressionNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ConditionalExpression);
                    this.conditionBehaviorNode.ConditionAsConditionalExpressionNode = this.conditionalExpressionNode;
                }
                this.conditions = this.conditionalExpressionNode.Conditions;
                if (this.conditions != null)
                {
                    this.conditions.Add(this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ComparisonCondition));
                }
                if (this.behaviorTriggerBaseNode.Actions.Count > 1)
                {
                    this.objectSet.ReparentActionAndCopyBehaviors(newTriggerParent);
                    this.behaviorTriggerBaseNode = newTriggerParent;
                }
                else
                {
                    SceneNode valueAsSceneNode = newTriggerParent.GetLocalValueAsSceneNode(BehaviorHelper.BehaviorsProperty);
                    valueAsSceneNode.Remove();
                    this.behaviorTriggerBaseNode.SetValueAsSceneNode(BehaviorHelper.BehaviorsProperty, valueAsSceneNode);
                }
                editTransaction.Commit();
            }
            this.Rebuild();
            this.Expanded = true;
        }
        private void NestContents(SceneNode node)
        {
            SceneElement sceneElement1 = (SceneElement)node;
            ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection;
            int count = destinationCollection.Count;

            SceneElement[]      sceneElementArray      = new SceneElement[count];
            LayoutCacheRecord[] layoutCacheRecordArray = new LayoutCacheRecord[count];
            ILayoutDesigner     designerForParent1     = this.SceneNode.ViewModel.GetLayoutDesignerForParent(this.SceneElement, true);
            Rect empty = Rect.Empty;

            for (int index = 0; index < count; ++index)
            {
                BaseFrameworkElement frameworkElement = destinationCollection[index] as BaseFrameworkElement;
                if (frameworkElement != null)
                {
                    layoutCacheRecordArray[index] = designerForParent1.CacheLayout(frameworkElement);
                    empty.Union(designerForParent1.GetChildRect(frameworkElement));
                }
            }
            for (int index = 0; index < count; ++index)
            {
                SceneNode    child         = destinationCollection[index];
                SceneElement sceneElement2 = child as SceneElement;
                if (sceneElement2 != null)
                {
                    sceneElementArray[index] = sceneElement2;
                }
                this.SceneNode.ViewModel.RemoveElement(child);
            }
            destinationCollection.Add((SceneNode)sceneElement1);
            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null)
                {
                    sceneElement1.DefaultContent.Add((SceneNode)sceneElementArray[index]);
                }
            }
            this.SceneNode.ViewModel.Document.OnUpdatedEditTransaction();
            this.SceneNode.DesignerContext.ActiveView.UpdateLayout();
            ILayoutDesigner designerForParent2 = this.SceneNode.ViewModel.GetLayoutDesignerForParent(sceneElement1, true);

            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null && layoutCacheRecordArray[index] != null)
                {
                    designerForParent2.SetLayoutFromCache((BaseFrameworkElement)sceneElementArray[index], layoutCacheRecordArray[index], empty);
                }
            }
            if (sceneElementArray.Length != 1)
            {
                return;
            }
            VisualStateManagerSceneNode.MoveStates(sceneElementArray[0], sceneElement1);
        }
Exemple #17
0
        public virtual BaseFrameworkElement BuildPanel(SceneViewModel viewModel, ICollection <BaseFrameworkElement> children)
        {
            BaseFrameworkElement             frameworkElement1     = (BaseFrameworkElement)viewModel.CreateSceneNode(this.PanelType);
            ISceneNodeCollection <SceneNode> collectionForProperty = frameworkElement1.GetCollectionForProperty(PanelElement.ChildrenProperty);

            foreach (BaseFrameworkElement frameworkElement2 in (IEnumerable <BaseFrameworkElement>)children)
            {
                collectionForProperty.Add((SceneNode)frameworkElement2);
            }
            return(frameworkElement1);
        }
Exemple #18
0
 public override void Execute()
 {
     PerformanceUtility.StartPerformanceSequence(PerformanceEvent.Make3D);
     try
     {
         using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
         {
             BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.SceneViewModel.ElementSelectionSet.PrimarySelection;
             using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoUnitName, false))
             {
                 ILayoutDesigner designerForChild = this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true);
                 Rect            childRect        = designerForChild.GetChildRect(frameworkElement);
                 DocumentNode    newValue         = this.CreateValue(frameworkElement);
                 if (newValue == null)
                 {
                     editTransaction.Cancel();
                 }
                 else if (this.CreateResource && this.ProcessAsResource(frameworkElement, newValue) == null)
                 {
                     editTransaction.Cancel();
                 }
                 else
                 {
                     if (this.ShouldReplaceOriginal)
                     {
                         this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)frameworkElement);
                         Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)frameworkElement, true);
                         this.SceneViewModel.ElementSelectionSet.Clear();
                         BaseFrameworkElement element = this.CreateElement(frameworkElement);
                         using (this.SceneViewModel.ForceBaseValue())
                         {
                             element.Name = frameworkElement.Name;
                             ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement);
                             int index = collectionForChild.IndexOf((SceneNode)frameworkElement);
                             frameworkElement.Remove();
                             this.Postprocess(frameworkElement, element, properties, childRect);
                             collectionForChild.Insert(index, (SceneNode)element);
                             SceneElementHelper.ApplyProperties((SceneNode)element, properties);
                             editTransaction.Update();
                             designerForChild.SetChildRect(element, childRect);
                         }
                         this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)element);
                     }
                     editTransaction.Commit();
                 }
             }
         }
     }
     finally
     {
         PerformanceUtility.EndPerformanceSequence(PerformanceEvent.Make3D);
     }
 }
Exemple #19
0
        private static SceneElement ChangeLayoutType(SceneElement sourceElement, ITypeId layoutType, ref SceneElement elementContainingChildren)
        {
            IDocumentRoot        documentRoot     = sourceElement.DocumentNode.DocumentRoot;
            IDocumentContext     documentContext  = documentRoot.DocumentContext;
            SceneViewModel       viewModel        = sourceElement.ViewModel;
            Size                 size             = Size.Empty;
            BaseFrameworkElement frameworkElement = sourceElement as BaseFrameworkElement;

            if (frameworkElement != null)
            {
                size = frameworkElement.GetComputedTightBounds().Size;
            }
            using (viewModel.ForceBaseValue())
            {
                SceneElement sceneElement = (SceneElement)viewModel.CreateSceneNode(layoutType);
                using (viewModel.DisableUpdateChildrenOnAddAndRemove())
                {
                    using (viewModel.DisableDrawIntoState())
                    {
                        viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)sourceElement);
                        Dictionary <IPropertyId, SceneNode>         properties     = SceneElementHelper.StoreProperties((SceneNode)sourceElement);
                        Dictionary <IPropertyId, List <SceneNode> > storedChildren = ChangeLayoutTypeCommand.StoreChildren(sourceElement);
                        if (sourceElement.DocumentNode == documentRoot.RootNode)
                        {
                            documentRoot.RootNode = sceneElement.DocumentNode;
                            sceneElement.DocumentNode.NameScope = new DocumentNodeNameScope();
                        }
                        else
                        {
                            ISceneNodeCollection <SceneNode> collectionContainer = sourceElement.GetCollectionContainer();
                            int index = collectionContainer.IndexOf((SceneNode)sourceElement);
                            sourceElement.Remove();
                            collectionContainer.Insert(index, (SceneNode)sceneElement);
                        }
                        SceneElementHelper.ApplyProperties((SceneNode)sceneElement, properties);
                        elementContainingChildren = ChangeLayoutTypeCommand.ApplyChildren(sceneElement, storedChildren, size);
                    }
                }
                if (sceneElement is GridElement || sceneElement is CanvasElement)
                {
                    ILayoutDesigner designerForChild = sceneElement.ViewModel.GetLayoutDesignerForChild(sceneElement, true);
                    if ((designerForChild.GetWidthConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width);
                    }
                    if ((designerForChild.GetHeightConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height);
                    }
                }
                return(sceneElement);
            }
        }
Exemple #20
0
 protected override void ModifyValue(PropertyReference propertyReference, object valueToSet, SceneNode.Modification modification, int index)
 {
     if (propertyReference.FirstStep.Equals((object)TextBlockElement.TextProperty))
     {
         ISceneNodeCollection <SceneNode> collectionForProperty = this.GetCollectionForProperty(TextBlockElement.InlinesProperty);
         if (collectionForProperty != null)
         {
             collectionForProperty.Clear();
         }
     }
     base.ModifyValue(propertyReference, valueToSet, modification, index);
 }
Exemple #21
0
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = selectedChildren.Count - 1; index >= 0; --index)
     {
         SceneElement sceneElement = selectedChildren[index];
         sceneElement.Remove();
         childCollection.Insert(0, (SceneNode)sceneElement);
     }
 }
Exemple #22
0
        private IEnumerable <SceneNode> FilterScopeEnumerator(SceneNode pivot)
        {
            SceneElement pivotElement  = pivot as SceneElement;
            bool         ignoreContent = pivotElement != null && pivot.ViewModel == this.lastViewModel && this.lastViewModel.ElementSelectionSet.IsSelected(pivotElement);

            yield return(pivot);

            DocumentCompositeNode compositeNode = pivot.DocumentNode as DocumentCompositeNode;

            if (compositeNode != null)
            {
                foreach (IPropertyId propertyKey in (IEnumerable <IProperty>)compositeNode.Properties.Keys)
                {
                    if (!ignoreContent || !pivot.ContentProperties.Contains(propertyKey))
                    {
                        SceneNode value = pivot.GetLocalValueAsSceneNode(propertyKey);
                        if (value == null)
                        {
                            DocumentNode nodeValue = ((DocumentCompositeNode)pivot.DocumentNode).Properties[propertyKey];
                            if (nodeValue != null)
                            {
                                yield return(pivot.ViewModel.GetSceneNode(nodeValue));
                            }
                        }
                        else
                        {
                            yield return(value);

                            foreach (SceneNode sceneNode in this.descendantEnumerator.Query(value))
                            {
                                yield return(sceneNode);
                            }
                        }
                    }
                }
                if (compositeNode.SupportsChildren)
                {
                    ISceneNodeCollection <SceneNode> children = pivot.GetChildren();
                    for (int i = 0; i < children.Count; ++i)
                    {
                        yield return(children[i]);

                        foreach (SceneNode sceneNode in this.descendantEnumerator.Query(children[i]))
                        {
                            yield return(sceneNode);
                        }
                    }
                }
            }
        }
Exemple #23
0
        public static List <PathElement> ReleaseCompoundPaths(PathElement pathElement, SceneEditTransaction editTransaction)
        {
            List <PathElement> list              = new List <PathElement>();
            PathGeometry       pathGeometry1     = pathElement.PathGeometry;
            Transform          geometryTransform = pathElement.GeometryTransform;
            ISceneNodeCollection <SceneNode> collectionContainer = pathElement.GetCollectionContainer();
            int num            = collectionContainer.IndexOf((SceneNode)pathElement);
            int oldFigureIndex = 0;

            foreach (PathFigure original in pathGeometry1.Figures)
            {
                PathFigure   pathFigure    = PathFigureUtilities.Copy(original, geometryTransform);
                PathGeometry pathGeometry2 = new PathGeometry();
                if (pathGeometry1.Transform != null && pathGeometry1.Transform.Value != Matrix.Identity)
                {
                    pathGeometry2.Transform = pathGeometry1.Transform.Clone();
                }
                if (pathGeometry2.FillRule != pathGeometry1.FillRule)
                {
                    pathGeometry2.FillRule = pathGeometry1.FillRule;
                }
                pathGeometry2.Figures.Add(pathFigure);
                DocumentNode node         = pathElement.DocumentNode.Clone(pathElement.DocumentContext);
                PathElement  pathElement1 = (PathElement)pathElement.ViewModel.GetSceneNode(node);
                collectionContainer.Insert(num++, (SceneNode)pathElement1);
                Rect extent = pathGeometry2.Bounds;
                extent = PathCommandHelper.InflateRectByStrokeWidth(extent, pathElement1, false);
                Vector vector = new Vector(-extent.Left, -extent.Top);
                PathCommandHelper.ReplacePathGeometry(pathElement1, pathGeometry2, editTransaction);
                Matrix transformToElement = pathElement.GetComputedTransformToElement((SceneElement)pathElement1);
                transformToElement.OffsetX += vector.X;
                transformToElement.OffsetY += vector.Y;
                PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform);
                PathCommandHelper.TransferPathFigureAnimations(pathElement, pathElement1, propertyReference, oldFigureIndex, 0, (Transform) new MatrixTransform(transformToElement));
                PathCommandHelper.AdjustPathForAnimations(pathElement1, editTransaction);
                list.Add(pathElement1);
                ++oldFigureIndex;
            }
            string name = pathElement.Name;

            pathElement.ViewModel.ElementSelectionSet.RemoveSelection((SceneElement)pathElement);
            pathElement.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)pathElement);
            pathElement.Remove();
            foreach (SceneNode sceneNode in list)
            {
                sceneNode.Name = name;
            }
            return(list);
        }
Exemple #24
0
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int count = childCollection.Count;

            for (int index = 0; index < selectedChildren.Count; ++index)
            {
                SceneElement sceneElement = selectedChildren[index];
                sceneElement.Remove();
                childCollection.Add((SceneNode)sceneElement);
            }
        }
Exemple #25
0
        public static void ReplaceSceneNode(SceneNode oldValue, SceneNode newValue)
        {
            ISceneNodeCollection <SceneNode> collectionForChild = oldValue.Parent.GetCollectionForChild(oldValue);

            if (collectionForChild == null)
            {
                return;
            }
            int index = collectionForChild.IndexOf(oldValue);

            if (index < 0)
            {
                return;
            }
            collectionForChild[index] = newValue;
        }
Exemple #26
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");
        }
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = 0; index < selectedChildren.Count; ++index)
     {
         SceneElement sceneElement = selectedChildren[index];
         int          num          = childCollection.IndexOf((SceneNode)sceneElement);
         if (num > 0 && !selectedChildren.Contains(childCollection[num - 1] as SceneElement))
         {
             sceneElement.Remove();
             childCollection.Insert(num - 1, (SceneNode)sceneElement);
         }
     }
 }
Exemple #28
0
 private static bool CanAddMultipleElements(SceneElement pasteRoot, int elementCount)
 {
     if (pasteRoot is StyleNode && elementCount > 1)
     {
         return(false);
     }
     if (elementCount > 1)
     {
         IPropertyId childProperty = (IPropertyId)pasteRoot.DefaultContentProperty;
         ISceneNodeCollection <SceneNode> collectionForProperty = pasteRoot.GetCollectionForProperty(childProperty);
         if (collectionForProperty.FixedCapacity.HasValue && elementCount > collectionForProperty.FixedCapacity.Value - collectionForProperty.Count)
         {
             return(false);
         }
     }
     return(true);
 }
        protected SceneElement GetDropTargetInfo(TimelineDropEffects dropEffects, TimelineDragDescriptor descriptor)
        {
            SceneElement sceneElement1 = this.Element;

            if (sceneElement1 == null)
            {
                return((SceneElement)null);
            }
            descriptor.DropIndex = -1;
            int          num           = 0;
            SceneElement sceneElement2 = (SceneElement)null;
            bool         flag          = false;

            if ((dropEffects & TimelineDropEffects.Before) != TimelineDropEffects.None)
            {
                sceneElement1 = this.Element.VisualElementAncestor;
                sceneElement2 = this.Element.VisualElementAncestor;
                if (this.Item.IsExpanded && this.Item.HasActiveChild)
                {
                    sceneElement1            = this.Element;
                    sceneElement2            = this.Element;
                    descriptor.RelativeDepth = 1;
                }
                num  = 1;
                flag = true;
            }
            else if ((dropEffects & TimelineDropEffects.After) != TimelineDropEffects.None)
            {
                sceneElement1 = this.Element.VisualElementAncestor;
                sceneElement2 = this.Element.VisualElementAncestor;
                flag          = true;
            }
            if (flag && sceneElement2 != null)
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = sceneElement2.GetCollectionForProperty((IPropertyId)this.GetContentPropertyFromDragDescriptor(descriptor));
                if (collectionForProperty != null)
                {
                    descriptor.DropIndex = collectionForProperty.IndexOf((SceneNode)this.Element) + num;
                }
            }
            if (!this.Element.ViewModel.ActiveEditingContainer.IsAncestorOf((SceneNode)sceneElement1))
            {
                sceneElement1 = (SceneElement)null;
            }
            return(sceneElement1);
        }
 public bool MoveNext()
 {
     if (this.childCollectionEnumerator != null && this.childCollectionEnumerator.MoveNext())
     {
         return(true);
     }
     while (this.propertyEnumerator.MoveNext())
     {
         ISceneNodeCollection <SceneNode> collectionForProperty = this.parentNode.GetCollectionForProperty(this.propertyEnumerator.Current);
         if (collectionForProperty.Count > 0)
         {
             this.childCollectionEnumerator = collectionForProperty.GetEnumerator();
             return(this.childCollectionEnumerator.MoveNext());
         }
     }
     return(false);
 }