private void ReadAttrs(Context context, IAttributeSet attrs, int defStyle) { TypedArray typedArray = context.ObtainStyledAttributes(attrs, Resource.Styleable.GaugeView, defStyle, 0); mShowOuterShadow = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterShadow, SHOW_OUTER_SHADOW); mShowOuterBorder = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterBorder, SHOW_OUTER_BORDER); mShowOuterRim = typedArray.GetBoolean(Resource.Styleable.GaugeView_showOuterRim, SHOW_OUTER_RIM); mShowInnerRim = typedArray.GetBoolean(Resource.Styleable.GaugeView_showInnerRim, SHOW_INNER_RIM); mShowNeedle = typedArray.GetBoolean(Resource.Styleable.GaugeView_showNeedle, SHOW_NEEDLE); mShowScale = typedArray.GetBoolean(Resource.Styleable.GaugeView_showScale, SHOW_SCALE); mShowRanges = typedArray.GetBoolean(Resource.Styleable.GaugeView_showRanges, SHOW_RANGES); mShowText = typedArray.GetBoolean(Resource.Styleable.GaugeView_showText, SHOW_TEXT); mOuterShadowWidth = mShowOuterShadow ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerShadowWidth, OUTER_SHADOW_WIDTH) : 0.0f; mOuterBorderWidth = mShowOuterBorder ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerBorderWidth, OUTER_BORDER_WIDTH) : 0.0f; mOuterRimWidth = mShowOuterRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_outerRimWidth, OUTER_RIM_WIDTH) : 0.0f; mInnerRimWidth = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimWidth, INNER_RIM_WIDTH) : 0.0f; mInnerRimBorderWidth = mShowInnerRim ? typedArray.GetFloat(Resource.Styleable.GaugeView_innerRimBorderWidth, INNER_RIM_BORDER_WIDTH) : 0.0f; mNeedleWidth = typedArray.GetFloat(Resource.Styleable.GaugeView_needleWidth, NEEDLE_WIDTH); mNeedleHeight = typedArray.GetFloat(Resource.Styleable.GaugeView_needleHeight, NEEDLE_HEIGHT); mScalePosition = (mShowScale || mShowRanges) ? typedArray.GetFloat(Resource.Styleable.GaugeView_scalePosition, SCALE_POSITION) : 0.0f; mScaleStartValue = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartValue, SCALE_START_VALUE); mScaleEndValue = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndValue, SCALE_END_VALUE); mScaleStartAngle = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleStartAngle, SCALE_START_ANGLE); mScaleEndAngle = typedArray.GetFloat(Resource.Styleable.GaugeView_scaleEndAngle, 360.0f - mScaleStartAngle); mDivisions = typedArray.GetInteger(Resource.Styleable.GaugeView_divisions, SCALE_DIVISIONS); mSubdivisions = typedArray.GetInteger(Resource.Styleable.GaugeView_subdivisions, SCALE_SUBDIVISIONS); if (mShowRanges) { mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR); string[] rangeValues = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeValues); string[] rangeColors = typedArray.GetTextArray(Resource.Styleable.GaugeView_rangeColors); ReadRanges(rangeValues, rangeColors); } if (mShowText) { int textValueId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textValue, 0); string textValue = typedArray.GetString(Resource.Styleable.GaugeView_textValue); mTextValue = (0 < textValueId) ? context.GetString(textValueId) : (null != textValue) ? textValue : ""; int textUnitId = typedArray.GetResourceId(Resource.Styleable.GaugeView_textUnit, 0); string textUnit = typedArray.GetString(Resource.Styleable.GaugeView_textUnit); mTextUnit = (0 < textUnitId) ? context.GetString(textUnitId) : (null != textUnit) ? textUnit : ""; mTextValueColor = typedArray.GetColor(Resource.Styleable.GaugeView_textValueColor, TEXT_VALUE_COLOR); mTextUnitColor = typedArray.GetColor(Resource.Styleable.GaugeView_textUnitColor, TEXT_UNIT_COLOR); mTextShadowColor = typedArray.GetColor(Resource.Styleable.GaugeView_textShadowColor, TEXT_SHADOW_COLOR); mTextValueSize = typedArray.GetFloat(Resource.Styleable.GaugeView_textValueSize, TEXT_VALUE_SIZE); mTextUnitSize = typedArray.GetFloat(Resource.Styleable.GaugeView_textUnitSize, TEXT_UNIT_SIZE); } typedArray.Recycle(); }
public string[] GetTextArray(int index) { return(_array.GetTextArray(index)); }