コード例 #1
0
        private bool CopyItem(ResourceEntryItem primaryResource, ResourceContainer destinationContainer, int destinationIndex, bool skipReferencedResourceCopy)
        {
            ResourceConflictResolution conflictResolution = ResourceConflictResolution.UseExisting;
            DocumentNode               node1              = primaryResource.Resource.ResourceNode.Clone(destinationContainer.ViewModel.Document.DocumentContext);
            DictionaryEntryNode        primaryResource1   = (DictionaryEntryNode)destinationContainer.ViewModel.GetSceneNode(node1);
            ResourceEvaluation         resourceEvaluation = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EvaluateResource(primaryResource1, destinationContainer.Node);
            List <DictionaryEntryNode> list1              = new List <DictionaryEntryNode>();

            if (!skipReferencedResourceCopy)
            {
                List <DocumentNode> foundResources = new List <DocumentNode>();
                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindAllReferencedResources(primaryResource.DocumentNode, foundResources, (Microsoft.Expression.DesignSurface.Utility.ResourceHelper.PostOrderOperation)null);
                foreach (DocumentNode documentNode in foundResources)
                {
                    DocumentNode node2 = documentNode.Parent.Clone(destinationContainer.ViewModel.Document.DocumentContext);
                    list1.Add((DictionaryEntryNode)destinationContainer.ViewModel.GetSceneNode(node2));
                }
            }
            IList <ResourceEvaluation> list2 = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EvaluateResources((IList <DictionaryEntryNode>)list1, destinationContainer.Node);

            if (!Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CheckEvaluationResults(list2, (ResourceEvaluationResult)7))
            {
                if (!Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CheckEvaluationResult(resourceEvaluation, ResourceEvaluationResult.ConflictingResourceExists, ResourceEvaluationResult.IdenticalResourceExists))
                {
                    goto label_10;
                }
            }
            conflictResolution = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.PromptForResourceConflictResolution(ResourceConflictResolution.UseExisting | ResourceConflictResolution.RenameNew | ResourceConflictResolution.OverwriteOld);
            if (conflictResolution == ResourceConflictResolution.Undetermined)
            {
                return(false);
            }
label_10:
            using (SceneEditTransaction editTransaction = destinationContainer.ViewModel.CreateEditTransaction(StringTable.UndoUnitCopyResource))
            {
                int num = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.AddResources(list2, (IList <SceneNode>)null, conflictResolution, destinationContainer.Node, destinationIndex);
                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.AddPrimaryResource(resourceEvaluation, (IList <SceneNode>)null, conflictResolution, destinationContainer.Node, destinationIndex + num);
                ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator(destinationContainer.ViewModel.DocumentRootResolver);
                SceneNode           keyNode             = primaryResource1.KeyNode;
                if (keyNode != null)
                {
                    DocumentNode documentNode = expressionEvaluator.EvaluateResource(destinationContainer.Node.DocumentNodePath, keyNode.DocumentNode);
                    foreach (DictionaryEntryNode dictionaryEntryNode in destinationContainer.ResourceDictionaryNode)
                    {
                        if (dictionaryEntryNode.Value.DocumentNode == documentNode)
                        {
                            this.ResourceManager.SelectedItems.SetSelection((ResourceEntryBase)this.ResourceManager.GetResourceItem(destinationContainer, dictionaryEntryNode.DocumentNode as DocumentCompositeNode));
                            editTransaction.Commit();
                            return(true);
                        }
                    }
                }
                else
                {
                    editTransaction.Commit();
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
ファイル: PasteCommand.cs プロジェクト: radtek/Shopdrawing
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitPaste))
     {
         this.SceneViewModel.GetActiveSceneInsertionPoint(new InsertionPointContext(false));
         if (this.SceneViewModel.TextSelectionSet.IsActive)
         {
             try
             {
                 this.SceneViewModel.TextSelectionSet.TextEditProxy.EditingElement.Paste();
             }
             catch (ArgumentException ex)
             {
                 this.SceneViewModel.DesignerContext.MessageDisplayService.ShowError(StringTable.PasteTextFailedDialogMessage);
             }
         }
         else
         {
             ICollection <SceneNode> nodes = PasteCommand.PasteData(this.SceneViewModel, SafeDataObject.FromClipboard());
             if (nodes.Count > 0)
             {
                 this.SceneViewModel.ClearSelections();
                 this.SceneViewModel.SelectNodes(nodes);
             }
         }
         editTransaction.Commit();
     }
 }
