示例#1
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();
                        }
                    }
                }
            }
        }
            public override void SelectElement(SceneElement element, SceneNodeProperty editingProperty)
            {
                if (element == null || editingProperty == null || (editingProperty.SceneNodeObjectSet == null || editingProperty.IsMixedValue))
                {
                    return;
                }
                SceneNodeObjectSet sceneNodeObjectSet = editingProperty.SceneNodeObjectSet;
                BindingSceneNode   bindingSceneNode   = sceneNodeObjectSet.ViewModel.CreateSceneNode(PlatformTypes.Binding) as BindingSceneNode;
                LayoutPathNode     layoutPathNode     = sceneNodeObjectSet.ViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath) as LayoutPathNode;

                using (SceneEditTransaction editTransaction = sceneNodeObjectSet.ViewModel.CreateEditTransaction(StringTable.AddLayoutPathUndo))
                {
                    using (sceneNodeObjectSet.ViewModel.ForceBaseValue())
                    {
                        element.EnsureNamed();
                        editTransaction.Update();
                        bindingSceneNode.ElementName = element.Name;
                        layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode);
                        editingProperty.AddValue((object)layoutPathNode.DocumentNode);
                        editTransaction.Commit();
                    }
                }
            }