Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 protected static bool PlatformNeutralTypeDictionaryTryGetValue(Dictionary <ITypeId, ITypeId> dictionary, ITypeId key, out ITypeId value)
 {
     foreach (ITypeId index in dictionary.Keys)
     {
         if (key.Equals((object)index))
         {
             value = dictionary[index];
             return(true);
         }
     }
     value = (ITypeId)null;
     return(false);
 }
Ejemplo n.º 4
0
        internal override bool ShouldRebuildAdorner(DocumentNodeChange change)
        {
            if (change == null || change.NewChildNode == null || change.OldChildNode == null)
            {
                return(false);
            }
            ITypeId type1 = (ITypeId)change.NewChildNode.Type;
            ITypeId type2 = (ITypeId)change.OldChildNode.Type;

            if (!type1.Equals((object)type2) && PlatformTypes.Brush.IsAssignableFrom(type1))
            {
                return(PlatformTypes.Brush.IsAssignableFrom(type2));
            }
            return(false);
        }
Ejemplo n.º 5
0
 private void Rebuild()
 {
     if (this.editingProperty == null)
     {
         this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
     }
     else
     {
         if (!this.editingProperty.Associated)
         {
             return;
         }
         this.oldNichedState  = this.editingProperty.IsMixedValue;
         this.editingResource = false;
         bool flag = this.brushSubtypeEditor is BrushEditor.NullBrushEditor;
         if (this.editingProperty.IsResource)
         {
             this.editingResource = true;
             this.editingProperty.SceneNodeObjectSet.InvalidateLocalResourcesCache();
             this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
             this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate)(o =>
             {
                 if (this.editingProperty != null && this.ResourceList.IsLoaded && this.Parent != null)
                 {
                     this.ResourceList.ApplyTemplate();
                     ItemsControl itemsControl = (ItemsControl)this.ResourceList.Template.FindName("ResourcesControl", (FrameworkElement)this.ResourceList);
                     itemsControl.ApplyTemplate();
                     ItemsPresenter itemsPresenter = (ItemsPresenter)itemsControl.Template.FindName("ResourcesItemsPresenter", (FrameworkElement)itemsControl);
                     itemsPresenter.ApplyTemplate();
                     WorkaroundVirtualizingStackPanel virtualizingStackPanel = (WorkaroundVirtualizingStackPanel)itemsControl.ItemsPanel.FindName("VirtualizingStackPanel", (FrameworkElement)itemsPresenter);
                     int index = -1;
                     if (this.editingProperty.SelectedLocalResourceModel != null)
                     {
                         this.editingProperty.SelectedLocalResourceModel.Parent.IsExpanded = true;
                         index = itemsControl.Items.IndexOf((object)this.editingProperty.SelectedLocalResourceModel);
                     }
                     else if (this.editingProperty.SelectedSystemResourceModel != null)
                     {
                         this.editingProperty.SelectedSystemResourceModel.Parent.IsExpanded = true;
                         index = itemsControl.Items.IndexOf((object)this.editingProperty.SelectedSystemResourceModel);
                     }
                     if (index >= 0)
                     {
                         virtualizingStackPanel.BringIndexIntoViewWorkaround(index);
                     }
                 }
                 return((object)null);
             }), (object)null);
         }
         else if (this.editingProperty.IsMixedValue)
         {
             this.BrushSubtypeEditor = (BrushSubtypeEditor)null;
         }
         else
         {
             ITypeId typeId = (ITypeId)this.editingProperty.ComputedValueTypeId;
             if (typeId != null)
             {
                 if (typeId.Equals((object)PlatformTypes.SolidColorBrush) && !(this.BrushSubtypeEditor is SolidColorBrushEditor))
                 {
                     this.BrushSubtypeEditor = (BrushSubtypeEditor) new SolidColorBrushEditor(this, this.editingProperty);
                 }
                 else if (PlatformTypes.GradientBrush.IsAssignableFrom(typeId))
                 {
                     if (this.BrushSubtypeEditor == null || !typeId.Equals((object)this.BrushSubtypeEditor.Category.Type))
                     {
                         this.BrushSubtypeEditor = (BrushSubtypeEditor) new GradientBrushEditor(this, typeId, this.editingProperty);
                     }
                 }
                 else if (PlatformTypes.TileBrush.IsAssignableFrom(typeId) && (this.BrushSubtypeEditor == null || !typeId.Equals((object)this.BrushSubtypeEditor.Category.Type)))
                 {
                     this.BrushSubtypeEditor = (BrushSubtypeEditor) new TileBrushEditor(this, typeId, this.editingProperty);
                 }
                 if (this.BrushSubtypeEditor != null)
                 {
                     BrushCategory.SetLastUsed(this.BrushSubtypeEditor.Category, this.editingProperty.GetValue());
                 }
             }
             else
             {
                 this.BrushSubtypeEditor = (BrushSubtypeEditor) new BrushEditor.NullBrushEditor();
             }
         }
         if (!(this.brushSubtypeEditor is BrushEditor.NullBrushEditor) && flag)
         {
             this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Delegate)(o =>
             {
                 this.BringIntoView();
                 return((object)null);
             }), (object)null);
         }
         this.OnEditingTypeChange();
     }
 }
