private void CreatePopup(VisualStateTransitionSceneNode transitionNode) { VisualStateManagerSceneNode.EnsureExtendedAssemblyReferences((ITypeResolver)transitionNode.ProjectContext, transitionNode.DesignerContext.AssemblyService, transitionNode.DesignerContext.ViewUpdateManager); IType type = transitionNode.ProjectContext.ResolveType(ProjectNeutralTypes.TransitionEffect); if (transitionNode.ProjectContext.PlatformMetadata.IsNullType((ITypeId)type)) { return; } transitionNode.ViewModel.TransitionSelectionSet.SetSelection(transitionNode); SceneNodeProperty transitionEffectProperty = new VisualStateTransitionEditor(transitionNode).VisualTransitionObjectSet.CreateSceneNodeProperty(new PropertyReference((ReferenceStep)transitionNode.ProjectContext.ResolveProperty(VisualStateManagerSceneNode.TransitionEffectProperty)), TypeUtilities.GetAttributes(type.RuntimeType)); this.popup = new TransitionEffectPickerPopup(transitionEffectProperty, transitionNode.ViewModel.DefaultView); transitionNode.ViewModel.Closing += new EventHandler(this.ViewModel_Closing); this.popup.SynchronousClosed += (EventHandler)((sender, e) => { if (transitionNode.IsAttached && transitionNode.ViewModel != null) { transitionNode.ViewModel.TransitionSelectionSet.Clear(); } if (transitionEffectProperty != null) { transitionEffectProperty.OnRemoveFromCategory(); transitionEffectProperty = (SceneNodeProperty)null; } transitionNode.ViewModel.Closing -= new EventHandler(this.ViewModel_Closing); this.popup = (TransitionEffectPickerPopup)null; }); this.popup.Placement = PlacementMode.Bottom; this.popup.PlacementTarget = (UIElement)this; this.popup.IsOpen = 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); }
private void DeleteStateGroup() { if (this.ActiveSceneViewModel == null) { return; } using (SceneEditTransaction editTransaction = this.sceneNode.ViewModel.CreateEditTransaction(StringTable.DeleteVisualStateGroupUndoUnit)) { if (this.selectedState != null || this.IsSelectedWithin) { this.SelectState((StateModel)null); } VisualStateManagerSceneNode.DeleteStateGroup(this.ModelManager.TargetNode, this.sceneNode); editTransaction.Update(); if (this.ActiveSceneViewModel != null) { VisualStateManagerSceneNode.UpdateHasExtendedVisualStateManager(this.ActiveSceneViewModel.ActiveEditingContainer); } editTransaction.Commit(); } }
public override void Execute(object arg) { DesignerContext designerContext = this.DesignerContext; SceneViewModel activeSceneViewModel = designerContext.ActiveSceneViewModel; ITypeId type = this.Type; if (type is ProjectNeutralTypeId) { bool flag = activeSceneViewModel.ProjectContext.PlatformMetadata.IsSupported((ITypeResolver)this.DesignerContext.ActiveSceneViewModel.ProjectContext, type); if (!flag && this.IsDragDropContainer) { IMessageDisplayService messageDisplayService = activeSceneViewModel.DesignerContext.MessageDisplayService; flag = ToolkitHelper.EnsureSilverlightToolkitTypeAvailable((ITypeResolver)activeSceneViewModel.ProjectContext, type, messageDisplayService, StringTable.SilverlightToolkitDragDropNotInstalled, StringTable.SilverlightToolkitDragDropIncorrectVersion); } if (!flag) { return; } } using (SceneEditTransaction editTransaction = designerContext.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitGroupIntoLayoutType, new object[1] { (object)this.Type.Name }))) { List <SceneElement> list1 = new List <SceneElement>(); List <SceneNode> elements = new List <SceneNode>(); list1.AddRange((IEnumerable <SceneElement>)designerContext.SelectionManager.ElementSelectionSet.Selection); GroupIntoLayoutTypeCommand.OrientationHelper orientationHelper = new GroupIntoLayoutTypeCommand.OrientationHelper(); list1.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(this.SceneViewModel.RootNode)); List <LayoutCacheRecord> list2 = new List <LayoutCacheRecord>(list1.Count); Rect empty = Rect.Empty; for (int index = 0; index < list1.Count; ++index) { list2.Add((LayoutCacheRecord)null); BaseFrameworkElement element = list1[index] as BaseFrameworkElement; if (element != null) { ILayoutDesigner designerForChild = element.ViewModel.GetLayoutDesignerForChild((SceneElement)element, true); Rect roundedUpChildRect = LayoutRoundingHelper.GetRoundedUpChildRect(designerForChild, element); empty.Union(roundedUpChildRect); orientationHelper.AddChildRect((SceneNode)element, roundedUpChildRect); LayoutCacheRecord layoutCacheRecord = designerForChild.CacheLayout(element); list2[index] = layoutCacheRecord; elements.Add((SceneNode)element); } } Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null; using (this.SceneViewModel.ForceBaseValue()) { using (this.SceneViewModel.DisableDrawIntoState()) { SceneElement sceneElement1 = (SceneElement)null; SceneElement sceneElement2 = (SceneElement)activeSceneViewModel.CreateSceneNode(type); Orientation? nullable = orientationHelper.ApplyOrientation(sceneElement2); if (nullable.HasValue) { orientationHelper.SortElements(elements, nullable.Value); } int num; if (list1.Count == 1 && list1[0] is BaseFrameworkElement) { int?fixedCapacity = sceneElement2.DefaultContent.FixedCapacity; num = fixedCapacity.GetValueOrDefault() != 1 ? 0 : (fixedCapacity.HasValue ? true : false); } else { num = 0; } bool flag = num != 0; if (sceneElement2 != null) { activeSceneViewModel.GetLayoutDesignerForParent(sceneElement2, true); } foreach (SceneElement sceneElement3 in list1) { if (sceneElement3 != null) { BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement; ILayoutDesigner layoutDesigner = frameworkElement == null ? (ILayoutDesigner)null : sceneElement3.ViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true); if (flag) { properties = SceneElementHelper.StoreProperties((SceneNode)sceneElement3, layoutDesigner.GetLayoutProperties(), true); } if (this.SceneViewModel.LockedInsertionPoint != null && this.SceneViewModel.LockedInsertionPoint.SceneElement == sceneElement3) { sceneElement1 = sceneElement3; } } } if (list1.Count == 1) { VisualStateManagerSceneNode.MoveStates(list1[0], sceneElement2); } using (activeSceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { SceneElement primarySelection = designerContext.SelectionManager.ElementSelectionSet.PrimarySelection; designerContext.SelectionManager.ElementSelectionSet.Clear(); Dictionary <IPropertyId, List <SceneNode> > storedChildren = new Dictionary <IPropertyId, List <SceneNode> >(); storedChildren.Add((IPropertyId)sceneElement2.DefaultContentProperty, elements); ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer(); foreach (SceneElement sceneElement3 in list1) { if (sceneElement3 != primarySelection) { sceneElement3.Remove(); } } int index1 = collectionContainer.IndexOf((SceneNode)primarySelection); primarySelection.Remove(); collectionContainer.Insert(index1, (SceneNode)sceneElement2); ChangeLayoutTypeCommand.ApplyChildren(sceneElement2, storedChildren, empty.Size); if (flag) { SceneElementHelper.FixElementNameBindingsInStoredProperties((SceneNode)list1[0], (SceneNode)sceneElement2, properties); SceneElementHelper.ApplyProperties((SceneNode)sceneElement2, properties); } else { ILayoutDesigner designerForChild = sceneElement2.ViewModel.GetLayoutDesignerForChild(sceneElement2, true); if (sceneElement2.IsViewObjectValid) { LayoutOverrides layoutOverrides = LayoutOverrides.None; LayoutOverrides overridesToIgnore = LayoutOverrides.None; if (nullable.HasValue && nullable.Value == Orientation.Horizontal) { layoutOverrides |= LayoutOverrides.Width; } else { overridesToIgnore |= LayoutOverrides.Width; } if (nullable.HasValue && nullable.Value == Orientation.Vertical) { layoutOverrides |= LayoutOverrides.Height; } else { overridesToIgnore |= LayoutOverrides.Height; } designerForChild.SetChildRect((BaseFrameworkElement)sceneElement2, empty, layoutOverrides, overridesToIgnore, LayoutOverrides.None); } } editTransaction.Update(); if (sceneElement2.IsViewObjectValid) { this.SceneViewModel.DefaultView.UpdateLayout(); SceneElement parentElement = primarySelection.ParentElement; ILayoutDesigner designerForParent = activeSceneViewModel.GetLayoutDesignerForParent(parentElement, true); for (int index2 = 0; index2 < list1.Count; ++index2) { SceneElement sceneElement3 = list1[index2]; BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement; if (frameworkElement != null) { LayoutCacheRecord layoutCacheRecord = list2[index2]; Rect rect = LayoutRoundingHelper.RoundUpLayoutRect(frameworkElement, layoutCacheRecord.Rect); rect.Location = (Point)(rect.Location - empty.Location); designerForParent.ClearUnusedLayoutProperties(frameworkElement); designerForParent.SetChildRect(frameworkElement, rect, flag ? LayoutOverrides.None : layoutCacheRecord.Overrides, LayoutOverrides.Margin | LayoutOverrides.GridBox, LayoutOverrides.None); if (this.IsDragDropContainer) { sceneElement3.SetValue(Base2DElement.AllowDropProperty, (object)true); } } } } if (sceneElement1 != null) { this.SceneViewModel.SetLockedInsertionPoint(sceneElement1); } } designerContext.SelectionManager.ElementSelectionSet.SetSelection(sceneElement2); editTransaction.Commit(); } } } }
private void Rebuild() { if (this.EditingProperty == null) { return; } this.EditingProperty.Recache(); this.states.Clear(); if (this.EditingProperty.ObjectSet.IsHomogenous && this.EditingProperty.ObjectSet.Count > 0) { BehaviorTargetedTriggerActionNode triggerActionNode = this.EditingProperty.SceneNodeObjectSet.Objects[0] as BehaviorTargetedTriggerActionNode; if (triggerActionNode == null || triggerActionNode.TargetObject == null && string.IsNullOrEmpty(triggerActionNode.TargetName)) { SceneNode editingContainer = this.viewModel.ActiveEditingContainer; SceneNode hostNode = VisualStateManagerSceneNode.GetHostNode(this.viewModel.ActiveEditingContainer); if (hostNode != null) { foreach (VisualStateGroupSceneNode stateGroupSceneNode in (IEnumerable <VisualStateGroupSceneNode>)VisualStateManagerSceneNode.GetStateGroups(hostNode)) { foreach (SceneNode sceneNode in (IEnumerable <VisualStateSceneNode>)stateGroupSceneNode.States) { this.states.Add(new StateInfo(sceneNode.Name, stateGroupSceneNode.Name)); } } } ControlTemplateElement controlTemplateElement = this.viewModel.ActiveEditingContainer as ControlTemplateElement; if (controlTemplateElement != null) { IType type = this.viewModel.ProjectContext.ResolveType(controlTemplateElement.ControlTemplateTargetTypeId); foreach (DefaultStateRecord defaultStateRecord in ProjectAttributeHelper.GetDefaultStateRecords(type, (ITypeResolver)(this.viewModel.ProjectContext as ProjectContext))) { this.AddStateInfoIfNeeded(defaultStateRecord.StateName, defaultStateRecord.GroupName, type); } } } else if (triggerActionNode.TargetNode != null && triggerActionNode.TargetNode.IsViewObjectValid) { IViewControl viewControl = triggerActionNode.TargetNode.ViewObject as IViewControl; if (viewControl != null) { object stateManagerHost = viewControl.VisualStateManagerHost; if (stateManagerHost != null) { foreach (object group in (IEnumerable)StatePickerEditor.GetVisualStateGroups(stateManagerHost, (ITypeResolver)triggerActionNode.ProjectContext)) { string stateGroupName = this.GetStateGroupName(group); foreach (object state in (IEnumerable)this.GetStates(group)) { this.states.Add(new StateInfo(this.GetStateName(state), stateGroupName)); } } } IType type = triggerActionNode.TargetNode.ProjectContext.GetType(triggerActionNode.TargetNode.TargetType); foreach (DefaultStateRecord defaultStateRecord in ProjectAttributeHelper.GetDefaultStateRecords(triggerActionNode.TargetNode.Type, (ITypeResolver)(this.viewModel.ProjectContext as ProjectContext))) { this.AddStateInfoIfNeeded(defaultStateRecord.StateName, defaultStateRecord.GroupName, type); } } } } this.states.RemoveAll((Predicate <StateInfo>)(stateInfo => { if (!string.IsNullOrEmpty(stateInfo.GroupName) && !string.IsNullOrEmpty(stateInfo.StateName) && !stateInfo.GroupName.StartsWith(VisualStateManagerSceneNode.SketchFlowAnimationXamlDelimiter, StringComparison.Ordinal)) { return(stateInfo.StateName.StartsWith("_BlendEditTimeState-", StringComparison.Ordinal)); } return(true); })); this.statesView = CollectionViewSource.GetDefaultView(this.states); PropertyGroupDescription groupDescription = new PropertyGroupDescription(); groupDescription.PropertyName = "GroupName"; this.statesView.GroupDescriptions.Clear(); this.statesView.GroupDescriptions.Add((GroupDescription)groupDescription); this.OnPropertyChanged("CurrentState"); this.OnPropertyChanged("States"); }
private SceneNode[] Ungroup(SceneEditTransaction transaction, BaseFrameworkElement group) { SceneElement parentElement = group.ParentElement; if (parentElement == null) { return(new SceneNode[0]); } transaction.Update(); ILayoutDesigner designerForParent1 = this.SceneViewModel.GetLayoutDesignerForParent(parentElement, true); Rect childRect = designerForParent1.GetChildRect(group); Matrix effectiveRenderTransform = group.GetEffectiveRenderTransform(false); SceneNode[] array = new SceneNode[group.DefaultContent.Count]; group.DefaultContent.CopyTo(array, 0); using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { Transform[] transformArray = new Transform[array.Length]; Point[] pointArray = new Point[array.Length]; LayoutCacheRecord[] layoutCacheRecordArray = new LayoutCacheRecord[array.Length]; ILayoutDesigner designerForParent2 = group.ViewModel.GetLayoutDesignerForParent((SceneElement)group, true); for (int index = 0; index < array.Length; ++index) { BaseFrameworkElement frameworkElement = array[index] as BaseFrameworkElement; if (frameworkElement != null) { transformArray[index] = (Transform)frameworkElement.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty); pointArray[index] = frameworkElement.RenderTransformOrigin; designerForParent2.GetChildRect(frameworkElement); LayoutCacheRecord layoutCacheRecord = designerForParent2.CacheLayout(frameworkElement); layoutCacheRecordArray[index] = layoutCacheRecord; } } int num1; if (array.Length == 1 && array[0] is BaseFrameworkElement) { int?fixedCapacity = group.DefaultContent.FixedCapacity; num1 = fixedCapacity.GetValueOrDefault() != 1 ? 0 : (fixedCapacity.HasValue ? true : false); } else { num1 = 0; } bool flag = num1 != 0; if (flag) { Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)group, designerForParent1.GetLayoutProperties(), true); SceneElementHelper.FixElementNameBindingsInStoredProperties((SceneNode)group, array[0], properties); if (!SceneElementHelper.ApplyProperties(array[0], properties)) { flag = false; } } if (array.Length == 1 && array[0] is SceneElement) { VisualStateManagerSceneNode.MoveStates((SceneElement)group, (SceneElement)array[0]); } using (this.SceneViewModel.ForceBaseValue()) { SceneElement sceneElement = (SceneElement)null; for (int index = 0; index < array.Length; ++index) { BaseFrameworkElement frameworkElement = array[index] as BaseFrameworkElement; if (frameworkElement != null) { if (this.SceneViewModel.LockedInsertionPoint != null && this.SceneViewModel.LockedInsertionPoint.SceneElement == frameworkElement) { sceneElement = (SceneElement)frameworkElement; } DocumentNodeHelper.PreserveFormatting(frameworkElement.DocumentNode); frameworkElement.Remove(); } } ISceneNodeCollection <SceneNode> collectionContainer = group.GetCollectionContainer(); int index1 = collectionContainer.IndexOf((SceneNode)group); this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)group); this.SceneViewModel.RemoveElement((SceneNode)group); Matrix matrix1 = effectiveRenderTransform; matrix1.OffsetX = 0.0; matrix1.OffsetY = 0.0; for (int index2 = array.Length - 1; index2 >= 0; --index2) { BaseFrameworkElement frameworkElement = array[index2] as BaseFrameworkElement; if (frameworkElement != null) { Matrix matrix2 = (transformArray[index2] ?? Transform.Identity).Value; collectionContainer.Insert(index1, (SceneNode)frameworkElement); CanonicalTransform canonicalTransform = new CanonicalTransform((Transform) new MatrixTransform(matrix2 * matrix1)); if (frameworkElement.GetLocalValue(Base2DElement.RenderTransformProperty) != null || !canonicalTransform.TransformGroup.Value.IsIdentity) { frameworkElement.SetValue(Base2DElement.RenderTransformProperty, canonicalTransform.GetPlatformTransform(frameworkElement.Platform.GeometryHelper)); if (frameworkElement.IsSet(Base2DElement.RenderTransformOriginProperty) == PropertyState.Unset) { frameworkElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)new Point(0.5, 0.5)); } } } } transaction.Update(); if (sceneElement != null) { this.SceneViewModel.SetLockedInsertionPoint(sceneElement); } bool[] flagArray = new bool[array.Length]; int length = 0; for (int index2 = 0; index2 < array.Length; ++index2) { BaseFrameworkElement frameworkElement = array[index2] as BaseFrameworkElement; if (frameworkElement != null && array[index2].Parent != null) { if (!flag) { LayoutCacheRecord layoutCacheRecord = layoutCacheRecordArray[index2]; Rect rect1 = layoutCacheRecord.Rect; Point point1 = new Point(rect1.X + rect1.Width * pointArray[index2].X, rect1.Y + rect1.Height * pointArray[index2].Y); Point point2 = effectiveRenderTransform.Transform(point1); Rect rect2 = new Rect(rect1.TopLeft + point2 - point1 + (Vector)childRect.TopLeft, rect1.Size); designerForParent1.ClearUnusedLayoutProperties(frameworkElement); designerForParent1.SetChildRect(frameworkElement, rect2, layoutCacheRecord.Overrides, LayoutOverrides.Margin | LayoutOverrides.GridBox, LayoutOverrides.None); } flagArray[index2] = true; ++length; } } SceneNode[] sceneNodeArray = new SceneNode[length]; int num2 = 0; for (int index2 = 0; index2 < array.Length; ++index2) { if (flagArray[index2]) { sceneNodeArray[num2++] = array[index2]; } } return(sceneNodeArray); } } }