public void FixupIndividualReference(DocumentCompositeNode resource, SceneNode reference) { switch (this.updateMethod) { case ReferencesFoundModel.UpdateMethod.UpdateReferences: DocumentNode node = reference.DocumentContext.CreateNode(this.newKey.GetType(), this.newKey); ResourceNodeHelper.SetResourceKey((DocumentCompositeNode)reference.DocumentNode, node); IPropertyId propertyId1 = (IPropertyId)reference.Parent.GetPropertyForChild(reference); reference.Parent.SetValue(new PropertyReference((ReferenceStep)propertyId1), (object)reference.DocumentNode.Clone(reference.DocumentContext)); break; case ReferencesFoundModel.UpdateMethod.ConvertToLocal: DocumentNode documentNode = resource.Properties[DictionaryEntryNode.ValueProperty].Clone(reference.DocumentContext); IPropertyId propertyId2 = (IPropertyId)reference.Parent.GetPropertyForChild(reference); reference.Parent.SetValue(new PropertyReference((ReferenceStep)propertyId2), (object)documentNode); break; case ReferencesFoundModel.UpdateMethod.ResetToDefault: if (PlatformTypes.Setter.IsAssignableFrom((ITypeId)reference.Parent.Type)) { reference.Parent.Remove(); break; } IPropertyId propertyKey = (IPropertyId)reference.Parent.GetPropertyForChild(reference); reference.Parent.ClearLocalValue(propertyKey); break; } }
private IEnumerable <DataStoreReferenceEntry> FindDataStoreReferenceDictionary(SceneDocument document) { List <DataStoreReferenceEntry> list = (List <DataStoreReferenceEntry>)null; ResourceDictionaryContentProvider dictionaryContentProvider = this.GetResourceDictionaryContentProvider(document); if (dictionaryContentProvider != null) { foreach (DocumentNode documentNode1 in dictionaryContentProvider.Items) { DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode; if (documentCompositeNode != null) { DocumentNode documentNode2 = documentCompositeNode.Properties[DictionaryEntryNode.ValueProperty]; if (documentNode2 != null) { SampleDataSet sampleDataSet = SampleDataSet.SampleDataSetFromType(documentNode2.Type.RuntimeType); if (sampleDataSet != null && sampleDataSet.Context == DataSetContext.DataStore) { if (list == null) { list = new List <DataStoreReferenceEntry>(); } DataStoreReferenceEntry storeReferenceEntry = new DataStoreReferenceEntry() { DataStore = sampleDataSet, DictionaryEntryNode = documentCompositeNode }; list.Add(storeReferenceEntry); } } } } } return((IEnumerable <DataStoreReferenceEntry>)list); }
private void PreProcessDocumentNodeForEditProxyRecursive(Microsoft.Expression.DesignModel.DocumentModel.DocumentNode node, Microsoft.Expression.DesignModel.DocumentModel.DocumentNode nodeInDocument, List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode> originals, List <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode> replacements) { if (PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)node.Type)) { BaseFrameworkElement frameworkElement = this.TextSource.ViewModel.GetSceneNode(nodeInDocument) as BaseFrameworkElement; if (frameworkElement != null) { DocumentCompositeNode node1 = node.Context.CreateNode(PlatformTypes.Rectangle); node1.Properties[BaseFrameworkElement.WidthProperty] = node.Context.CreateNode(typeof(double), (object)frameworkElement.RenderSize.Width); node1.Properties[BaseFrameworkElement.HeightProperty] = node.Context.CreateNode(typeof(double), (object)frameworkElement.RenderSize.Height); node1.Properties[BaseFrameworkElement.TagProperty] = node.Context.CreateNode(typeof(int), (object)this.inlineUIElementStandIns.Count); this.inlineUIElementStandIns.Add(node); this.inlineUIElementOriginals.Add(nodeInDocument); originals.Add(node); replacements.Add((Microsoft.Expression.DesignModel.DocumentModel.DocumentNode)node1); return; } } IEnumerator <Microsoft.Expression.DesignModel.DocumentModel.DocumentNode> enumerator = nodeInDocument.ChildNodes.GetEnumerator(); foreach (Microsoft.Expression.DesignModel.DocumentModel.DocumentNode node1 in node.ChildNodes) { enumerator.MoveNext(); this.PreProcessDocumentNodeForEditProxyRecursive(node1, enumerator.Current, originals, replacements); } }
private void UpdateElementNameBindingsInternal(DocumentCompositeNode documentNode, IProperty elementNameProperty, string oldName, string newName) { DocumentNode node = documentNode.Properties[(IPropertyId)elementNameProperty]; if (node != null) { string valueAsString = DocumentPrimitiveNode.GetValueAsString(node); if (oldName == valueAsString) { documentNode.Properties[(IPropertyId)elementNameProperty] = (DocumentNode)documentNode.Context.CreateNode(newName); } } foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentNode.Properties) { DocumentCompositeNode documentNode1 = keyValuePair.Value as DocumentCompositeNode; if (documentNode1 != null && documentNode1.NameScope == null) { this.UpdateElementNameBindingsInternal(documentNode1, elementNameProperty, oldName, newName); } } if (!documentNode.SupportsChildren) { return; } for (int index = 0; index < documentNode.Children.Count; ++index) { DocumentCompositeNode documentNode1 = documentNode.Children[index] as DocumentCompositeNode; if (documentNode1 != null && documentNode1.NameScope == null) { this.UpdateElementNameBindingsInternal(documentNode1, elementNameProperty, oldName, newName); } } }
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(); } } }
public PropertyDictionaryChangeUndoUnit(DocumentCompositeNode node, IProperty propertyKey, SourceContextContainer <DocumentNode> oldValue, SourceContextContainer <DocumentNode> newValue) { this.node = node; this.propertyKey = propertyKey; this.oldValue = oldValue; this.newValue = newValue; }
private EventHandlerModel EventSubscription_Inserted(object sender, SceneNode basisNode, object basisContent, SceneNode newPathNode) { DocumentCompositeNode documentCompositeNode = newPathNode.Parent.DocumentNode as DocumentCompositeNode; EventHandlerModel eventHandlerModel1 = (EventHandlerModel)null; if (documentCompositeNode != null) { IPropertyId propertyId = (IPropertyId)newPathNode.Parent.GetPropertyForChild(newPathNode); if (propertyId is IEvent) { foreach (EventHandlerModel eventHandlerModel2 in (IEnumerable <EventHandlerModel>) this.EventHandlers) { if (eventHandlerModel2.EventKey == propertyId) { eventHandlerModel1 = eventHandlerModel2; break; } } if (eventHandlerModel1 != null) { eventHandlerModel1.Refresh(); } } } return(eventHandlerModel1); }
private SceneNode ProcessChild(SceneNode node, object child) { SceneNode sceneNode1 = child as SceneNode; if (sceneNode1 != null) { return(sceneNode1); } IPropertyId propertyKey = (IPropertyId)child; SceneNode sceneNode2 = node.GetLocalValueAsSceneNode(propertyKey); if (sceneNode2 == null) { DocumentCompositeNode documentCompositeNode = node.DocumentNode as DocumentCompositeNode; if (documentCompositeNode != null) { DocumentNode node1 = documentCompositeNode.Properties[propertyKey]; if (node1 != null) { sceneNode2 = node.ViewModel.GetSceneNode(node1); } } } return(sceneNode2); }
private void ProcessDocumentNodeChildren(DataBindingProcessingContext context) { DocumentCompositeNode documentCompositeNode = context.DocumentCompositeNode; if (documentCompositeNode == null) { return; } if (!string.IsNullOrEmpty(documentCompositeNode.Name)) { this.namedElementDataContexts[documentCompositeNode] = context; } foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode.Properties) { DocumentCompositeNode childNode = keyValuePair.Value as DocumentCompositeNode; if (childNode != null) { this.ProcessDocumentNodeChild(context, childNode, keyValuePair.Key); } else { this.ProcessDataContextPathExtension(context, keyValuePair.Value, keyValuePair.Key); } } if (!documentCompositeNode.SupportsChildren) { return; } for (int index = 0; index < documentCompositeNode.Children.Count; ++index) { DocumentCompositeNode childNode = documentCompositeNode.Children[index] as DocumentCompositeNode; this.ProcessDocumentNodeChild(context, childNode, (IProperty)null); } }
public RawDataSourceInfoBase GetRawDataContextInfo(DocumentCompositeNode documentNode) { if (documentNode == null) { return((RawDataSourceInfoBase)null); } IProperty ptoperty = DesignTimeProperties.ResolveDesignTimePropertyKey(DesignTimeProperties.DesignDataContextProperty, documentNode.PlatformMetadata); DocumentNode dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty]; if (dataSourceNode == null) { ptoperty = DataContextHelper.GetDataContextProperty(documentNode.Type); if (ptoperty != null) { dataSourceNode = documentNode.Properties[(IPropertyId)ptoperty]; } } if (dataSourceNode == null) { return((RawDataSourceInfoBase)null); } RawDataSourceInfoBase rawDataSourceInfo = DataContextHelper.GetRawDataSourceInfo(dataSourceNode); if (rawDataSourceInfo != null && rawDataSourceInfo.IsValid) { this.OnDataSourceFound(documentNode, ptoperty); } return(rawDataSourceInfo); }
public static bool ShouldInstantiatePreviewControl(IInstanceBuilderContext context, ViewNode viewNode, out XamlDocument sourceDocument, out string sourcePath) { sourceDocument = null; sourcePath = null; if (!PlatformTypes.UserControl.Equals(viewNode.Type)) { DocumentCompositeNode documentNode = viewNode.DocumentNode as DocumentCompositeNode; IProperty property = documentNode.TypeResolver.ResolveProperty(DesignTimeProperties.ClassProperty); if (documentNode != null && !documentNode.Properties.Contains(property)) { sourcePath = viewNode.Type.XamlSourcePath; if (!string.IsNullOrEmpty(sourcePath)) { if (context.CurrentlyInstantiatingUserControlPreviews.Contains(sourcePath)) { return(false); } try { sourceDocument = (XamlDocument)context.DocumentRootResolver.GetDocumentRoot(sourcePath); } catch (FileNotFoundException fileNotFoundException) { } if (sourceDocument != null && UserControlInstanceBuilderHelper.ShouldUseDocumentForPreview(context, sourceDocument)) { return(true); } } } } return(false); }
public static DocumentCompositeNode FindResource(DocumentNode key, DocumentCompositeNode resourcesCollection, int numberOfChildrenToSearch) { if (resourcesCollection != null && resourcesCollection.SupportsChildren) { IList <DocumentNode> children = resourcesCollection.Children; if (numberOfChildrenToSearch < 0) { numberOfChildrenToSearch = children.Count; } for (int i = 0; i < numberOfChildrenToSearch; i++) { DocumentCompositeNode item = children[i] as DocumentCompositeNode; if (item != null) { DocumentNode resourceEntryKey = ResourceNodeHelper.GetResourceEntryKey(item); if (resourceEntryKey == null) { DocumentCompositeNode documentCompositeNode = item.Properties[KnownProperties.DictionaryEntryValueProperty] as DocumentCompositeNode; if (documentCompositeNode != null) { resourceEntryKey = ResourceSite.GetImplicitKey(documentCompositeNode); } } if (resourceEntryKey != null && resourceEntryKey.Equals(key)) { return(item); } } } } return(null); }
public override bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode) { TemplateBindingInstanceBuilderBase.CheckForInvalidBinding(viewNode); bool flag = base.Instantiate(context, viewNode); if (context.RootTargetTypeReplacement != null && context.IsSerializationScope) { ViewNode viewNode1 = StyleControlTemplateHelper.FindContainingControlTemplate(viewNode); if (viewNode1 != null) { ViewNode viewNode2 = StyleControlTemplateHelper.FindStyleTemplateOwningViewNode(viewNode1); if (viewNode2 == null || viewNode2 == context.ViewNodeManager.Root) { DocumentCompositeNode documentNode = viewNode.DocumentNode as DocumentCompositeNode; if (documentNode != null && DocumentNodeUtilities.IsTemplateBinding(documentNode)) { IMemberId valueAsMember = DocumentNodeHelper.GetValueAsMember(documentNode, KnownProperties.TemplateBindingPropertyProperty); if (valueAsMember != null) { IProperty replacementProperty = context.RootTargetTypeReplacement.GetReplacementProperty(valueAsMember as IProperty); if (replacementProperty != null && replacementProperty is DependencyPropertyReferenceStep && replacementProperty != valueAsMember) { DocumentCompositeNode instance = (DocumentCompositeNode)viewNode.Instance; instance.Properties[KnownProperties.TemplateBindingPropertyProperty] = context.DocumentContext.CreateNode(PlatformTypes.DependencyProperty, new DocumentNodeMemberValue(replacementProperty)); } } } } } } return(flag); }
public override bool AllowPostponedResourceUpdate(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNodePath evaluatedResource) { if (viewNode.Type.Metadata.NameProperty == propertyKey) { return(false); } DocumentNodePath editingContainer = context.ViewNodeManager.EditingContainer; if (editingContainer != null && DependencyObjectInstanceBuilderBase <T> .IsEvaluatedResourceWithinNodePath(editingContainer, viewNode, propertyKey, evaluatedResource)) { return(false); } if (context.IsSerializationScope && !PlatformTypes.UIElement.IsAssignableFrom(viewNode.Type)) { return(false); } if (evaluatedResource.Node != null && PlatformTypes.Visual.IsAssignableFrom(evaluatedResource.Node.Type)) { return(false); } DocumentCompositeNode node = evaluatedResource.Node as DocumentCompositeNode; if (node != null && node.PlatformMetadata.IsCapabilitySet(PlatformCapability.SupportNonSharedResources) && node.Properties[DesignTimeProperties.SharedProperty] != null && !node.GetValue <bool>(DesignTimeProperties.SharedProperty)) { return(false); } return(true); }
public void FixNameConflicts(DocumentNode node) { DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode; if (documentCompositeNode == null) { return; } string name = documentCompositeNode.Name; if (name != null) { if (this.NameAlreadyUsed((DocumentNode)documentCompositeNode, name)) { string namePrefix = this.GetNamePrefix(name); documentCompositeNode.Name = this.GetFirstAvailableIndexedName((DocumentNode)documentCompositeNode, namePrefix); } this.AddNode(documentCompositeNode.Name, (DocumentNode)documentCompositeNode); } if (node.NameScope != null) { return; } if (documentCompositeNode.SupportsChildren) { for (int index = 0; index < documentCompositeNode.Children.Count; ++index) { this.FixNameConflicts(documentCompositeNode.Children[index]); } } for (int index = 0; index < documentCompositeNode.Properties.Count; ++index) { this.FixNameConflicts(documentCompositeNode.Properties[index]); } }
private void ProcessDataTemplate(DataBindingProcessingContext context, DocumentCompositeNode resolvedTemplateNode) { IType targetType = this.GetTargetType(resolvedTemplateNode, DataTemplateElement.DataTypeProperty); if (targetType == null) { this.ProcessResource(context, resolvedTemplateNode); } else { if (resolvedTemplateNode != context.DocumentCompositeNode) { return; } RawDataSourceInfoBase dataContextFromType = this.GetDataContextFromType(targetType, resolvedTemplateNode.Properties[DataTemplateElement.DataTypeProperty]); if (dataContextFromType == null) { return; } this.ProcessDocumentNodeChildren(new DataBindingProcessingContext((DocumentNode)resolvedTemplateNode, (DataBindingProcessingContext)null) { DataContext = dataContextFromType }); } }
private DataContextMetadata.AncestorPropertyPath ParseInternal() { List <string> list = new List <string>(); while (this.parsePosition < this.ancestorPath.Length) { string str = this.ParseNextStep(); if (str == null) { return((DataContextMetadata.AncestorPropertyPath)null); } list.Add(str); } List <ReferenceStep> steps = new List <ReferenceStep>(list.Count); for (int index = list.Count - 1; index >= 0; --index) { this.ancestorNode = this.ancestorNode.Parent; if (this.ancestorNode == null) { return((DataContextMetadata.AncestorPropertyPath)null); } ReferenceStep property = this.GetProperty(list[index]); if (property == null) { return((DataContextMetadata.AncestorPropertyPath)null); } steps.Add(property); } steps.Reverse(); return(new DataContextMetadata.AncestorPropertyPath(this.ancestorNode, new PropertyReference(steps))); }
private void TransferLayoutProperties(IEnumerable <IPropertyId> properties, BaseFrameworkElement source, SceneElement target) { DocumentCompositeNode documentCompositeNode1 = source.DocumentNode as DocumentCompositeNode; DocumentCompositeNode documentCompositeNode2 = target.DocumentNode as DocumentCompositeNode; if (documentCompositeNode1 == null || documentCompositeNode2 == null) { return; } foreach (IPropertyId propertyId in properties) { IProperty propertyKey = source.ViewModel.ProjectContext.ResolveProperty(propertyId); if (propertyKey != null) { if (documentCompositeNode1.Properties.Contains(propertyKey)) { documentCompositeNode2.Properties[(IPropertyId)propertyKey] = documentCompositeNode1.Properties[(IPropertyId)propertyKey].Clone(target.DocumentContext); } else { documentCompositeNode2.ClearValue((IPropertyId)propertyKey); } } } }
public DocumentNodeCollectionChangeUndoUnit(DocumentCompositeNode node, int index, DocumentNode oldChildNode, DocumentNode newChildNode) { this.node = node; this.index = index; this.oldChildNode = oldChildNode; this.newChildNode = newChildNode; }
private static DocumentNode GetTemplateNode(SceneNode newElement, DocumentCompositeNode styleNode, out StyleNode styleElement) { DocumentCompositeNode documentCompositeNode1 = styleNode.Properties[DictionaryEntryNode.ValueProperty] as DocumentCompositeNode; SceneViewModel viewModel = newElement.ViewModel.GetViewModel(documentCompositeNode1.DocumentRoot, false); if (viewModel == null) { styleElement = (StyleNode)null; return((DocumentNode)null); } styleElement = viewModel.GetSceneNode((DocumentNode)documentCompositeNode1) as StyleNode; DependencyPropertyReferenceStep propertyReferenceStep = (DependencyPropertyReferenceStep)newElement.ViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty); if (documentCompositeNode1 != null) { DocumentCompositeNode documentCompositeNode2 = documentCompositeNode1.Properties[StyleNode.SettersProperty] as DocumentCompositeNode; if (documentCompositeNode2 != null) { foreach (DocumentNode documentNode1 in (IEnumerable <DocumentNode>)documentCompositeNode2.Children) { DocumentCompositeNode documentCompositeNode3 = documentNode1 as DocumentCompositeNode; if (documentCompositeNode3 != null) { IMemberId memberId = (IMemberId)DocumentPrimitiveNode.GetValueAsMember(documentCompositeNode3.Properties[SetterSceneNode.PropertyProperty]); DocumentNode documentNode2 = documentCompositeNode3.Properties[SetterSceneNode.ValueProperty]; if (memberId != null && documentNode2 != null && propertyReferenceStep.Equals((object)memberId)) { return(documentNode2); } } } } } return((DocumentNode)null); }
public Model(DesignerContext designerContext, SceneDocument document, DocumentCompositeNode node) { this.designerContext = designerContext; this.document = document; this.node = node; this.state = EventsModel.State.Unknown; }
private SceneElement PreparePresenter(DocumentCompositeNode visualTreeNode, SceneElement presenterElement) { if (presenterElement.Type.Equals((object)PlatformTypes.ContentPresenter)) { ContentPresenterElement.PrepareContentPresenter((ContentPresenterElement)presenterElement); } else if (presenterElement.Type.Equals((object)PlatformTypes.ItemsPresenter) && presenterElement.Parent == null) { ContentControlElement contentControlElement = (ContentControlElement)presenterElement.ViewModel.CreateSceneNode(PlatformTypes.ScrollViewer); if (!presenterElement.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { DocumentNode first = visualTreeNode.FindFirst((Predicate <DocumentNode>)(node => { if (node.Name != null) { return(node.Name.Equals(PlatformTypes.ScrollViewer.Name)); } return(false); })); if (first != null) { presenterElement.ViewModel.GetSceneNode(first).Name = (string)null; } contentControlElement.Name = PlatformTypes.ScrollViewer.Name; } contentControlElement.DefaultInsertionPoint.Insert((SceneNode)presenterElement); return((SceneElement)contentControlElement); } return(presenterElement); }
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); }
public static string GetUserFriendlyDescription(DocumentCompositeNode expressionNode, DocumentNode parentNode) { if (DocumentNodeUtilities.IsDynamicResource((DocumentNode)expressionNode) || DocumentNodeUtilities.IsStaticResource((DocumentNode)expressionNode)) { DocumentNode resourceKey = ResourceNodeHelper.GetResourceKey(expressionNode); DocumentPrimitiveNode documentPrimitiveNode = resourceKey as DocumentPrimitiveNode; DocumentCompositeNode expressionNode1 = resourceKey as DocumentCompositeNode; if (documentPrimitiveNode != null && documentPrimitiveNode.Value != null) { return(documentPrimitiveNode.Value.ToString()); } if (expressionNode1 != null && DocumentNodeUtilities.IsMarkupExtension((DocumentNode)expressionNode1)) { return(XamlExpressionSerializer.GetUserFriendlyDescription(expressionNode1, (DocumentNode)expressionNode)); } } else if (DocumentNodeUtilities.IsStaticResource((DocumentNode)expressionNode)) { DocumentPrimitiveNode documentPrimitiveNode = expressionNode.Properties[StaticExtensionProperties.MemberProperty] as DocumentPrimitiveNode; if (documentPrimitiveNode != null) { return(documentPrimitiveNode.Value.ToString()); } } return(XamlExpressionSerializer.GetStringFromExpression((DocumentNode)expressionNode, parentNode)); }
public void Rebuild() { bool isMixed = false; DocumentCompositeNode valueAsDocumentNode = SceneNodePropertyValueCollection.GetLocalValueAsDocumentNode(this.parentProperty, false, out isMixed); int num; if (isMixed || valueAsDocumentNode != null && !this.parentProperty.PropertyType.IsAssignableFrom(valueAsDocumentNode.TargetType)) { num = 0; this.isValidSelection = false; } else { this.isValidSelection = true; num = valueAsDocumentNode == null || !valueAsDocumentNode.SupportsChildren ? 0 : valueAsDocumentNode.Children.Count; } this.objectSet.RebuildObjects(); foreach (PropertyBase propertyBase in this.children) { propertyBase.OnRemoveFromCategory(); } this.children.Clear(); for (int index = 0; index < num; ++index) { this.children.Add(this.CreatePropertyForIndex(index)); } this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }
public bool MoveTo(DocumentCompositeNode targetNode, IProperty targetProperty, bool makeCurrent) { if (targetNode == this.CurrentNode) { this.moveToNode = targetNode; this.moveToProperty = targetProperty; if (makeCurrent) { return(this.MoveNext()); } return(true); } if (this.currentIndex < 0) { this.currentIndex = 0; } for (; this.currentIndex < this.dataContextPath.Count; ++this.currentIndex) { NodePathEntry nodePathEntry = this.dataContextPath[this.currentIndex]; if (nodePathEntry.Container == null || nodePathEntry.Container.IsAncestorOf((DocumentNode)targetNode)) { this.moveToNode = targetNode; this.moveToProperty = targetProperty; if (makeCurrent) { return(this.MoveNext()); } return(true); } } return(false); }
protected override bool DoesNodeReferenceUrl(DocumentNode node, string url) { DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode; if (documentCompositeNode != null) { Uri uriValue = DocumentNodeHelper.GetUriValue(documentCompositeNode.Properties[ImageElement.SourceProperty]); string uriString = uriValue != (Uri)null ? uriValue.OriginalString : (string)null; if (!string.IsNullOrEmpty(uriString)) { Uri uri = node.Context.MakeDesignTimeUri(new Uri(uriString, UriKind.RelativeOrAbsolute)); if (!uri.IsAbsoluteUri) { return(false); } string localPath = uri.LocalPath; if (StringComparer.OrdinalIgnoreCase.Compare(localPath, url) == 0) { return(true); } return(StringComparer.OrdinalIgnoreCase.Compare(localPath.Replace("file:///", "").Replace("/", "\\"), url) == 0); } } return(false); }
public override void Initialize(IInstanceBuilderContext context, ViewNode viewNode, bool isNewInstance) { if (context.IsSerializationScope || viewNode.Instance == null || viewNode.InstanceState != InstanceState.Uninitialized) { base.Initialize(context, viewNode, isNewInstance); return; } DocumentCompositeNode documentNode = viewNode.DocumentNode as DocumentCompositeNode; DocumentCompositeNode documentCompositeNode = documentNode; if (documentNode != null) { this.InstantiateProperties(context, viewNode, documentCompositeNode); if (documentCompositeNode.SupportsChildren) { for (int i = 0; i < documentCompositeNode.Children.Count; i++) { DocumentNode item = documentCompositeNode.Children[i]; IInstanceBuilder builder = context.InstanceBuilderFactory.GetBuilder(item.TargetType); ViewNode viewNode1 = builder.GetViewNode(context, item); viewNode.Children.Add(viewNode1); this.InstantiateChild(context, viewNode, viewNode1); } } } viewNode.InstanceState = InstanceState.Valid; this.OnInitialized(context, viewNode, viewNode.Instance); }
private static void CheckForInvalidBinding(ViewNode viewNode) { if (viewNode == null || viewNode.DocumentNode == null || viewNode.DocumentNode.Parent == null || !viewNode.DocumentNode.IsProperty) { return; } IProperty sitePropertyKey = viewNode.DocumentNode.SitePropertyKey; if (KnownProperties.ContentControlContentProperty.Equals(sitePropertyKey) || KnownProperties.ContentPresenterContentProperty.Equals(sitePropertyKey)) { DocumentCompositeNode documentNode = (DocumentCompositeNode)viewNode.DocumentNode; if (DocumentNodeUtilities.IsBinding(documentNode)) { DocumentNode item = documentNode.Properties[KnownProperties.BindingPathProperty]; DocumentNode item1 = documentNode.Properties[KnownProperties.BindingRelativeSourceProperty]; DocumentNode documentNode1 = documentNode.Properties[KnownProperties.BindingElementNameProperty]; if (item == null && (item1 != null || documentNode1 != null)) { CultureInfo currentCulture = CultureInfo.CurrentCulture; string invalidBindingToVisualTreeElement = ExceptionStringTable.InvalidBindingToVisualTreeElement; object[] name = new object[] { sitePropertyKey.Name }; throw new InvalidOperationException(string.Format(currentCulture, invalidBindingToVisualTreeElement, name)); } } } }
private DocumentNode CreateCollectionItemInternal(DocumentCompositeNode collectionNode, string value) { SampleCollectionType sampleCollectionType = collectionNode.Type as SampleCollectionType; if (sampleCollectionType == null) { return((DocumentNode)null); } DocumentNode documentNode; if (sampleCollectionType.ItemSampleType.IsBasicType) { SampleBasicType sampleType = (SampleBasicType)sampleCollectionType.ItemSampleType; if (value == null) { value = this.valueGenerator.GetRandomValue(sampleType, (string)null, (string)null); } documentNode = (DocumentNode)this.CreateBasicNode(sampleType, value); } else { documentNode = (DocumentNode)this.CreateCompositeNode((SampleNonBasicType)sampleCollectionType.ItemSampleType); } collectionNode.Children.Add(documentNode); return(documentNode); }