예제 #1
0
        private void InitializeStyleAttributeProperties(IAttributeSet attrs)
        {
            var nameSpace = "http://schemas.android.com.apk/res-auto";

            isChecked = attrs.GetAttributeBooleanValue(nameSpace, "isSelected", false);
            SetViewState();
        }
예제 #2
0
 public Button(Context context, IAttributeSet attrs)
     : base(context, attrs)
 {
     SetDefaultProperties();
     clickAfterRipple = attrs.GetAttributeBooleanValue(MATERIALDESIGNXML, "animate", true);
     Attributes       = attrs;
     beforeBackground = backgroundColor;
     if (rippleColor == null)
     {
         rippleColor = MakePressColor();
     }
 }
예제 #3
0
            public AttributesParser(IAttributeSet attributes)
            {
                MinValue    = ParseFloat(attributes, "min_value", 0);
                MaxValue    = ParseFloat(attributes, "max_value", 1);
                Value       = ParseFloat(attributes, "value", MinValue);
                LabelHidden = attributes.GetAttributeBooleanValue(null, "hide_label", false);
                var typeAttribute          = attributes.GetAttributeValue(null, "progress_type");
                var progressColorAttribute = attributes.GetAttributeValue(null, "progress_color");

                if (typeAttribute == null || typeAttribute == "big")
                {
                    ProgressType = RadialProgressViewStyle.Big;
                }
                else if (typeAttribute == "small")
                {
                    ProgressType = RadialProgressViewStyle.Small;
                }
                else if (typeAttribute == "tiny")
                {
                    ProgressType = RadialProgressViewStyle.Tiny;
                }
                else
                {
                    throw new ArgumentException("Unrecognized RadialProgress type '" + typeAttribute + "'. Must be either 'big', 'small' or 'tiny'.", "progress_type");
                }

                if (!string.IsNullOrEmpty(progressColorAttribute))
                {
                    try
                    {
                        ProgressColor = Color.ParseColor(progressColorAttribute);
                    }
                    catch (AndroidException)
                    {
                        throw new ArgumentException("Wrong color string '" + progressColorAttribute + "'. Must be either '#RRGGBB' or '#AARRGGBB'.", "progress_color");
                    }
                }
            }
예제 #4
0
 protected void InitAttributeSet(IAttributeSet attrs)
 {
     for (int i = 0; i < attrs.AttributeCount; i++)
     {
         try
         {
             if (attrs.GetAttributeName(i) == "is_enabled")
             {
                 this.IsEnabled = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "is_name_visible")
             {
                 this.IsNameVisible = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "is_percent_visible")
             {
                 this.IsPercentVisible = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "is_value_visible")
             {
                 this.IsValueVisible = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "background_color")
             {
                 try
                 {
                     string value = attrs.GetAttributeValue(i);
                     var    color = Android.Graphics.Color.ParseColor(value);
                     this.BackgroundColor = new NGraphics.Color(color.R, color.G, color.B);
                 }
                 catch (Exception)
                 {
                 }
             }
             if (attrs.GetAttributeName(i) == "is_single_selectable")
             {
                 this.IsSingleSelectable = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "is_title_on_top")
             {
                 this.IsTitleOnTop = attrs.GetAttributeBooleanValue(i, true);
             }
             if (attrs.GetAttributeName(i) == "percent_color")
             {
                 try
                 {
                     string value = attrs.GetAttributeValue(i);
                     var    color = Android.Graphics.Color.ParseColor(value);
                     this.PercentColor = new NGraphics.Color(color.R, color.G, color.B);
                 }
                 catch (Exception)
                 {
                 }
             }
             if (attrs.GetAttributeName(i) == "text_color")
             {
                 try
                 {
                     string value = attrs.GetAttributeValue(i);
                     var    color = Android.Graphics.Color.ParseColor(value);
                     this.TextColor = new NGraphics.Color(color.R, color.G, color.B);
                 }
                 catch (Exception)
                 {
                 }
             }
             if (attrs.GetAttributeName(i) == "value_color")
             {
                 try
                 {
                     string value = attrs.GetAttributeValue(i);
                     var    color = Android.Graphics.Color.ParseColor(value);
                     this.ValueColor = new NGraphics.Color(color.R, color.G, color.B);
                 }
                 catch (Exception)
                 {
                 }
             }
             if (attrs.GetAttributeName(i) == "title_color")
             {
                 try
                 {
                     string value = attrs.GetAttributeValue(i);
                     var    color = Android.Graphics.Color.ParseColor(value);
                     this.TitleColor = new NGraphics.Color(color.R, color.G, color.B);
                 }
                 catch (Exception)
                 {
                 }
             }
             if (attrs.GetAttributeName(i) == "pull_ratio")
             {
                 this.PullRatio = attrs.GetAttributeFloatValue(i, 0.1f);
             }
             if (attrs.GetAttributeName(i) == "start_angle")
             {
                 this.StartAngle = attrs.GetAttributeFloatValue(i, 0.0f);
             }
             if (attrs.GetAttributeName(i) == "title")
             {
                 this.Title = attrs.GetAttributeValue(i);
             }
         }
         catch (Exception)
         {
         }
     }
 }