コード例 #3
0
        protected override void SetSelectionWithUndo(string description, MarkerBasedSceneNodeCollection <SceneElement> newSelection, SceneElement newPrimarySelection)
        {
            SceneNode           containerForSelection = this.ViewModel.GetEditingContainerForSelection <SceneElement>((ICollection <SceneElement>)newSelection);
            List <SceneElement> removedElements;

            newSelection = this.StorageProvider.CopyList((ICollection <SceneElement>) this.ViewModel.GetSelectionForEditingContainer <SceneElement>(containerForSelection, (ICollection <SceneElement>)newSelection, out removedElements));
            if (removedElements.Contains(newPrimarySelection))
            {
                newPrimarySelection = newSelection.Count > 0 ? newSelection[newSelection.Count - 1] : (SceneElement)null;
            }
            this.OnSelectionChanging((IList <SceneElement>)newSelection);
            if (this.EditTransactionFactory != null)
            {
                description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, description, new object[1]
                {
                    (object)this.NamingHelper.Name
                });
                using (SceneEditTransaction editTransaction = this.EditTransactionFactory.CreateEditTransaction(description, true))
                {
                    this.SetSelectionWithUndo(description, newSelection, newPrimarySelection);
                    if (containerForSelection != null)
                    {
                        this.ViewModel.ActiveEditingContainerPath = containerForSelection.DocumentNodePath;
                    }
                    editTransaction.Commit();
                }
            }
            else
            {
                this.SetSelectionInternal(newSelection, newPrimarySelection);
            }
            this.OnSelectionChangedOutsideUndo();
        }
コード例 #4
0
        public override void Execute()
        {
            SceneElement closestValidCanvas = this.FindClosestValidCanvas(this.designerContext.SelectionManager.ElementSelectionSet.Selection);

            if (closestValidCanvas == null)
            {
                return;
            }
            RegroupToResourceCommand.ConvertibleBrushReference brushReference = new RegroupToResourceCommand.ConvertibleBrushReference(closestValidCanvas);
            ResourceContainer resourceContainer = this.designerContext.ResourceManager.FindResourceContainer(brushReference.DocumentUrl);

            using (SceneEditTransaction editTransaction1 = this.designerContext.ActiveSceneViewModel.CreateEditTransaction(this.UndoUnitString))
            {
                using (SceneEditTransaction editTransaction2 = resourceContainer.ViewModel.CreateEditTransaction(this.UndoUnitString))
                {
                    DocumentCompositeNode resourceNode = this.GetResourceNode(brushReference);
                    DocumentNode          documentNode = resourceNode.Properties[DictionaryEntryNode.ValueProperty];
                    this.designerContext.SelectionManager.ElementSelectionSet.SetSelection(closestValidCanvas);
                    if (!typeof(DrawingBrush).IsAssignableFrom(documentNode.TargetType))
                    {
                        throw new NotSupportedException("Regroup to resource not enabled on non-DrawingBrush types.");
                    }
                    new RegroupToResourceCommand.ReplaceDrawingBrushCommand(this.designerContext.ActiveSceneViewModel, resourceNode).Execute();
                    this.PostProcess(closestValidCanvas);
                    editTransaction2.Commit();
                    editTransaction1.Commit();
                }
            }
        }
コード例 #5
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitCut))
     {
         if (this.SceneViewModel.TextSelectionSet.IsActive)
         {
             this.SceneViewModel.TextSelectionSet.TextEditProxy.EditingElement.Cut();
         }
         else if (!this.SceneViewModel.KeyFrameSelectionSet.IsEmpty)
         {
             CutCommand.CutKeyframes(this.SceneViewModel, this.SceneViewModel.KeyFrameSelectionSet.Selection[0].TargetElement as SceneElement, (ICollection <KeyFrameSceneNode>) this.SceneViewModel.KeyFrameSelectionSet.Selection);
         }
         else if (!this.SceneViewModel.ChildPropertySelectionSet.IsEmpty)
         {
             CutCommand.CutPropertyNodes(this.SceneViewModel, (IList <SceneNode>) this.SceneViewModel.ChildPropertySelectionSet.Selection);
         }
         else if (!this.SceneViewModel.BehaviorSelectionSet.IsEmpty)
         {
             CutCommand.CutBehaviorNodes(this.SceneViewModel, (IList <BehaviorBaseNode>) this.SceneViewModel.BehaviorSelectionSet.Selection);
         }
         else
         {
             List <SceneElement> elements = new List <SceneElement>((IEnumerable <SceneElement>) this.SceneViewModel.ElementSelectionSet.Selection);
             elements.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(this.SceneViewModel.RootNode));
             this.SceneViewModel.ElementSelectionSet.Clear();
             CutCommand.CutElements(this.SceneViewModel, elements);
         }
         editTransaction.Commit();
     }
 }
コード例 #6
0
ファイル: AssetPane.cs プロジェクト: radtek/Shopdrawing
        private void AssetView_AssetDoubleClicked(object sender, AssetEventArgs e)
        {
            SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel;

            if (activeSceneViewModel == null || !activeSceneViewModel.IsEditable || (activeSceneViewModel.DefaultView == null || !activeSceneViewModel.DefaultView.IsDesignSurfaceEnabled) || (e.Asset == null || !e.Asset.IsValid))
            {
                return;
            }
            bool   flag        = false;
            string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitCreateControlFormat, new object[1]
            {
                (object)e.Asset.Name
            });

            using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(description))
            {
                foreach (ISceneInsertionPoint insertionPoint in e.Asset.FindInsertionPoints(activeSceneViewModel))
                {
                    if (e.Asset.CanCreateInstance(insertionPoint))
                    {
                        e.Asset.CreateInstance(this.designerContext.LicenseManager, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null);
                        flag = true;
                    }
                }
                editTransaction.Commit();
                if (!flag || !e.Asset.SupportsTextEditing(activeSceneViewModel.ProjectContext))
                {
                    return;
                }
                this.designerContext.ActiveView.TryEnterTextEditMode(true);
            }
        }