Ejemplo n.º 6
0
 public static DocumentNode CreateNodeFromTextValue(XamlParserContext parserContext, ITextLocation lineInformation, IDocumentNodeReference nodeReference, IXmlNamespaceResolver xmlNamespaceResolver, TypeConverter typeConverter, ITypeId valueTypeId, string value)
 {
     if (parserContext.PlatformMetadata.KnownTypes.DependencyProperty.IsAssignableFrom(valueTypeId))
     {
         MemberType memberTypes = MemberType.Property | MemberType.Field;
         if (parserContext.TypeResolver.IsCapabilitySet(PlatformCapability.IncompleteAttachedPropertiesInMarkupExtensions))
         {
             memberTypes |= MemberType.IncompleteAttachedProperty;
         }
         MemberType defaultType = value.IndexOf('.') >= 0 ? MemberType.AttachedProperty : MemberType.LocalProperty;
         IProperty  propertyKey = XamlTypeHelper.GetPropertyKey(parserContext, lineInformation, xmlNamespaceResolver, value, (XmlNamespace)null, nodeReference.TargetType, memberTypes, defaultType, false);
         if (propertyKey == null)
         {
             return((DocumentNode)null);
         }
         MarkupExtensionParser.VerifyMemberIsDependencyProperty(parserContext, lineInformation, (IMember)propertyKey);
         return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeMemberValue((IMember)propertyKey)));
     }
     if (parserContext.PlatformMetadata.KnownTypes.ICommand.IsAssignableFrom(valueTypeId))
     {
         bool flag = typeConverter != null && !parserContext.PlatformMetadata.KnownTypes.CommandConverter.Equals((object)parserContext.TypeResolver.GetType(typeConverter.GetType()));
         if (value.IndexOf('.') < 0 || flag)
         {
             return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeStringValue(value)));
         }
         IType  typeId;
         string memberName;
         if (MarkupExtensionParser.GetTypeAndMemberName(parserContext, lineInformation, xmlNamespaceResolver, value, (IType)null, out typeId, out memberName))
         {
             MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(parserContext.TypeResolver, typeId);
             IMember           member = (IMember)typeId.GetMember(MemberType.LocalProperty | MemberType.Field, memberName, allowableMemberAccess) ?? XamlTypeHelper.AddMemberIfPossible(parserContext.PlatformMetadata, typeId, MemberType.LocalProperty, memberName);
             if (member != null)
             {
                 return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeMemberValue(member)));
             }
             parserContext.ReportError(XamlParseErrors.UnrecognizedOrInaccessibleMember(lineInformation, memberName));
         }
         return((DocumentNode)null);
     }
     if (parserContext.PlatformMetadata.KnownTypes.RoutedEvent.IsAssignableFrom(valueTypeId))
     {
         IType  typeId;
         string memberName;
         if (!MarkupExtensionParser.GetTypeAndMemberName(parserContext, lineInformation, xmlNamespaceResolver, value, nodeReference.TargetType, out typeId, out memberName))
         {
             return((DocumentNode)null);
         }
         MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(parserContext.TypeResolver, typeId);
         IMember           member = (IMember)typeId.GetMember(MemberType.Event, memberName, allowableMemberAccess);
         if (member != null)
         {
             MarkupExtensionParser.VerifyMemberIsRoutedEvent(parserContext, lineInformation, member);
         }
         else
         {
             member = XamlTypeHelper.AddMemberIfPossible(parserContext.PlatformMetadata, typeId, MemberType.RoutedEvent, memberName);
         }
         if (member != null)
         {
             return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeMemberValue(member)));
         }
         parserContext.ReportError(XamlParseErrors.UnrecognizedOrInaccessibleMember(lineInformation, memberName));
         return((DocumentNode)null);
     }
     if (parserContext.PlatformMetadata.KnownTypes.Delegate.IsAssignableFrom(valueTypeId))
     {
         string memberName = value;
         if (parserContext.RootClassAttributes == null && parserContext.TypeResolver.IsCapabilitySet(PlatformCapability.IsWpf))
         {
             parserContext.ReportError(XamlParseErrors.CannotDetermineMemberTargetType(lineInformation, memberName));
         }
         return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeStringValue(memberName)));
     }
     if (parserContext.PlatformMetadata.KnownTypes.PropertyPath.IsAssignableFrom(valueTypeId))
     {
         return(MarkupExtensionParser.ParsePropertyPath(parserContext, lineInformation, xmlNamespaceResolver, value));
     }
     if (parserContext.PlatformMetadata.KnownTypes.Uri.IsAssignableFrom(valueTypeId))
     {
         return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeStringValue(value)));
     }
     if (parserContext.PlatformMetadata.KnownTypes.Type.IsAssignableFrom(valueTypeId))
     {
         IType typeId = XamlTypeHelper.GetTypeId(parserContext, lineInformation, xmlNamespaceResolver, value, false);
         if (typeId != null)
         {
             return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeMemberValue((IMember)typeId)));
         }
         return((DocumentNode)null);
     }
     if (valueTypeId.Equals((object)parserContext.TypeResolver.PlatformMetadata.KnownTypes.Object))
     {
         valueTypeId = (ITypeId)parserContext.TypeResolver.ResolveType(parserContext.TypeResolver.PlatformMetadata.KnownTypes.String);
     }
     if (valueTypeId.IsResolvable && valueTypeId != parserContext.TypeResolver.ResolveType(parserContext.TypeResolver.PlatformMetadata.KnownTypes.String) && (typeConverter == null || !typeConverter.CanConvertFrom(typeof(string))))
     {
         parserContext.ReportError(XamlParseErrors.CannotConvertFromString(lineInformation, valueTypeId));
     }
     return((DocumentNode)parserContext.DocumentContext.CreateNode(valueTypeId, (IDocumentNodeValue) new DocumentNodeStringValue(value)));
 }