internal XmlnsPrefix GetNearestXmlnsPrefix(ITypeId typeId) { ElementNode elementNode = (ElementNode)this.Node; if (elementNode.HasNamespaces) { this.InvalidatePrefixCache(); } XmlnsPrefix key; if (!this.prefixesForType.TryGetValue(typeId, out key)) { foreach (KeyValuePair <XmlnsPrefix, IXmlNamespace> keyValuePair in elementNode.GetNamespacePrefixPairs()) { IXmlNamespace xmlNamespace = keyValuePair.Value; if ((!xmlNamespace.Value.StartsWith("clr-namespace:", StringComparison.Ordinal) ? (xmlNamespace != XmlNamespace.DesignTimeXmlNamespace ? (ITypeId)this.TypeResolver.ProjectNamespaces.GetType(xmlNamespace, typeId.Name) : (ITypeId)this.TypeResolver.GetType(xmlNamespace, typeId.Name)) : this.GetType(xmlNamespace, typeId.Name)) == typeId) { if (key == null) { key = keyValuePair.Key; } if (this.IsDefaultNamespace(xmlNamespace)) { key = keyValuePair.Key; break; } } } this.prefixesForType.Add(typeId, key); } return(key); }
public override bool IsAssignableFrom(ITypeId type) { if (type == null || !type.IsResolvable) { return(false); } if (this.knownUnreferencedType != KnownUnreferencedType.None) { IUnreferencedTypeId unreferencedTypeId = type as IUnreferencedTypeId; if (unreferencedTypeId != null && unreferencedTypeId.IsKnownUnreferencedType(this.knownUnreferencedType)) { return(true); } } IType type1 = (IType)type; IType type2 = type1.PlatformMetadata.ResolveType(this); if (type2.IsResolvable) { return(type2.IsAssignableFrom(type)); } ProjectContextType projectContextType = type1 as ProjectContextType; if (projectContextType != null) { type2 = projectContextType.TypeResolver.ResolveType(this); if (type2 != null) { return(type2.IsAssignableFrom(type)); } } return(false); }
internal IDisposable PushStyleOrTemplate(ITypeId type) { IDisposable disposable = (IDisposable) new XamlSerializerContext.DisposableStyleOrTemplateContext(this, this.styleOrTemplateType); this.styleOrTemplateType = type; return(disposable); }
protected override SceneNode InternalCreateRawInstance(ITypeId instanceType) { IType type = this.ViewModel.ProjectContext.ResolveType(instanceType); if (type != null && type.RuntimeType != (System.Type)null) { ToolboxExampleAttribute attribute = TypeUtilities.GetAttribute <ToolboxExampleAttribute>(type.RuntimeType); if (attribute != null) { IToolboxExampleFactory toolboxExampleFactory = Activator.CreateInstance(attribute.ToolboxExampleFactoryType) as IToolboxExampleFactory; if (toolboxExampleFactory != null && toolboxExampleFactory.Examples != null) { IToolboxExample[] toolboxExampleArray = Enumerable.ToArray <IToolboxExample>(toolboxExampleFactory.Examples); if (this.exampleInfo.Index < toolboxExampleArray.Length) { IToolboxExample toolboxExample = toolboxExampleArray[this.exampleInfo.Index]; if (toolboxExample != null) { ISceneNodeModelItem sceneNodeModelItem = toolboxExample.CreateExample(this.ViewModel.ExtensibilityManager.EditingContext) as ISceneNodeModelItem; if (sceneNodeModelItem != null && sceneNodeModelItem.SceneNode != null) { return(sceneNodeModelItem.SceneNode); } } } } } } return(base.InternalCreateRawInstance(instanceType)); }
private static Brush GetTextForeground(BaseFrameworkElement element) { ITypeId type = (ITypeId)element.ViewObject.GetIType((ITypeResolver)element.ProjectContext); Brush brush; if (PlatformTypes.RichTextBox.IsAssignableFrom(type)) { brush = (Brush)element.GetComputedValueAsWpf(ControlElement.ForegroundProperty); } else if (PlatformTypes.TextBox.IsAssignableFrom(type)) { brush = (Brush)element.GetComputedValueAsWpf(ControlElement.ForegroundProperty); } else { if (!PlatformTypes.TextBlock.IsAssignableFrom(type)) { return((Brush)null); } brush = (Brush)element.GetComputedValueAsWpf(TextBlockElement.ForegroundProperty); } if (brush == null) { brush = (Brush)Brushes.Black; } return(brush); }
public static ViewNode FindStyleTemplateOwningViewNode(ViewNode viewNode) { while (viewNode.Parent != null) { bool flag = false; ITypeId[] typeIdArray = StyleControlTemplateHelper.typesToSkip; int num = 0; while (num < (int)typeIdArray.Length) { ITypeId typeId = typeIdArray[num]; if (!viewNode.Parent.Type.Equals(typeId)) { num++; } else { flag = true; break; } } if (!flag) { break; } viewNode = viewNode.Parent; } return(viewNode.Parent); }
private IProperty ConvertPropertyKey(IProperty propertyKey, IPlatformMetadata targetPlatformMetadata) { ITypeId typeId = (ITypeId)propertyKey.DeclaringType; if (typeId.Equals((object)PlatformTypes.TextElement)) { typeId = PlatformTypes.Inline; } ITypeId type = (ITypeId)PlatformTypeHelper.ConvertTypeId(typeId, targetPlatformMetadata); IProperty property1 = type.GetMember(propertyKey.MemberType, propertyKey.Name, (MemberAccessTypes)(propertyKey.ReadAccess | propertyKey.WriteAccess)) as IProperty; if (property1 == null && targetPlatformMetadata.IsCapabilitySet(PlatformCapability.SupportsProxyProperties)) { IEnumerable <IProperty> proxyProperties = targetPlatformMetadata.GetProxyProperties(this.StandaloneWpfDocumentContext.TypeResolver); if (proxyProperties != null) { string name = propertyKey.Name; foreach (IProperty property2 in proxyProperties) { if (name == property2.Name && property2.DeclaringType.IsAssignableFrom(type)) { property1 = property2; break; } } } } return(property1); }
public static ITypeId GetPathAnimationForType(ITypeId type) { ITypeId typeId; AnimationSceneNode.PlatformNeutralTypeDictionaryTryGetValue(PathAnimationSceneNode.animationsForTypes, type, out typeId); return(typeId); }
private void ChangeBrushType(BrushCategory brushCategory) { if (this.editingProperty == null || this.IsEditingCategory(brushCategory)) { return; } ITypeId type = (ITypeId)this.editingProperty.ComputedValueTypeId; bool flag = false; if (type != null && this.editingProperty.IsResource && (type.Equals((object)brushCategory.Type) || PlatformTypes.GradientBrush.IsAssignableFrom(type) && brushCategory.DefaultBrush is GradientBrush || PlatformTypes.TileBrush.IsAssignableFrom(type) && brushCategory.DefaultBrush is TileBrush)) { flag = true; } if (this.brushSubtypeEditor != null) { BrushCategory.SetLastUsed(this.brushSubtypeEditor.Category, this.editingProperty.GetValue()); } if (flag) { this.editingProperty.DoSetLocalValue(); } else { this.editingProperty.SetValue(BrushCategory.GetLastUsed(this.editingProperty.SceneNodeObjectSet.DesignerContext, this.editingProperty.SceneNodeObjectSet.DocumentContext, brushCategory)); } this.editingProperty.Recache(); this.Rebuild(); }
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(); } }
public bool IsTypeSupported(ITypeId type) { if (!base.PlatformMetadata.IsSupported(this, type)) { return(false); } IType type1 = this.ResolveType(type); if (PlatformTypes.MediaElement.IsAssignableFrom(type1) && !this.IsCapabilitySet(PlatformCapability.SupportsMediaElementControl)) { return(false); } if (PlatformTypes.HyperlinkButton.IsAssignableFrom(type1) && !this.IsCapabilitySet(PlatformCapability.SupportsHyperlinkButtonControl)) { return(false); } if (PlatformTypes.ComboBox.IsAssignableFrom(type1) && !this.IsCapabilitySet(PlatformCapability.SupportsComboBox)) { return(false); } if (PlatformTypes.ComboBoxItem.IsAssignableFrom(type1) && !this.IsCapabilitySet(PlatformCapability.SupportsComboBoxItem)) { return(false); } if (PlatformTypes.VirtualizingStackPanel.IsAssignableFrom(type1) && !this.IsCapabilitySet(PlatformCapability.SupportsVirtualizingStackPanel)) { return(false); } return(true); }
public GradientBrushEditor(BrushEditor brushEditor, ITypeId brushType, SceneNodeProperty basisProperty) : base(brushEditor, basisProperty) { IPlatformMetadata platformMetadata = basisProperty.SceneNodeObjectSet.DocumentContext.TypeResolver.PlatformMetadata; if (PlatformTypes.LinearGradientBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.LinearGradient; } else if (PlatformTypes.RadialGradientBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.RadialGradient; } this.editorTemplate = new DataTemplate(); this.editorTemplate.VisualTree = new FrameworkElementFactory(typeof(GradientBrushEditorControl)); this.gradientStopsProperty = this.RegisterProperty(GradientBrushNode.GradientStopsProperty, (PropertyChangedEventHandler)null); this.gradientStopsProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnGradientStopsChange); basisProperty.SceneNodeObjectSet.DesignerContext.GradientToolSelectionService.PropertyChanged += new PropertyChangedEventHandler(this.OnGradientStopSelectionChange); this.gradientStops = new ObservableCollection <GradientStopEditor>(); this.gradientStopsView = (ListCollectionView)CollectionViewSource.GetDefaultView((object)this.gradientStops); this.sortedGradientStopsView = new ListCollectionView((IList)this.gradientStops); this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("Offset", ListSortDirection.Ascending)); this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("PropertyIndex", ListSortDirection.Ascending)); this.gradientStops.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnGradientStopsChanged); this.gradientStopsView.CurrentChanged += new EventHandler(this.OnCurrentStopChanged); this.RebuildAdvancedProperties(); this.RebuildModel(-1); }
public static void RegisterDragDropTargetAttributeTable(ITypeResolver typeResolver) { AttributeTableBuilder attributeTableBuilder = new AttributeTableBuilder(); ITypeId[] typeIdArray = new ITypeId[3] { ProjectNeutralTypes.DataGridDragDropTarget, ProjectNeutralTypes.ListBoxDragDropTarget, ProjectNeutralTypes.TreeViewDragDropTarget }; foreach (ITypeId typeId in typeIdArray) { Type runtimeType = typeResolver.ResolveType(typeId).RuntimeType; if (runtimeType != (Type)null) { attributeTableBuilder.AddCallback(runtimeType, (AttributeCallback)(builder => { builder.AddCustomAttributes("AllowedSourceEffects", (Attribute) new CategoryAttribute(PresentationFrameworkStringTable.Category_Common_Properties)); builder.AddCustomAttributes("AllowedSourceEffects", (Attribute) new DescriptionAttribute(StringTable.DragDropTargetTypeDescription)); builder.AddCustomAttributes("AllowDrop", (Attribute) new EditorBrowsableAttribute(EditorBrowsableState.Always)); })); } } MetadataStore.AddAttributeTable(attributeTableBuilder.CreateTable()); }
public ScreenNameReferenceVerifier(DesignerContext designerContext, ITypeId referentialObjectType, IPropertyId referentialProperty, bool allowNullOrEmpty) { this.designerContext = designerContext; this.referentialObjectType = referentialObjectType; this.referentialProperty = referentialProperty; this.allowNullOrEmpty = allowNullOrEmpty; }
static PlatformTypesValidationExtension() { ITypeId[] collection = new ITypeId[] { PlatformTypes.ICollection, PlatformTypes.ICollectionT, PlatformTypes.IEnumerable, PlatformTypes.IEnumerableT, PlatformTypes.IList, PlatformTypes.IListT }; PlatformTypesValidationExtension.CollectionTypes = collection; ITypeId[] uIElement = new ITypeId[] { PlatformTypes.UIElement, PlatformTypes.Delegate }; PlatformTypesValidationExtension.ObjectTypes = uIElement; }
public TileBrushEditor(BrushEditor brushEditor, ITypeId brushType, SceneNodeProperty basisProperty) : base(brushEditor, basisProperty) { if (PlatformTypes.VisualBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.Visual; } else if (PlatformTypes.ImageBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.Image; } else if (PlatformTypes.DrawingBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.Drawing; } else if (PlatformTypes.VideoBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.Video; } else if (PlatformTypes.WebBrowserBrush.Equals((object)brushType)) { this.brushCategory = BrushCategory.Html; } this.editorTemplate = new DataTemplate(); this.editorTemplate.VisualTree = new FrameworkElementFactory(typeof(TileBrushEditorControl)); this.stretchProperty = this.RegisterProperty(TileBrushNode.StretchProperty, new PropertyChangedEventHandler(this.OnStretchChanged)); this.tileModeProperty = this.RegisterProperty(TileBrushNode.TileModeProperty, new PropertyChangedEventHandler(this.OnTileModeChanged)); this.imageSourceProperty = this.RegisterProperty(ImageBrushNode.ImageSourceProperty, new PropertyChangedEventHandler(this.OnImageSourceChanged)); this.opacityProperty = this.RegisterProperty(BrushNode.OpacityProperty, new PropertyChangedEventHandler(this.OnOpacityChanged)); this.AdvancedProperties.Add((PropertyEntry)this.opacityProperty); this.relativeTransformProperty = this.RegisterProperty(BrushNode.RelativeTransformProperty, new PropertyChangedEventHandler(this.OnRelativeTransformChanged)); this.AdvancedProperties.Add((PropertyEntry)this.relativeTransformProperty); this.IsSilverlight = !basisProperty.SceneNodeObjectSet.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf); }
public object ConvertToWpf(IDocumentContext sourceDocumentContext, object obj) { if (PlatformConverter.IsPlatformValue(obj, this.StandaloneWpfDocumentContext)) { return(obj); } if (obj != null) { ITypeId typeId = (ITypeId)sourceDocumentContext.TypeResolver.GetType(obj.GetType()); if (PlatformTypes.Style.IsAssignableFrom(typeId) || PlatformTypes.FrameworkTemplate.IsAssignableFrom(typeId)) { return(Activator.CreateInstance(PlatformTypeHelper.ConvertTypeId(typeId, this.StandaloneWpfDocumentContext.TypeResolver.PlatformMetadata).RuntimeType)); } if (PlatformTypes.CompositeTransform.IsAssignableFrom(typeId)) { IPlatform platform = PlatformConverter.GetPlatform(sourceDocumentContext); if (platform != null) { Transform transform = (Transform)platform.GeometryHelper.ConvertTransformToWpf(obj); if (transform != null) { return((object)transform); } } } } object obj1 = this.ConvertInternal(obj, sourceDocumentContext, this.StandaloneWpfDocumentContext, PlatformConverter.ConvertToType.InstanceValue); FontFamily fontFamily = obj1 as FontFamily; if (fontFamily != null && fontFamily.Source == PlatformConverter.portableUserInterfaceString) { return((object)PlatformConverter.PortableUserInterfaceFont); } return(obj1); }
public static bool AttributeExists(IEnumerable attributes, ITypeId attributeType) { bool flag; if (attributes != null) { IEnumerator enumerator = attributes.GetEnumerator(); try { while (enumerator.MoveNext()) { if (!PlatformNeutralAttributeHelper.IsAssignableFrom(attributeType, enumerator.Current)) { continue; } flag = true; return(flag); } return(false); } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } return(flag); } return(false); }
public static bool TypeSupported(ITypeResolver typeResolver, ITypeId type) { if (typeResolver == null) { return(false); } return(typeResolver.PlatformMetadata.IsSupported(typeResolver, type)); }
public static bool IsSupportedTransitionAnimationType(ITypeId animatedType) { if (!PlatformTypes.Double.Equals((object)animatedType) && !PlatformTypes.Color.Equals((object)animatedType)) { return(PlatformTypes.Point.Equals((object)animatedType)); } return(true); }
public DocumentCompositeNode CreateNode(ITypeId typeId) { IType type = this.projectContext.ResolveType(typeId); DocumentCompositeNode documentCompositeNode = this.DocumentNodeBuilderFactory.BuildNode((IDocumentContext)this, type.NearestResolvedType.RuntimeType); documentCompositeNode.Type = type; return(documentCompositeNode); }
public UnbuiltTypeDescription(IAssembly assemblyReference, ITypeId baseType, string clrNamespace, string typeName, IXmlNamespace xmlNamespace) { this.assembly = assemblyReference; this.clrNamespace = clrNamespace; this.typeName = typeName; this.xmlNamespace = xmlNamespace; this.baseType = baseType; }
private bool CanSetControlProperty(ITypeId type) { if (!PlatformTypes.TextElement.IsAssignableFrom(type) && !PlatformTypes.TextBlock.IsAssignableFrom(type) && (!PlatformTypes.FlowDocumentScrollViewer.IsAssignableFrom(type) && !PlatformTypes.Control.IsAssignableFrom(type)) && !PlatformTypes.AccessText.IsAssignableFrom(type)) { return(ProjectNeutralTypes.DataGridTextColumn.IsAssignableFrom(type)); } return(true); }
private bool CanSetTextProperty(ITypeId type) { if (!PlatformTypes.TextElement.IsAssignableFrom(type) && !PlatformTypes.TextBoxBase.IsAssignableFrom(type) && (!PlatformTypes.TextBlock.IsAssignableFrom(type) && !PlatformTypes.RichTextBox.IsAssignableFrom(type)) && !PlatformTypes.FlowDocumentScrollViewer.IsAssignableFrom(type)) { return(PlatformTypes.AccessText.IsAssignableFrom(type)); } return(true); }
public bool IsTypeSupported(ITypeId type) { if (this.actualProjectContext == null) { return(this.PlatformMetadata.IsSupported((ITypeResolver)this, type)); } return(this.actualProjectContext.IsTypeSupported(type)); }
public XamlParserResults(ITypeId expectedRootType, DocumentNode rootNode, IList <XamlParseError> errors, INodeSourceContext xmlDocumentReference, IReadableSelectableTextBuffer textBuffer) { this.expectedRootType = expectedRootType; this.rootNode = rootNode; this.errors = errors; this.xmlDocumentReference = (XmlDocumentReference)xmlDocumentReference; this.textBuffer = textBuffer; }
public bool IsAssignableFrom(ITypeId type) { if (type != this && !this.runtimeType.IsAssignableFrom(type)) { return(this.designType.IsAssignableFrom(type)); } return(true); }
public bool IsShapeType(ITypeId type) { if (!this.ShapeType.IsAssignableFrom(type) && !ProjectNeutralTypes.PrimitiveShape.IsAssignableFrom(type) && !ProjectNeutralTypes.CompositeShape.IsAssignableFrom(type)) { return(ProjectNeutralTypes.CompositeContentShape.IsAssignableFrom(type)); } return(true); }
protected static bool IsDraggableBehaviorType(ITypeId typeId) { if (!ProjectNeutralTypes.Behavior.IsAssignableFrom(typeId)) { return(ProjectNeutralTypes.BehaviorTriggerAction.IsAssignableFrom(typeId)); } return(true); }
public DocumentPrimitiveNode(IDocumentContext context, ITypeId typeId, IDocumentNodeValue value) : base(context, typeId) { if (value == null && !this.Type.SupportsNullValues) { throw new ArgumentException(ExceptionStringTable.DocumentNodeValueTypeValueIsNull); } this.value = value; }