コード例 #7
0
 private void Move(int index)
 {
     this.CacheAllElements();
     using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(StringTable.UndoUnitArrange))
     {
         SceneElement     primarySelection = this.ViewModel.ElementSelectionSet.PrimarySelection;
         List <SceneNode> list1            = SceneNode.FromMarkerList <SceneNode>((DocumentNodeMarkerSortedListBase)this.SourceData, this.ViewModel);
         list1.Sort((IComparer <SceneNode>) new ZOrderComparer <SceneNode>(this.ViewModel.RootNode, !this.ViewModel.TimelineItemManager.SortByZOrder, true));
         if (!this.ViewModel.TimelineItemManager.SortByZOrder)
         {
             list1.Reverse();
         }
         List <SceneElement> list2 = new List <SceneElement>();
         foreach (SceneNode node in list1)
         {
             SceneElement sceneElement = this.Move(node, ref index) as SceneElement;
             if (sceneElement != null)
             {
                 list2.Add(sceneElement);
             }
         }
         this.ViewModel.ElementSelectionSet.SetSelection((ICollection <SceneElement>)list2, primarySelection);
         editTransaction.Commit();
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: FontEmbedder.cs プロジェクト: radtek/Shopdrawing
        private void ChangeFontReference(FontChangeType fontChange, IProjectFont projectFont)
        {
            FontFamily oldFontFamily;
            FontFamily newFontFamily;

            FontEmbedder.CreateFontFamilyChange(fontChange, projectFont, this.viewModel.Document.DocumentContext, out oldFontFamily, out newFontFamily);
            if (!(oldFontFamily.Source != newFontFamily.Source))
            {
                return;
            }
            SceneElement sceneElement = this.viewModel.RootNode as SceneElement;

            if (sceneElement == null)
            {
                return;
            }
            FontFamilyRepairProcessor familyRepairProcessor = new FontFamilyRepairProcessor(this.viewModel.DesignerContext, new FontFamilyChangeModel(oldFontFamily.Source, newFontFamily.Source, fontChange, projectFont, sceneElement.DocumentNode.DocumentRoot, this.viewModel.ProjectContext));

            using (SceneEditTransaction editTransaction = this.viewModel.CreateEditTransaction(StringTable.EmbedFontUndoUnit))
            {
                familyRepairProcessor.Begin();
                if (familyRepairProcessor.Cancelled)
                {
                    editTransaction.Cancel();
                }
                else
                {
                    editTransaction.Commit();
                }
            }
        }
コード例 #10
0
        protected override DragDropEffects OnHandleDrop(DragDropEffects dropEffects)
        {
            bool flag = (dropEffects & DragDropEffects.Copy) != DragDropEffects.None;

            using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(flag ? StringTable.UndoUnitCopy : StringTable.UndoUnitArrange))
            {
                this.ViewModel.ClearSelections();
                SceneNode sceneNode = !flag?this.Move((SceneNode)this.SourceData) : this.Copy((SceneNode)this.SourceData);

                if (sceneNode != null)
                {
                    this.ViewModel.SelectNodes((ICollection <SceneNode>) new SceneNode[1]
                    {
                        sceneNode
                    });
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                    return(DragDropEffects.None);
                }
            }
            return(dropEffects);
        }
コード例 #11
0
        protected override void ModifyValue(PropertyReferenceProperty property, object valueToSet, Modification modification, int index)
        {
            if (this.objects.Length == 0)
            {
                using (this.ViewModel.ForceDefaultSetValue())
                    this.parent.SetValue((PropertyReferenceProperty)this.parentProperty, this.parent.GetValue(this.baseReference, PropertyReference.GetValueFlags.Computed));
                this.RebuildObjects();
            }
            bool treeModified = false;
            SceneEditTransaction sceneEditTransaction = (SceneEditTransaction)null;

            try
            {
                sceneEditTransaction = this.parent.PrepareTreeForModifyValue(this.parentProperty.Reference.Append(property.Reference), valueToSet, modification, out treeModified);
                if (treeModified)
                {
                    this.RebuildObjects();
                }
                base.ModifyValue(property, valueToSet, modification, index);
            }
            finally
            {
                if (sceneEditTransaction != null)
                {
                    sceneEditTransaction.Commit();
                    sceneEditTransaction.Dispose();
                }
            }
        }
