private static bool IsPropertyBindableAsTarget(SceneNode sceneNode, ReferenceStep referenceStep, bool isDeclaringTypeBindable) { if (referenceStep.Equals((object)referenceStep.DeclaringType.Metadata.NameProperty) || (referenceStep.WriteAccess & (MemberAccessType)14) == MemberAccessType.None) { return(false); } SceneNode[] selection = new SceneNode[1] { sceneNode }; TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, sceneNode.Type); if ((!PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep) || !PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, sceneNode.Type, targetedReferenceStep, (ITypeResolver)sceneNode.ProjectContext)) && !referenceStep.Equals((object)ContentControlElement.ContentProperty)) { return(false); } if (referenceStep.PropertyType.IsBinding) { return(true); } object[] customAttributes = referenceStep.GetCustomAttributes(typeof(BindableAttribute), false); if (customAttributes != null && customAttributes.Length > 0) { return(((BindableAttribute)customAttributes[0]).Bindable); } return(isDeclaringTypeBindable && referenceStep is DependencyPropertyReferenceStep); }
public override void OnSelectionChanged(SceneNode[] selectedObjects) { base.OnSelectionChanged(selectedObjects); if (this.objectSet != null) { this.objectSet.Dispose(); this.objectSet = (TriggerObjectSet)null; } this.selectedObjects = selectedObjects; if (selectedObjects.Length > 0) { SceneNode sceneNode = selectedObjects[0]; if (sceneNode != null && ProjectNeutralTypes.BehaviorTriggerAction.IsAssignableFrom((ITypeId)sceneNode.Type)) { BehaviorTriggerBaseNode behaviorTriggerBaseNode = sceneNode.Parent as BehaviorTriggerBaseNode; if (behaviorTriggerBaseNode != null) { this.objectSet = new TriggerObjectSet((BehaviorTriggerActionNode)sceneNode); this.TriggerType = behaviorTriggerBaseNode.Type; List <TargetedReferenceStep> list = new List <TargetedReferenceStep>(); foreach (IProperty property in ITypeExtensions.GetProperties(behaviorTriggerBaseNode.Type, MemberAccessTypes.Public, true)) { ReferenceStep referenceStep = property as ReferenceStep; if (referenceStep != null) { list.Add(new TargetedReferenceStep(referenceStep, behaviorTriggerBaseNode.Type)); } } foreach (TargetedReferenceStep targetedReferenceStep in list) { if (PropertyInspectorModel.IsPropertyBrowsable(this.selectedObjects, targetedReferenceStep)) { AttributeCollection attributes = targetedReferenceStep.Attributes; Attribute[] attributeArray = new Attribute[attributes.Count + 1]; int index; for (index = 0; index < attributes.Count; ++index) { attributeArray[index] = attributes[index]; } attributeArray[index] = (Attribute) new CategoryAttribute(CategoryLocalizationHelper.GetLocalizedCategoryName(CategoryLocalizationHelper.CategoryName.Triggers)); SceneNodeProperty property = (SceneNodeProperty)this.objectSet.CreateProperty(new PropertyReference(targetedReferenceStep.ReferenceStep), new AttributeCollection(attributeArray)); if (!PlatformTypes.IList.IsAssignableFrom((ITypeId)property.PropertyTypeId)) { this.AddProperty(property); } } } } } } this.OnPropertyChanged("IsEmpty"); }
internal SceneNodePropertyInspectorPane(PropertyInspectorModel propertyInspectorModel) { this.propertyInspectorModel = propertyInspectorModel; this.DataContext = (object)propertyInspectorModel; PropertyInspectorHelper.SetOwningPropertyInspectorModel((DependencyObject)this, (IPropertyInspector)propertyInspectorModel); PropertyInspectorHelper.SetOwningPropertyInspectorElement((DependencyObject)this, (UIElement)this); propertyInspectorModel.TransactionHelper.AddCommandBindings((UIElement)this, SupportedPropertyCommands.All); this.CommandBindings.Add(new CommandBinding((ICommand)PropertyValueEditorCommands.FinishEditing, new ExecutedRoutedEventHandler(this.OnPropertyValueFinishEditingCommand))); this.InitializeComponent(); this.SetValue(DesignerProperties.IsInDesignModeProperty, (object)false); this.Loaded += new RoutedEventHandler(this.This_Loaded); this.Unloaded += new RoutedEventHandler(this.This_Unloaded); }
private static bool IsPropertyBindableAsSource(SceneNode sceneNode, ReferenceStep referenceStep) { if ((referenceStep.ReadAccess & (MemberAccessType)14) == MemberAccessType.None) { return(false); } SceneNode[] selection = new SceneNode[1] { sceneNode }; TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, sceneNode.Type); return(PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep, true, true) && PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, sceneNode.Type, targetedReferenceStep, (ITypeResolver)sceneNode.ProjectContext)); }
private void AddElementPropertiesWithTypeFilter(SceneElement targetElement, ResourceEntryItem resource, System.Windows.Controls.ItemCollection menuItems, Type filterType) { SceneNode[] selection = new SceneNode[1] { (SceneNode)targetElement }; foreach (TargetedReferenceStep targetedReferenceStep in (IEnumerable <TargetedReferenceStep>)PropertyMerger.GetMergedProperties((IEnumerable <SceneNode>)selection)) { ReferenceStep referenceStep = targetedReferenceStep.ReferenceStep; if (referenceStep.Name != "Name" && PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep) && (PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, targetElement.Type, targetedReferenceStep, (ITypeResolver)targetElement.ProjectContext) && PlatformTypeHelper.GetPropertyType((IProperty)referenceStep) != (Type)null) && (PlatformTypeHelper.GetPropertyType((IProperty)referenceStep).IsAssignableFrom(resource.Resource.Type.RuntimeType) && (filterType == (Type)null || filterType.IsAssignableFrom(PlatformTypeHelper.GetPropertyType((IProperty)referenceStep))))) { menuItems.Add((object)this.BuildPropertyMenuItem(targetElement, referenceStep, resource)); } } }
private CategoryBase CreateCategory(string name, Type selectedType) { CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(name); CategoryBase categoryBase = (CategoryBase)CategoryFactory.GetCustomCategorySelector(canonicalCategoryName).CreateSceneNodeCategory(canonicalCategoryName, name, this.SceneNodeObjectSet.DesignerContext.MessageLoggingService); ITypeResolver typeResolver = (ITypeResolver)this.SceneNodeObjectSet.ProjectContext; CategoryEditorSet categoryEditorsList = new CategoryEditorSet(); IType type = typeResolver.GetType(selectedType); PropertyInspectorModel.GetCategoryEditors(type, categoryEditorsList, this.MessageLoggingService); foreach (CategoryEditor categoryEditor in categoryEditorsList.Union(CategoryEditorInstanceFactory.GetEditors((ITypeId)type, categoryBase as SceneNodeCategory))) { if (categoryEditor.TargetCategory == categoryBase.CategoryName) { categoryBase.CategoryEditors.Add(categoryEditor); } } return(categoryBase); }
protected void RecalculateTemplateBindableProperties() { this.templateBindableProperties.Clear(); SceneNode[] objects = this.Objects; if (objects.Length != 1) { return; } SceneNode sceneNode = objects[0]; if (sceneNode == null || sceneNode.StoryboardContainer == null || !typeof(ControlTemplateElement).IsAssignableFrom(sceneNode.StoryboardContainer.GetType()) || !sceneNode.Platform.Metadata.IsCapabilitySet(PlatformCapability.SupportNonFrameworkElementTemplateBinding) && !PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)sceneNode.Type)) { return; } Type targetElementType = sceneNode.StoryboardContainer.TargetElementType; if (!(targetElementType != (Type)null)) { return; } IList <TargetedReferenceStep> mergedProperties = PropertyMerger.GetMergedProperties((IEnumerable <SceneNode>) new SceneNode[1] { sceneNode.ViewModel.CreateSceneNode(targetElementType) }); IProjectContext projectContext = sceneNode.ProjectContext; foreach (TargetedReferenceStep targetedReferenceStep in (IEnumerable <TargetedReferenceStep>)mergedProperties) { DependencyPropertyReferenceStep referenceStep = targetedReferenceStep.ReferenceStep as DependencyPropertyReferenceStep; if (referenceStep != null) { bool showReadOnly = true; if (PropertyInspectorModel.IsPropertyBrowsable(objects, targetedReferenceStep, showReadOnly) && PropertyInspectorModel.IsAttachedPropertyBrowsable(objects, this.ObjectTypeId, targetedReferenceStep, (ITypeResolver)projectContext)) { this.templateBindableProperties.Add(new TemplateBindablePropertyModel(referenceStep)); } } } this.templateBindableProperties.Sort((Comparison <TemplateBindablePropertyModel>)((left, right) => string.Compare(left.PropertyName, right.PropertyName, StringComparison.CurrentCulture))); this.OnPropertyChanged("TemplateBindableProperties"); }
private CategoryBase CreateCategory(string name, Type selectedType) { CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(name); CategoryBase categoryBase = (CategoryBase)CategoryFactory.GetCustomCategorySelector(canonicalCategoryName).CreateSceneNodeCategory(canonicalCategoryName, name, this.SceneNodeObjectSet.DesignerContext.MessageLoggingService); ITypeResolver typeResolver = (ITypeResolver)this.SceneNodeObjectSet.ProjectContext; CategoryEditorSet categoryEditorsList = new CategoryEditorSet(); IType type = typeResolver.GetType(selectedType); PropertyInspectorModel.GetCategoryEditors(type, categoryEditorsList, this.MessageLoggingService); using (IEnumerator <CategoryEditor> enumerator = categoryEditorsList.Union(CategoryEditorInstanceFactory.GetEditors((ITypeId)type, categoryBase as SceneNodeCategory)).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { CategoryEditor current = enumerator.Current; if (current.get_TargetCategory() == categoryBase.get_CategoryName()) { categoryBase.CategoryEditors.Add(current); } } } return(categoryBase); }
public void Rebuild() { foreach (PropertyBase propertyBase in this.subProperties) { propertyBase.Associated = false; } PropertyDescriptorCollection descriptorCollection = (PropertyDescriptorCollection)null; Type targetType = this.parentProperty.PropertyType; bool isMixed; DocumentNode valueAsDocumentNode = this.parentProperty.GetLocalValueAsDocumentNode(true, out isMixed); if (valueAsDocumentNode == null || !(valueAsDocumentNode is DocumentPrimitiveNode) && !valueAsDocumentNode.Type.IsBinding) { TypeConverter converterFromAttributes = MetadataStore.GetTypeConverterFromAttributes(targetType.Assembly, this.parentProperty.Attributes); if (converterFromAttributes != null) { object obj = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local); if (obj != null && obj != MixedProperty.Mixed) { descriptorCollection = converterFromAttributes.GetProperties(obj); targetType = obj.GetType(); } } if (descriptorCollection == null) { object component = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local); if (component != null && component != MixedProperty.Mixed) { descriptorCollection = TypeUtilities.GetProperties(component); targetType = component.GetType(); } } } this.objectSet.RebuildObjects(); IProjectContext projectContext = this.parentProperty.SceneNodeObjectSet.ProjectContext; if (projectContext != null && descriptorCollection != null) { SceneNode[] objects = this.objectSet.Objects; foreach (PropertyDescriptor propertyDescriptor in descriptorCollection) { ReferenceStep referenceStep = PlatformTypeHelper.GetProperty((ITypeResolver)projectContext, targetType, propertyDescriptor) as ReferenceStep; if (referenceStep != null) { TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, this.objectSet.ObjectTypeId); if (PropertyInspectorModel.IsPropertyBrowsable(objects, targetedReferenceStep) && PropertyInspectorModel.IsAttachedPropertyBrowsable(objects, this.objectSet.ObjectTypeId, targetedReferenceStep, (ITypeResolver)this.parentProperty.SceneNodeObjectSet.ProjectContext)) { PropertyReference propertyReference = new PropertyReference(referenceStep); SceneNodeProperty property = this.FindProperty(propertyReference); if (property == null) { SceneNodeProperty sceneNodeProperty = this.objectSet.CreateProperty(propertyReference, referenceStep.Attributes) as SceneNodeProperty; int index = this.subProperties.BinarySearch(sceneNodeProperty, (IComparer <SceneNodeProperty>) new SceneNodePropertyCollection.PropertyNameComparer()); if (index < 0) { index = ~index; } this.subProperties.Insert(index, sceneNodeProperty); this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, (object)sceneNodeProperty, index)); } else if (!property.UpdateAndRefresh(propertyReference, referenceStep.Attributes, (Type)null)) { property.Associated = true; } } } } } for (int index = this.subProperties.Count - 1; index >= 0; --index) { if (!this.subProperties[index].Associated) { PropertyEntry propertyEntry = (PropertyEntry)this.subProperties[index]; this.subProperties[index].OnRemoveFromCategory(); this.subProperties.RemoveAt(index); this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, (object)propertyEntry, index)); } } this.OnPropertyChanged("Item[]"); }