示例#1
0
        private bool SetStyleValue(StylePropertyId id, StyleBackground inlineValue, StyleBackground sharedValue)
        {
            var sv = new StyleValue();

            if (TryGetStyleValue(id, ref sv))
            {
                var vectorImage = sv.resource.IsAllocated ? sv.resource.Target as VectorImage : null;
                var texture     = sv.resource.IsAllocated ? sv.resource.Target as Texture2D : null;
                if ((vectorImage == inlineValue.value.vectorImage && texture == inlineValue.value.texture) && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }

                if (sv.resource.IsAllocated)
                {
                    sv.resource.Free();
                }
            }
            else if (inlineValue.keyword == StyleKeyword.Null)
            {
                return(false);
            }

            sv.id      = id;
            sv.keyword = inlineValue.keyword;
            if (inlineValue.value.vectorImage != null)
            {
                sv.resource = GCHandle.Alloc(inlineValue.value.vectorImage);
            }
            else if (inlineValue.value.texture != null)
            {
                sv.resource = GCHandle.Alloc(inlineValue.value.texture);
            }
            else
            {
                sv.resource = new GCHandle();
            }

            SetStyleValue(sv);

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                sv.keyword = sharedValue.keyword;
                if (sharedValue.value.texture != null)
                {
                    sv.resource = GCHandle.Alloc(sharedValue.value.texture);
                }
                else if (sharedValue.value.vectorImage != null)
                {
                    sv.resource = GCHandle.Alloc(sharedValue.value.vectorImage);
                }
                else
                {
                    sv.resource = new GCHandle();
                }
            }

            ApplyStyleValue(sv);
            return(true);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            bool flag = !(obj is StyleBackground);
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                StyleBackground lhs = (StyleBackground)obj;
                result = (lhs == this);
            }
            return(result);
        }
        public StyleBackground GetStyleBackground(StylePropertyId id)
        {
            StyleValue      styleValue = default(StyleValue);
            bool            flag       = this.TryGetStyleValue(id, ref styleValue);
            StyleBackground result;

            if (flag)
            {
                Texture2D v = styleValue.resource.IsAllocated ? (styleValue.resource.Target as Texture2D) : null;
                result = new StyleBackground(v, styleValue.keyword);
            }
            else
            {
                result = StyleKeyword.Null;
            }
            return(result);
        }
        private bool SetInlineStyle(StylePropertyID id, StyleBackground inlineValue, StyleBackground sharedValue)
        {
            var sv = new StyleValue();

            if (TryGetInlineStyleValue(id, ref sv))
            {
                var texture = sv.resource.IsAllocated ? sv.resource.Target as Texture2D : null;
                if (texture == inlineValue.value.texture && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }

                if (sv.resource.IsAllocated)
                {
                    sv.resource.Free();
                }
            }

            sv.id       = id;
            sv.keyword  = inlineValue.keyword;
            sv.resource = inlineValue.value.texture != null?GCHandle.Alloc(inlineValue.value.texture) : new GCHandle();

            SetInlineStyle(sv);

            int specificity = StyleValueExtensions.InlineSpecificity;

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                specificity = sharedValue.specificity;
                sv.keyword  = sharedValue.keyword;
                sv.resource = sharedValue.value.texture != null?GCHandle.Alloc(sharedValue.value.texture) : new GCHandle();
            }

            ApplyStyleValue(sv, specificity);
            return(true);
        }
示例#5
0
 public bool Equals(StyleBackground other)
 {
     return(other == this);
 }
示例#6
0
 internal StyleBackground(GCHandle gcHandle, StyleKeyword keyword)
 {
     this = new StyleBackground(gcHandle.IsAllocated ? Background.FromObject(gcHandle.Target) : default(Background), keyword);
 }
示例#7
0
 internal StyleBackground(VectorImage v, StyleKeyword keyword)
 {
     this = new StyleBackground(Background.FromVectorImage(v), keyword);
 }
示例#8
0
 internal StyleBackground(Texture2D v, StyleKeyword keyword)
 {
     this = new StyleBackground(Background.FromTexture2D(v), keyword);
 }
示例#9
0
 public StyleBackground(StyleKeyword keyword)
 {
     this = new StyleBackground(default(Background), keyword);
 }
示例#10
0
 public StyleBackground(VectorImage v)
 {
     this = new StyleBackground(v, StyleKeyword.Undefined);
 }
示例#11
0
 public StyleBackground(Texture2D v)
 {
     this = new StyleBackground(v, StyleKeyword.Undefined);
 }
示例#12
0
 public StyleBackground(Background v)
 {
     this = new StyleBackground(v, StyleKeyword.Undefined);
 }