コード例 #12
0
        private void ApplyResourceOnExistingElement(SceneElement targetElement, IPropertyId targetProperty, ResourceEntryItem resource)
        {
            if (resource.Resource.KeyNode != null || targetProperty.Equals((object)BaseFrameworkElement.StyleProperty))
            {
                using (SceneEditTransaction editTransaction = this.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertySetUndo, new object[1]
                {
                    (object)targetProperty.Name
                })))
                {
                    if (resource.Resource.KeyNode != null)
                    {
                        IDocumentContext documentContext = this.ActiveSceneViewModel.Document.DocumentContext;
                        IProjectContext  projectContext  = this.ActiveSceneViewModel.Document.ProjectContext;
                        DocumentNode     keyNode         = resource.Resource.KeyNode.Clone(documentContext);
                        DocumentNode     documentNode    = !(projectContext.ResolveProperty(targetProperty) is DependencyPropertyReferenceStep) || !JoltHelper.TypeSupported((ITypeResolver)projectContext, PlatformTypes.DynamicResource) ? (DocumentNode)DocumentNodeUtilities.NewStaticResourceNode(documentContext, keyNode) : (DocumentNode)DocumentNodeUtilities.NewDynamicResourceNode(documentContext, keyNode);
                        targetElement.SetValue(targetProperty, (object)documentNode);
                    }
                    else if (targetProperty.Equals((object)BaseFrameworkElement.StyleProperty))
                    {
                        targetElement.ClearValue(targetProperty);
                    }
                    editTransaction.Commit();
                }
            }
            ResourceManager   resourceManager   = this.ActiveSceneViewModel.DesignerContext.ResourceManager;
            DocumentReference documentReference = resource.Container.DocumentReference;

            if (resource.Resource.IsResourceReachable((SceneNode)targetElement) || !(documentReference != resourceManager.ActiveRootContainer.DocumentReference) || !(documentReference != resourceManager.TopLevelResourceContainer.DocumentReference))
            {
                return;
            }
            resourceManager.LinkToResource(resourceManager.TopLevelResourceContainer, documentReference);
        }
コード例 #13
0
        private object OnDragDropDelayed(object arg)
        {
            this.isDropping = false;
            TextEditProxy textEditProxy = (TextEditProxy)arg;

            if (textEditProxy != null)
            {
                using (SceneEditTransaction editTransaction = this.Tool.ActiveSceneViewModel.CreateEditTransaction(StringTable.UndoUnitDragDropText))
                {
                    if (this.editProxy != null)
                    {
                        this.ActiveSceneViewModel.ElementSelectionSet.SetSelection((SceneElement)this.editProxy.TextSource);
                        TextSelectionSet textSelectionSet = this.ActiveSceneViewModel.TextSelectionSet;
                        textSelectionSet.TextEditProxy = this.editProxy;
                        textSelectionSet.IsActive      = true;
                    }
                    textEditProxy.Serialize();
                    textEditProxy.UpdateDocumentModel();
                    this.RemoveEditProxyFromScene(textEditProxy);
                    this.CommitCurrentEdit();
                    editTransaction.Commit();
                    if (this.editProxy != null)
                    {
                        if (this.editProxy.TextSource.IsViewObjectValid)
                        {
                            this.SetIsTextEditingProperty(this.editProxy.TextSource, true);
                        }
                    }
                }
            }
            return((object)null);
        }
コード例 #14
0
 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();
     }
 }
