public double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes) { if (Application.FontSize_Get == null) { // We make these up anyway, so new sizes didn't really change // iOS docs say default button font size is 15, default label font size is 17 so we use those as the defaults. switch (size) { case NamedSize.Default: return(typeof(Button).IsAssignableFrom(targetElementType) ? 15 : 17); case NamedSize.Micro: return(12); case NamedSize.Small: return(14); case NamedSize.Medium: return(17); case NamedSize.Large: return(22); default: throw new ArgumentOutOfRangeException("size"); } } else { return(Application.FontSize_Get(size)); } }
public double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes) { if (_smallSize == 0) { _smallSize = ConvertTextAppearanceToSize(Resource.Attribute.TextAppearanceSmall, Resource.Style.TextAppearanceDeviceDefaultSmall, 12); _mediumSize = ConvertTextAppearanceToSize(Resource.Attribute.TextAppearanceMedium, Resource.Style.TextAppearanceDeviceDefaultMedium, 14); _largeSize = ConvertTextAppearanceToSize(Resource.Attribute.TextAppearanceLarge, Resource.Style.TextAppearanceDeviceDefaultLarge, 18); _buttonDefaultSize = ConvertTextAppearanceToSize(Resource.Attribute.TextAppearanceButton, Resource.Style.TextAppearanceDeviceDefaultWidgetButton, 14); _editTextDefaultSize = ConvertTextAppearanceToSize(Resource.Style.TextAppearanceWidgetEditText, Resource.Style.TextAppearanceDeviceDefaultWidgetEditText, 18); _labelDefaultSize = _smallSize; // as decreed by the android docs, ALL HAIL THE ANDROID DOCS, ALL GLORY TO THE DOCS, PRAISE HYPNOTOAD _microSize = Math.Max(1, _smallSize - (_mediumSize - _smallSize)); } if (Application.FontSize_Get == null) { if (useOldSizes) { switch (size) { case NamedSize.Default: if (typeof(Button).IsAssignableFrom(targetElementType)) { return(_buttonDefaultSize); } if (typeof(Label).IsAssignableFrom(targetElementType)) { return(_labelDefaultSize); } if (typeof(Editor).IsAssignableFrom(targetElementType) || typeof(Entry).IsAssignableFrom(targetElementType) || typeof(SearchBar).IsAssignableFrom(targetElementType)) { return(_editTextDefaultSize); } return(14); case NamedSize.Micro: return(10); case NamedSize.Small: return(12); case NamedSize.Medium: return(14); case NamedSize.Large: return(18); default: throw new ArgumentOutOfRangeException("size"); } } switch (size) { case NamedSize.Default: if (typeof(Button).IsAssignableFrom(targetElementType)) { return(_buttonDefaultSize); } if (typeof(Label).IsAssignableFrom(targetElementType)) { return(_labelDefaultSize); } if (typeof(Editor).IsAssignableFrom(targetElementType) || typeof(Entry).IsAssignableFrom(targetElementType)) { return(_editTextDefaultSize); } return(_mediumSize); case NamedSize.Micro: return(_microSize); case NamedSize.Small: return(_smallSize); case NamedSize.Medium: return(_mediumSize); case NamedSize.Large: return(_largeSize); default: throw new ArgumentOutOfRangeException("size"); } } else { return(Application.FontSize_Get(size)); } }