private View OnDrawView(string name, Context context, IAttributeSet attrs)
        {
            View view = null;

            try
            {
                if (name.IndexOf('.') == -1)
                {
                    if ("View".Equals(name))
                    {
                        view = LayoutInflater.From(context).CreateView(name, "android.view.", attrs);
                    }
                    if (view == null)
                    {
                        view = LayoutInflater.From(context).CreateView(name, "android.widget.", attrs);
                    }
                    if (view == null)
                    {
                        view = LayoutInflater.From(context).CreateView(name, "android.webkit.", attrs);
                    }
                }
                else
                {
                    if (view == null)
                    {
                        view = LayoutInflater.From(context).CreateView(name, null, attrs);
                    }
                }
                if (view != null)
                {
                    for (int i = 0; i < attrs.AttributeCount; i++)
                    {
                        if (attrs.GetAttributeName(i).Equals(ChangeModeController.ATTR_BACKGROUND))
                        {
                            Controller.BackGroundViews.Add(new AttrEntity <View>(view, Controller.GetAttr(mClass, attrs.GetAttributeValue(i))));
                        }
                        if (attrs.GetAttributeName(i).Equals(ChangeModeController.ATTR_TEXTCOLOR))
                        {
                            Controller.TextColorViews.Add(new AttrEntity <TextView>((TextView)view, Controller.GetAttr(mClass, attrs.GetAttributeValue(i))));
                        }
                        if (attrs.GetAttributeName(i).Equals(ChangeModeController.ATTR_BACKGROUND_DRAWABLE))
                        {
                            Controller.BackGroundDrawableViews.Add(new AttrEntity <View>(view, Controller.GetAttr(mClass, attrs.GetAttributeValue(i))));
                        }
                    }
                }
            }
            catch { }
            return(view);
        }
        private void Init(IAttributeSet attrs)
        {
            int count = attrs.AttributeCount;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    string name = attrs.GetAttributeName(i);

                    if (name != null && name.Equals("numColumns"))
                    {
                        this.mNumColumnsID = attrs.GetAttributeResourceValue(i, 1);
                        UpdateColumns();
                        break;
                    }
                }
            }
            Console.WriteLine("numColumns set to: " + NumColumns);
        }
Example #3
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)
         {
         }
     }
 }