コード例 #15
0
ファイル: SelectionSet`2.cs プロジェクト: radtek/Shopdrawing
        protected virtual void SetSelectionWithUndo(string description, ListOfT newSelection, T newPrimarySelection)
        {
            this.OnSelectionChanging((IList <T>)newSelection);
            int primarySelection = this.GetIndexOfPrimarySelection(newSelection, newPrimarySelection);

            if (this.editTransactionFactory != null)
            {
                description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, description, new object[1]
                {
                    (object)this.namingHelper.Name
                });
                using (SceneEditTransaction editTransaction = this.editTransactionFactory.CreateEditTransaction(description, true))
                {
                    editTransaction.AddUndoUnit((IUndoUnit) new SelectionSet <T, ListOfT> .SelectionChangeUndoUnit(this, newSelection, primarySelection));
                    editTransaction.Commit();
                }
            }
            else
            {
                this.SetSelectionInternal(newSelection, primarySelection);
            }
            if (this.ViewModel == null || !this.IsExclusive || newSelection.Count <= 0)
            {
                return;
            }
            this.ViewModel.EnforceExclusiveSelection((ISelectionSet)this);
        }
コード例 #16
0
        public void Execute()
        {
            if (!this.IsEnabled)
            {
                return;
            }
            ResourceEntryItem  resourceEntryItem  = (ResourceEntryItem)this.resourceManager.SelectedItems.Selection[0];
            SceneNode          sceneNode          = resourceEntryItem.Container.ViewModel.GetSceneNode(resourceEntryItem.Resource.ValueNode);
            ConvertibleDrawing convertibleDrawing = ConvertibleDrawing.CreateConvertibleDrawing((object)(Brush)this.designerContext.ActiveSceneViewModel.CreateInstance(sceneNode.DocumentNodePath), sceneNode.ProjectContext.ProjectPath);

            if (convertibleDrawing == null)
            {
                return;
            }
            DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)sceneNode.DocumentNode;
            string         valueAsString        = DocumentPrimitiveNode.GetValueAsString(resourceEntryItem.Resource.KeyNode);
            string         documentUrl          = documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl;
            SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel;

            using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(this.CommandName))
            {
                BaseFrameworkElement child = (BaseFrameworkElement)activeSceneViewModel.CreateSceneNode((object)convertibleDrawing.Convert());
                activeSceneViewModel.ActiveSceneInsertionPoint.Insert((SceneNode)child);
                child.SetLocalValue(DesignTimeProperties.BrushDocumentReferenceProperty, (object)documentUrl);
                child.SetLocalValue(DesignTimeProperties.BrushKeyProperty, (object)valueAsString);
                child.Name  = valueAsString + "_1";
                this.point *= ElementUtilities.GetInverseMatrix(activeSceneViewModel.DefaultView.GetComputedTransformToRoot(activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement));
                Rect rect = new Rect(this.point, new Size(child.Width, child.Height));
                activeSceneViewModel.GetLayoutDesignerForChild((SceneElement)child, true).SetChildRect(child, rect, LayoutOverrides.None, LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None);
                this.designerContext.SelectionManager.ElementSelectionSet.SetSelection((SceneElement)child);
                editTransaction.Commit();
            }
        }
コード例 #17
0
        internal void AddTriggerNode()
        {
            Type newClrObject = ClrNewObjectDialog.CreateNewClrObject(this.sceneViewModel, this.sceneViewModel.ProjectContext.ResolveType(ProjectNeutralTypes.BehaviorTriggerBase).RuntimeType, true);

            if (!(newClrObject != (Type)null))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.sceneViewModel.CreateEditTransaction(StringTable.AddBehaviorCommandTriggerUndo))
            {
                BehaviorTriggerBaseNode behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)this.sceneViewModel.CreateSceneNode(newClrObject);
                InvokeCommandActionNode commandActionNode       = (InvokeCommandActionNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.InvokeCommandAction);
                commandActionNode.CommandName = this.CategoryName;
                behaviorTriggerBaseNode.Actions.Add((SceneNode)commandActionNode);
                if (ProjectNeutralTypes.BehaviorEventTriggerBase.IsAssignableFrom((ITypeId)behaviorTriggerBaseNode.Type))
                {
                    SceneNode sceneNode = (SceneNode)this.behaviorNode;
                    while (sceneNode != null && !(sceneNode is SceneElement))
                    {
                        sceneNode = sceneNode.Parent;
                    }
                    if (sceneNode != null)
                    {
                        sceneNode.EnsureNamed();
                        ((BehaviorEventTriggerBaseNode)behaviorTriggerBaseNode).SourceName = sceneNode.Name;
                    }
                }
                this.behaviorNode.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty).Add((SceneNode)behaviorTriggerBaseNode);
                editTransaction.Commit();
            }
            this.Rebuild();
            this.TriggerNodeView.MoveCurrentToLast();
        }
コード例 #18
0
 private bool CreateControls(Point dropPoint)
 {
     using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
     {
         DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(this.DragModel.TargetNode);
         DataSourceInfo  other           = new DataSourceInfo(new DataSchemaNodePath(this.DragModel.DataSource.PrimaryAbsoluteSchema, this.GetRelativeSchema().Root));
         bool            flag            = false;
         if (dataContextInfo.DataSource == null || !dataContextInfo.DataSource.IsValidWithSource || dataContextInfo.DataSource.CompareSources(other) != DataSourceMatchCriteria.Exact)
         {
             flag = true;
         }
         IList <DataSchemaNodePath>      relativeSchemaPaths = this.GetRelativeSchemaPaths();
         CanvasLikeDataViewLayoutBuilder viewLayoutBuilder   = new CanvasLikeDataViewLayoutBuilder(this.DragModel.InsertionPoint.InsertIndex, false);
         DocumentCompositeNode           containerNode       = (DocumentCompositeNode)this.DragModel.TargetNode.DocumentNode;
         DataViewFactory.GenerateDataView(this.DragModel.Platform, this.DragModel.DocumentContext, relativeSchemaPaths, DataViewCategory.Master, containerNode, (IDataViewLayoutBuilder)viewLayoutBuilder);
         if (flag)
         {
             viewLayoutBuilder.RebindFields(this.DragModel.ViewModel, this.DragModel.DataSource.PrimaryAbsoluteSchema, relativeSchemaPaths);
         }
         editTransaction.Update();
         viewLayoutBuilder.ApplyActiveUserThemeStyle(this.DragModel.ViewModel);
         viewLayoutBuilder.CompleteLayout(this.DragModel.ViewModel, dropPoint);
         viewLayoutBuilder.SelectElements(this.DragModel.ViewModel);
         editTransaction.Commit();
     }
     return(true);
 }
コード例 #19
0
        private void ApplyChangesInternal(SceneDocument sceneDocument, List <PathChange> documentChanges)
        {
            bool flag = true;

            foreach (PathChange pathChange in documentChanges)
            {
                if (!pathChange.Change.BreakingChange)
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                return;
            }
            SceneView sceneView   = this.GetSceneView(sceneDocument);
            string    description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SampleDataUpdateBindingsTransaction, new object[1]
            {
                (object)this.SampleData.Name
            });

            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(description))
            {
                using (sceneView.ViewModel.AnimationEditor.DeferKeyFraming())
                {
                    foreach (PathChange pathChange in documentChanges)
                    {
                        pathChange.ApplyChange(sceneView.ViewModel);
                    }
                }
                editTransaction.Commit();
            }
        }
コード例 #20
0
        private bool SetBindingOnExistingElement()
        {
            bool flag = false;

            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
            {
                if (DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details)
                {
                    this.GetReusableDetailsContainer(true, this.DragModel.CheckDropFlags(DataBindingDragDropFlags.SetBinding));
                }
                IProperty targetProperty = this.DragModel.TargetProperty;
                if (this.SetBinding(this.DragModel.TargetNode, ref targetProperty))
                {
                    if (DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details && this.DragModel.InsertionPoint.SceneElement != null && DesignTimeProperties.DesignDataContextProperty.Equals((object)targetProperty))
                    {
                        DocumentCompositeNode documentCompositeNode = this.DragModel.TargetNode.DocumentNode as DocumentCompositeNode;
                        if (documentCompositeNode != null && documentCompositeNode.Properties[BaseFrameworkElement.DataContextProperty] == null)
                        {
                            this.LinkDetailsWithMasterControl(this.DragModel.InsertionPoint.SceneElement);
                        }
                    }
                    editTransaction.Commit();
                    this.DragModel.OnUserSelectedProperty(targetProperty);
                    flag = true;
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
            return(flag);
        }
コード例 #21
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoString))
     {
         ItemsControlElement itemsControlElement = this.TargetElement as ItemsControlElement;
         if (itemsControlElement != null)
         {
             ITypeId              itemType       = this.ItemType;
             StyleAsset           asset          = this.Asset;
             IProperty            targetProperty = this.SceneViewModel.ProjectContext.ResolveProperty(ItemsControlElement.ItemsProperty);
             ISceneInsertionPoint insertionPoint = (ISceneInsertionPoint) new PropertySceneInsertionPoint((SceneElement)itemsControlElement, targetProperty);
             if (asset != null && asset.CanCreateInstance(insertionPoint))
             {
                 IExpandable expandable = this.TargetElement as IExpandable;
                 if (expandable != null)
                 {
                     using (this.SceneViewModel.ForceBaseValue())
                         this.TargetElement.SetValue(expandable.ExpansionProperty, (object)true);
                 }
                 asset.CreateInstance(this.DesignerContext.LicenseManager, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null);
             }
             else
             {
                 this.TypeInstantiator.CreateInstance(itemType, insertionPoint, Rect.Empty, (OnCreateInstanceAction)null);
             }
         }
         editTransaction.Commit();
     }
 }
コード例 #22
0
        private DocumentCompositeNode GenerateDataTemplateIfNeeded(SceneNode targetNode, ITypeId dataTemplateType)
        {
            if (this.DragModel.RelativeDropSchemaPath.IsProperty)
            {
                return((DocumentCompositeNode)null);
            }
            IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths();

            if (relativeSchemaPaths.Count == 0)
            {
                return((DocumentCompositeNode)null);
            }
            DocumentCompositeNode dataTemplateNode = (DocumentCompositeNode)null;

            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitCreateTemplate))
            {
                DataSchemaNode node           = this.DragModel.RelativeDropSchemaPath.Node;
                DataSchemaNode dataSchemaNode = node.CollectionItem ?? node;
                string         str            = ((dataSchemaNode.Type != (Type)null ? dataSchemaNode.Type.Name : dataSchemaNode.PathName) + "Template").TrimStart('@', '/');
                if (!SceneNodeIDHelper.IsCSharpID(str))
                {
                    str = "DataTemplate";
                }
                dataTemplateNode = DataViewFactory.CreateDataTemplateResource(targetNode, ItemsControlElement.ItemTemplateProperty, str, relativeSchemaPaths, DataViewCategory.DataTemplate, dataTemplateType);
                editTransaction.Update();
                this.ApplyActiveUserThemeStyleToDataTemplate(dataTemplateNode);
                editTransaction.Commit();
            }
            return(dataTemplateNode);
        }
コード例 #23
0
        private void AssignToPart(PartInPartsExplorer part)
        {
            DocumentNode first = this.ViewModel.ActiveEditingContainer.DocumentNode.FindFirst((Predicate <DocumentNode>)(node =>
            {
                if (node.Name != null)
                {
                    return(node.Name.Equals(part.Name));
                }
                return(false);
            }));

            using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(StringTable.UndoMakeIntoPart))
            {
                if (first != null)
                {
                    ((SceneNode)first.SceneNode).Name = (string)null;
                    this.TargetElement.Name           = part.Name;
                    ((SceneNode)first.SceneNode).Name = part.Name;
                }
                else
                {
                    this.TargetElement.Name = part.Name;
                }
                editTransaction.Commit();
            }
        }
コード例 #24
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();
            }
        }
コード例 #25
0
        private DocumentCompositeNode GetResourceNode(RegroupToResourceCommand.ConvertibleBrushReference brushReference)
        {
            ResourceItem resourceItem = this.FindResourceItem(brushReference);

            if (resourceItem != null)
            {
                return((DocumentCompositeNode)resourceItem.DocumentNode);
            }
            ResourceContainer resourceContainer = this.designerContext.ResourceManager.FindResourceContainer(brushReference.DocumentUrl);

            resourceContainer.EnsureEditable();
            CreateResourceModel createResourceModel = new CreateResourceModel(resourceContainer.ViewModel, resourceContainer.ViewModel.DesignerContext.ResourceManager, typeof(DrawingBrush), (Type)null, (string)null, (SceneElement)null, (SceneNode)null, CreateResourceModel.ContextFlags.None);

            createResourceModel.SelectedLocation = (object)resourceContainer.ViewModel.Document;
            createResourceModel.KeyString        = brushReference.Key;
            DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)null;

            createResourceModel.SelectedExternalResourceDictionaryFile = resourceContainer;
            using (SceneEditTransaction editTransaction = resourceContainer.ViewModel.CreateEditTransaction(StringTable.CreateResourceDialogTitle))
            {
                documentCompositeNode = resourceContainer.ViewModel.Document.DocumentContext.CreateNode(typeof(DrawingBrush));
                documentCompositeNode = createResourceModel.CreateResource((DocumentNode)documentCompositeNode, (IPropertyId)null, -1);
                editTransaction.Commit();
            }
            return(documentCompositeNode);
        }
コード例 #26
0
ファイル: ResourceHelper.cs プロジェクト: radtek/Shopdrawing
        private static DictionaryEntryNode ResolveResourceConflict(ResourceEvaluation resourceEvaluation, IList <SceneNode> elements, SceneNode destination, ResourceConflictResolution resolution)
        {
            DictionaryEntryNode originalResource    = resourceEvaluation.OriginalResource;
            DocumentNode        evaluatedResource   = resourceEvaluation.EvaluatedResource;
            DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)null;

            if (resolution == ResourceConflictResolution.RenameNew)
            {
                DocumentNode newKey = ResourceHelper.GenerateUniqueResourceKey(originalResource.Key.ToString(), destination);
                ResourceHelper.ChangeKey(elements, originalResource, originalResource.KeyNode.DocumentNode, newKey);
                dictionaryEntryNode = originalResource;
            }
            else if (resolution == ResourceConflictResolution.OverwriteOld)
            {
                DocumentCompositeNode parent = evaluatedResource.Parent;
                if (parent != null && typeof(DictionaryEntry).IsAssignableFrom(parent.TargetType))
                {
                    SceneViewModel viewModel = SceneViewModel.GetViewModel((ISceneViewHost)destination.ProjectContext.GetService(typeof(ISceneViewHost)), parent.DocumentRoot, false);
                    if (viewModel != null)
                    {
                        using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoResourceOverwrite))
                        {
                            ((DictionaryEntryNode)viewModel.GetSceneNode((DocumentNode)parent)).Value = viewModel.GetSceneNode(originalResource.Value.DocumentNode.Clone(viewModel.Document.DocumentContext));
                            editTransaction.Commit();
                        }
                    }
                }
                dictionaryEntryNode = (DictionaryEntryNode)null;
            }
            else if (resolution == ResourceConflictResolution.UseExisting)
            {
                dictionaryEntryNode = (DictionaryEntryNode)null;
            }
            return(dictionaryEntryNode);
        }
コード例 #27
0
        internal static void AddItemsToDocument(SceneView view, IEnumerable <IProjectItem> importedItems, Point dropPoint, ISceneInsertionPoint insertionPoint)
        {
            bool flag = false;

            if (importedItems == null || !Enumerable.Any <IProjectItem>(importedItems))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = view.ViewModel.CreateEditTransaction(StringTable.DropElementsIntoSceneUndo))
            {
                foreach (IProjectItem projectItem in importedItems)
                {
                    if (FileDropToolBehavior.CanInsertTo(view, projectItem, insertionPoint))
                    {
                        FileDropToolBehavior.AddToDocument(view, projectItem, dropPoint, insertionPoint);
                    }
                    else
                    {
                        flag = true;
                    }
                }
                editTransaction.Commit();
            }
            if (!flag)
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = StringTable.DragInsertionContainedIllegalItemsMessage,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Exclamation
            };
            int num = (int)view.ViewModel.DesignerContext.MessageDisplayService.ShowMessage(args);
        }
コード例 #28
0
        private void ApplyRelativeTransform_Execute()
        {
            if (!(this.ComponentType != (Type)null) || !this.IsRelativeTransform || this.ObjectSet.RepresentativeSceneNode == null)
            {
                return;
            }
            SelectionManagerPerformanceHelper.MeasurePerformanceUntilPipelinePostSceneUpdate(this.designerContext.SelectionManager, PerformanceEvent.EditSingleTransformProperty);
            using (SceneEditTransaction editTransaction = this.ObjectSet.ViewModel.CreateEditTransaction(StringTable.UndoUnitTransformPaneRelativeTransform))
            {
                LocalValueObjectSet localValueObjectSet = (LocalValueObjectSet)this.PropertyLookup.ActiveObjectSet;
                foreach (SceneNode sceneNode in this.ObjectSet.Objects)
                {
                    object currentTransform;
                    if (this.PropertyLookup.TransformType == TransformType.Transform2D)
                    {
                        if (this.PropertyLookup.IsCompositeSupported)
                        {
                            currentTransform = sceneNode.GetComputedValue(this.TransformProperty.Reference);
                            if (currentTransform != null && !PlatformTypes.CompositeTransform.IsAssignableFrom((ITypeId)this.ObjectSet.ProjectContext.GetType(currentTransform.GetType())))
                            {
                                currentTransform = (object)null;
                            }
                        }
                        else
                        {
                            currentTransform = sceneNode.GetComputedValueAsWpf(this.TransformProperty.Reference);
                        }
                    }
                    else
                    {
                        currentTransform = sceneNode.GetComputedValue(this.TransformProperty.Reference);
                    }
                    object valueToSet = this.ApplyRelativeTransform(localValueObjectSet.LocalValue, currentTransform);
                    if (sceneNode is Base2DElement && this.TransformProperty.Reference.LastStep.Equals((object)Base2DElement.RenderTransformProperty) && sceneNode.IsSet(Base2DElement.RenderTransformOriginProperty).Equals((object)PropertyState.Unset))
                    {
                        sceneNode.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)new Point(0.5, 0.5));
                    }
                    switch (this.PropertyLookup.TransformType)
                    {
                    case TransformType.Transform2D:
                        if (this.PropertyLookup.IsCompositeSupported)
                        {
                            sceneNode.SetValue(this.TransformProperty.Reference, valueToSet);
                            break;
                        }
                        sceneNode.SetValueAsWpf(this.TransformProperty.Reference, (object)((ICanonicalTransform)valueToSet).TransformGroup);
                        break;

                    case TransformType.Transform3D:
                        sceneNode.SetValue(this.TransformProperty.Reference, (object)((CanonicalTransform3D)valueToSet).ToTransform());
                        break;

                    case TransformType.PlaneProjection:
                        sceneNode.SetValue(this.TransformProperty.Reference, valueToSet);
                        break;
                    }
                }
                editTransaction.Commit();
            }
        }
コード例 #29
0
        public void CreateNewEventTrigger()
        {
            if (this.CurrentContainer == null)
            {
                return;
            }
            SceneViewModel    activeSceneViewModel = this.ActiveSceneViewModel;
            SceneDocument     document             = activeSceneViewModel.Document;
            ITriggerContainer currentContainer     = this.CurrentContainer;

            using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit))
            {
                IProjectContext projectContext = document.ProjectContext;
                IType           type           = projectContext.GetType(currentContainer.TargetElementType);
                if (type != null)
                {
                    TriggerSourceInformation triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultEvent((ITypeResolver)projectContext, type);
                    if (triggerSource != (TriggerSourceInformation)null)
                    {
                        TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, activeSceneViewModel);
                        if (trigger != null)
                        {
                            int index = currentContainer.VisualTriggers.Count;
                            if (this.selectedItem != null)
                            {
                                index = this.selectedItem != this.noneTrigger ? currentContainer.VisualTriggers.IndexOf(this.selectedItem.SceneNode) + 1 : 0;
                            }
                            currentContainer.VisualTriggers.Insert(index, trigger);
                            this.TriggerToBeSelected = trigger;
                        }
                    }
                }
                editTransaction.Commit();
            }
        }
コード例 #30
0
 internal void MoveItem(ResourceEntryItem resourceEntry, int destinationIndex)
 {
     using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(StringTable.UndoUnitMoveResource))
     {
         DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)resourceEntry.Resource.ResourceNode.SceneNode;
         int num = this.ResourceDictionaryNode.IndexOf(dictionaryEntryNode);
         if (num == -1)
         {
             return;
         }
         if (destinationIndex > num)
         {
             --destinationIndex;
         }
         if (!this.ResourceDictionaryNode.Remove(dictionaryEntryNode))
         {
             return;
         }
         if (destinationIndex >= 0 && destinationIndex < this.ResourceDictionaryNode.Count)
         {
             this.ResourceDictionaryNode.Insert(destinationIndex, dictionaryEntryNode);
         }
         else
         {
             this.ResourceDictionaryNode.Add(dictionaryEntryNode);
         }
         editTransaction.Commit();
     }
 }