예제 #1
0
        internal NSDictionary ToDictionary()
        {
            int n    = 0;
            var font = Font;

            if (font != null)
            {
                n++;
            }
            var text_color = TextColor;

            if (text_color != null)
            {
                n++;
            }
            var text_shadow_color = TextShadowColor;

            if (text_shadow_color != null)
            {
                n++;
            }
            var text_shadow_offset = TextShadowOffset;

            if (text_shadow_offset.Horizontal != 0 || text_shadow_offset.Vertical != 0)
            {
                n++;
            }
            if (n == 0)
            {
                return(new NSDictionary());
            }

            var keys   = new NSObject [n];
            var values = new NSObject [n];

            n = 0;
            if (font != null)
            {
                keys [n]   = UITextAttributesConstants.Font;
                values [n] = font;
                n++;
            }
            if (text_color != null)
            {
                keys [n]   = UITextAttributesConstants.TextColor;
                values [n] = text_color;
                n++;
            }
            if (text_shadow_color != null)
            {
                keys [n]   = UITextAttributesConstants.TextShadowColor;
                values [n] = text_shadow_color;
                n++;
            }
            if (text_shadow_offset.Horizontal != 0 || text_shadow_offset.Vertical != 0)
            {
                keys [n]   = UITextAttributesConstants.TextShadowOffset;
                values [n] = NSValue.FromUIOffset(text_shadow_offset);
            }
            using (NSArray avalues = NSArray.FromObjects(values),
                   akeys = NSArray.FromObjects(keys)){
                return(NSDictionary.FromObjectsAndKeysInternal(avalues, akeys));
            }
        }