Example #1
0
        private void InitializeFromAttributes(Context context, IAttributeSet attrs)
        {
            var attr = context.ObtainStyledAttributes(attrs, Resource.Styleable.FloatingActionMenu, 0, 0);

            Icon = attr.GetDrawable(Resource.Styleable.FloatingActionMenu_buttonIcon)
                   ?? ResourcesCompat.GetDrawable(Resources, Resource.Drawable.fab_add, null);
            BackgroundColor = attr.GetColor(Resource.Styleable.FloatingActionMenu_buttonBackgroundColor, unchecked ((int)0xFF263238));
            ButtonElevation = attr.GetFloat(Resource.Styleable.FloatingActionMenu_buttonElevation, 0.0f);
            ButtonSpacing   = attr.GetInteger(Resource.Styleable.FloatingActionMenu_buttonSpacing, BUTTON_SPACING);
            OpenOnHold      = attr.GetBoolean(Resource.Styleable.FloatingActionMenu_openOnHold, false);
            OpenDirection   = attr.GetInteger(Resource.Styleable.FloatingActionMenu_openDirection, OPEN_UP);

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentLeft"), out bool alignLeft))
            {
                _alignLeft = alignLeft;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentTop"), out bool alignTop))
            {
                _alignTop = alignTop;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentRight"), out bool alignRight))
            {
                _alignRight = alignRight;
            }

            if (bool.TryParse(attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_alignParentBottom"), out bool alignBottom))
            {
                _alignBottom = alignBottom;
            }


            CreateMenuButton();
        }
Example #2
0
        public SeekBarPreference(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            mContext = context;

            mDialogMessage = attrs.GetAttributeValue(androidns, "dialogMessage");
            mSuffix        = attrs.GetAttributeValue(androidns, "text");
            mDefault       = attrs.GetAttributeIntValue(androidns, "defaultValue", 0);
            mMax           = attrs.GetAttributeIntValue(androidns, "max", 100);
            mValue         = GetPersistedInt(mDefault);
        }
Example #3
0
            public MapViewLayoutParams(Context context, IAttributeSet attrs)
                : base(context, attrs)
            {
                this.X = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
                this.Y = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
                String geoPoint = attrs.GetAttributeValue("http://schemas.mapquest.com/apk/res/mapquest", "geoPoint");

                if ((geoPoint.Length > 0))
                {
                    String[] arr = geoPoint.Split(new[] { "," }, StringSplitOptions.None);
                    if (arr.Length > 1)
                    {
                        try
                        {
                            double latitude  = Double.Parse(arr[0].Trim());
                            double longitude = Double.Parse(arr[1].Trim());
                            this.Point = new GeoPoint(latitude, longitude);
                            this.Mode  = 0;
                        }
                        catch (NumberFormatException nfe)
                        {
                            Log.Error("mq.android.maps.mapview", "Invalid value for geoPoint attribute : " + geoPoint);
                        }
                    }
                }
            }
Example #4
0
 public MapViewLayoutParams(Context context, IAttributeSet attrs)
     : base(context, attrs)
 {
     this.X = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
     this.Y = attrs.GetAttributeIntValue("http://schemas.mapquest.com/apk/res/mapquest", "x", int.MaxValue);
     String geoPoint = attrs.GetAttributeValue("http://schemas.mapquest.com/apk/res/mapquest", "geoPoint");
     if ((geoPoint.Length > 0))
     {
         String[] arr = geoPoint.Split(new[] { "," }, StringSplitOptions.None);
         if (arr.Length > 1)
         {
             try
             {
                 double latitude = Double.Parse(arr[0].Trim());
                 double longitude = Double.Parse(arr[1].Trim());
                 this.Point = new GeoPoint(latitude, longitude);
                 this.Mode = 0;
             }
             catch (NumberFormatException nfe)
             {
                 Log.Error("mq.android.maps.mapview", "Invalid value for geoPoint attribute : " + geoPoint);
             }
         }
     }
 }
        public SlidingTabLayoutPlus(Context context, IAttributeSet attrs)
            : base(context, attrs, 0)
        {
            this.mContext = context;
            SetFitsSystemWindows(true);
            SetWillNotDraw(false);//重写onDraw方法,需要调用这个方法来清除flag
            SetClipChildren(false);
            SetClipToPadding(false);

            this.mContext  = context;
            mTabsContainer = new LinearLayout(context);
            AddView(mTabsContainer);

            obtainAttributes(context, attrs);

            var height = attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");// model.GetValue("layout_height");//  .GetAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");

            if (height.Equals(ViewGroup.LayoutParams.MatchParent + ""))
            {
            }
            else if (height.Equals(ViewGroup.LayoutParams.WrapContent + ""))
            {
            }
            else
            {
                int[]      systemAttrs = { Android.Resource.Attribute.LayoutHeight };
                TypedArray a           = context.ObtainStyledAttributes(attrs, systemAttrs);
                mHeight = a.GetDimensionPixelSize(0, ViewGroup.LayoutParams.WrapContent);
                a.Recycle();
            }
        }
        /// <summary>
        /// Tries to pull the Custom Attribute directly from the TextView.
        /// </summary>
        /// <param name="context">Activity Context.</param>
        /// <param name="attrs">View Attributes.</param>
        /// <param name="attributeId">f -1 returns null.</param>
        /// <returns>null if attribute is not defined or added to View</returns>
        internal static string PullFontPathFromView(Context context, IAttributeSet attrs, int attributeId)
        {
            if (attributeId == -1 || attrs == null)
            {
                return(null);
            }

            string attributeName;

            try
            {
                attributeName = context.Resources.GetResourceEntryName(attributeId);
            }
            catch (Resources.NotFoundException e)
            {
                // invalid attribute ID
                return(null);
            }

            var stringResourceId = attrs.GetAttributeResourceValue(null, attributeName, -1);

            return(stringResourceId > 0
                    ? context.GetString(stringResourceId)
                    : attrs.GetAttributeValue(null, attributeName));
        }
Example #7
0
        private void Initialize(IAttributeSet attrs = null)
        {
            Focusable = true;
            Holder.AddCallback(this);
            SetZOrderOnTop(true);
            Holder.SetFormat(Format.Transparent);

            if (attrs == null)
            {
                _gifMovie    = null;
                _movieWidth  = 0;
                _movieHeight = 0;
            }
            else
            {
                this.InitializeAttributes(attrs);
                string filePath;
                var    resourceId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
                if (resourceId > 0)
                {
                    var inputStream = Context.Resources.OpenRawResource(resourceId);
                    SetAnimationStream(inputStream);
                }
                else if (!string.IsNullOrEmpty((filePath = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "file_path"))))
                {
                    FilePath = filePath;
                }
            }
        }
Example #8
0
        void ProcessAttributeSets(IAttributeSet attrs)
        {
            var resID = attrs.GetAttributeResourceValue(null, "description", -1);
            var val   = resID == -1 ?
                        attrs.GetAttributeValue(null, "description")
                                : Context.Resources.GetString(resID);

            desc = (val ?? string.Empty).ToUpper();
        }
        public DirectionArrow(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            var dirAttr = attrs.GetAttributeValue(null, "direction");

            Enum.TryParse(dirAttr, out _dir);

            Create();
        }
        public DirectionArrow(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {

            var dirAttr = attrs.GetAttributeValue(null, "direction");
            Enum.TryParse(dirAttr, out _dir);

            Create();
        }
Example #11
0
        private void Initialize(IAttributeSet attrs = null)
        {
            this.InitializeAttributes(attrs);
            string file = attrs?.GetAttributeValue(ElementExtensions.XmlNamespace, "filePath");

            if (file != null)
            {
                FilePath = file;
            }
        }
        private string GetAttributeStringValue(IAttributeSet attrs, string nameSpace, string name, string defaultValue)
        {
            var value = attrs.GetAttributeValue(nameSpace, name);

            if (value == null)
            {
                value = defaultValue;
            }

            return(value);
        }
Example #13
0
        public HttpImageView(Context context, IAttributeSet attrs, int defStyle) :
            base(context, attrs, defStyle)
        {
            HttpImageUrl = attrs.GetAttributeValue(null, "httpmageurl");
            var attr = attrs.GetAttributeValue(null, "usecache");
            var val  = false;

            bool.TryParse(attr, out val);
            UseCache = val;
            var samplesize = attrs.GetAttributeValue(null, "samplesize");
            var s          = 1;

            int.TryParse(samplesize, out s);
            if (s == 0)
            {
                s = 1;
            }
            SampleSize = s;
            Initialize();
        }
Example #14
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");
                    }
                }
            }
Example #15
0
        private void Init(Context context, IAttributeSet attrs)
        {
            ; var array     = context.ObtainStyledAttributes(attrs, Resource.Styleable.CustomTextView);
            var   textStyle = array.GetString(Resource.Styleable.CustomTextView_textStyle);
            var   type      = TypefaceHelper.GeTypeface(context, textStyle);

            SetTypeface(type, TypefaceStyle.Normal);
            var background = attrs.GetAttributeValue("http://schemas.android.com/apk/res/android", "background");

            if (String.IsNullOrEmpty(background))
            {
                SetBackgroundResource(Android.Resource.Color.Transparent);
            }
        }
Example #16
0
        public PriceButton(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            LayoutInflater.From(context).Inflate(Resource.Layout.PriceButton, this);

            _bigFiguresTextView = FindViewById<TextView>(Resource.Id.PriceButtonBigFiguresTextView);
            _pipsTextView = FindViewById<TextView>(Resource.Id.PriceButtonPipsTextView);
            _tenthOfPipTextView = FindViewById<TextView>(Resource.Id.PriceButtonTenthOfPipTextView);
            _progressView = FindViewById<ProgressBar>(Resource.Id.PriceButtonProgress);
            _contentView = FindViewById<LinearLayout>(Resource.Id.PriceButtonContent);

            var directionLabelTextView = FindViewById<TextView>(Resource.Id.PriceButtonDirectionTextView);
            directionLabelTextView.Text = attrs.GetAttributeValue(null, "direction_label");

            Click += PriceButton_Click;
        }
Example #17
0
        public static double ParseThickness(IAttributeSet attrs, string thickness, int currentThickness)
        {
            var thicknessRes = attrs.GetAttributeResourceValue(XmlNamespace, thickness, 0);

            if (thicknessRes > 0)
            {
                return((int)(DroidFactory.MainActivity.Resources.GetDimension(thicknessRes) / DroidFactory.DisplayScale));
            }
            var thicknessAttr = attrs.GetAttributeValue(XmlNamespace, thickness);

            if (thicknessAttr != null && double.TryParse(thicknessAttr.TrimEnd('s', 'd', 'p', 'x'), out double value))
            {
                return(value);
            }
            return(currentThickness);
        }
Example #18
0
        public PriceButton(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            LayoutInflater.From(context).Inflate(Resource.Layout.PriceButton, this);

            _bigFiguresTextView = FindViewById <TextView>(Resource.Id.PriceButtonBigFiguresTextView);
            _pipsTextView       = FindViewById <TextView>(Resource.Id.PriceButtonPipsTextView);
            _tenthOfPipTextView = FindViewById <TextView>(Resource.Id.PriceButtonTenthOfPipTextView);
            _progressView       = FindViewById <ProgressBar>(Resource.Id.PriceButtonProgress);
            _contentView        = FindViewById <LinearLayout>(Resource.Id.PriceButtonContent);

            var directionLabelTextView = FindViewById <TextView>(Resource.Id.PriceButtonDirectionTextView);

            directionLabelTextView.Text = attrs.GetAttributeValue(null, "direction_label");

            Click += PriceButton_Click;
        }
        private void SetValuesFromXml(IAttributeSet attrs)
        {
            maxValue = attrs.GetAttributeIntValue(ANDROIDNS, "max", 100);
            minValue = attrs.GetAttributeIntValue(APPLICATIONNS, "min", 0);

            unitsLeft = GetAttributeStringValue(attrs, APPLICATIONNS, "unitsLeft", "");
            var units = GetAttributeStringValue(attrs, APPLICATIONNS, "units", "");

            unitsRight = GetAttributeStringValue(attrs, APPLICATIONNS, "unitsRight", units);

            var newInterval = attrs.GetAttributeValue(APPLICATIONNS, "interval");

            if (newInterval != null)
            {
                int.TryParse(newInterval, out interval);
            }
        }
Example #20
0
        public static void SetColor(this IElement element, IAttributeSet attrs, string propertyName)
        {
            string color = attrs.GetAttributeValue(XmlNamespace, char.ToLowerInvariant(propertyName[0]) + propertyName.Substring(1));

            if (color != null)
            {
                var colorProp = Device.Reflector.GetProperty(typeof(Color), color);
                if (colorProp != null)
                {
                    var value = colorProp.GetValue(Color.Transparent);
                    Device.Reflector.GetProperty(element.GetType(), propertyName)?.SetValue(element, value);
                }
                else
                {
                    Device.Reflector.GetProperty(element.GetType(), propertyName)?.SetValue(element, new Color(color));
                }
            }
        }
Example #21
0
            float ParseFloat(IAttributeSet attributes, string attributeName, float defaultNumber)
            {
                var numberAttr = attributes.GetAttributeValue(null, attributeName);

                if (string.IsNullOrEmpty(numberAttr))
                {
                    return(defaultNumber);
                }

                float result;

                if (float.TryParse(numberAttr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out result))
                {
                    return(result);
                }
                else
                {
                    throw new ArgumentException("Wrong " + attributeName + " value '" + numberAttr + "'. Must be a number.");
                }
            }
Example #22
0
        public global::Android.Views.View OnCreateView(string name, Context context, IAttributeSet attrs)
        {
            String viewFullName = string.Format("android.widget.{0}", name); // this is bad as it will only do the normal controls....
            var    id           = attrs.GetAttributeValue(BindingConstants.BindingNamespace, BindingConstants.IdString);

            var view = _layoutInflater.CreateView(viewFullName, null, attrs);

            if (view == null || id == null)
            {
                return(view);
            }

            var node = FindNodeWithId(_rootnode, id);

            if (node != null)
            {
                BindingFactory bf = new BindingFactory();
                foreach (var property in node.Value.Properties)
                {
                    Add(view, property.Value, node.Value);
                }
            }
            return(view);
        }
        private string GetAttributeStringValue(IAttributeSet attrs, string nameSpace, string name, string defaultValue)
        {
            var value = attrs.GetAttributeValue (nameSpace, name);

            if (value == null)
                value = defaultValue;

            return value;
        }
        public IonTextView(Context context, IAttributeSet attrs)
            : base(context, attrs)
        {
            this.context = context;

            for (int i = 0; i < attrs.AttributeCount; i++)
            {
                this.ttfName = attrs.GetAttributeValue("http://schemas.android.com/apk/res/com.gem.nwtbiblefree", "ttf");

                init();
            }
        }
Example #25
0
        private void Initialize(IAttributeSet attrs = null)
        {
            MaxHeight = double.PositiveInfinity;
            Columns   = new ColumnCollection();
            Rows      = new RowCollection();

            ChildViewAdded   -= GridBase_ChildViewAdded;
            ChildViewAdded   += GridBase_ChildViewAdded;
            ChildViewRemoved -= GridBase_ChildViewRemoved;
            ChildViewRemoved += GridBase_ChildViewRemoved;

            if (attrs == null)
            {
                return;
            }
            var rowCountString = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "rows");
            var rows           = rowCountString?.Split(',');

            if (rows?.Length == 1 && int.TryParse(rows[0], out int rowCount))
            {
                this.SetRows(rowCount);
            }
            else if (rows?.Length > 0)
            {
                foreach (var row in rows)
                {
                    if (row.Contains('*'))
                    {
                        double.TryParse(row.Replace("*", string.Empty), out double height);
                        Rows.Add(new Row(height == 0 ? 1 : height, LayoutUnitType.Star));
                    }
                    else if (row.ToUpper().StartsWith("A"))
                    {
                        Rows.Add(Row.AutoSized);
                    }
                    else
                    {
                        var height = double.Parse(row);
                        Rows.Add(new Row(height, LayoutUnitType.Absolute));
                    }
                }
            }
            var columns = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "columns")?.Split(',');

            if (columns?.Length == 1 && int.TryParse(columns[0], out int columnCount))
            {
                this.SetColumns(columnCount);
            }
            else if (columns?.Length > 0)
            {
                foreach (var column in columns)
                {
                    if (column.Contains('*'))
                    {
                        double.TryParse(column.Replace("*", string.Empty), out double width);
                        Columns.Add(new Column(width == 0 ? 1 : width, LayoutUnitType.Star));
                    }
                    else if (column.ToUpper().StartsWith("A"))
                    {
                        Columns.Add(Column.AutoSized);
                    }
                    else
                    {
                        var width = double.Parse(column);
                        Columns.Add(new Column(width, LayoutUnitType.Absolute));
                    }
                }
            }
            string padding = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "padding");

            if (!string.IsNullOrEmpty(padding))
            {
                var padValues = padding.Split(',').Select(p => p.TryParseDouble()).ToList();
                switch (padValues.Count)
                {
                case 1:
                    Padding = new Thickness(padValues[0]);
                    break;

                case 2:
                    Padding = new Thickness(padValues[0], padValues[1]);
                    break;

                case 4:
                    Padding = new Thickness(padValues[0], padValues[1], padValues[2], padValues[3]);
                    break;

                default:
                    throw new FormatException("Invalid padding format: " + padding);
                }
            }

            var left   = ElementExtensions.ParseThickness(attrs, "paddingLeft", (int)Padding.Left);
            var top    = ElementExtensions.ParseThickness(attrs, "paddingTop", (int)Padding.Top);
            var right  = ElementExtensions.ParseThickness(attrs, "paddingRight", (int)Padding.Right);
            var bottom = ElementExtensions.ParseThickness(attrs, "paddingBottom", (int)Padding.Bottom);

            Padding = new Thickness(left, top, right, bottom);
        }
        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);
        }
Example #27
0
 void ProcessAttributeSets(IAttributeSet attrs)
 {
     var resID = attrs.GetAttributeResourceValue (null, "description", -1);
     var val = resID == -1 ?
         attrs.GetAttributeValue (null, "description")
         : Context.Resources.GetString (resID);
     desc = (val ?? string.Empty).ToUpper ();
 }
Example #28
0
            public View OnCreateView(string name, Context context, IAttributeSet attrs)
            {
                // string ns = "http://schemas.android.com/apk/res-auto";
                string ns_ = "http://schemas.android.com/apk/res/android";

                string tag_ = ToolCell.isNull(attrs.GetAttributeValue(ns_, "tag"), string.Empty).ToString();
                // string style_ = ToolCell.isNull(attrs.GetAttributeValue(ns_, "style"), string.Empty).ToString();
                string type_ = ToolObjectName.getArgValue(tag_, ConstCmdLine.type);


                //ToolMobile.log("OnCreateView [" + name + "] with tag [" + tag_ + "]");

                View v = null;

                switch (name)
                {
                case "GridView":
                    if (type_ == "grid")
                    {
                        v = new MobDataGrid(context, attrs);
                    }
                    break;

                case "ExpandableListView":
                    if (type_ == "tree")
                    {
                        v = new MobTreeView(context, attrs);
                    }
                    break;

                case "ListView":
                    if (type_ == "list")
                    {
                        v = new MobListView(context, attrs);
                    }
                    break;

                case "LinearLayout":
                    if (type_ == "numinput")
                    {
                        v = new MobNumInput(context, attrs);
                    }
                    else
                    {
                        v = new MobPanel(context, attrs);
                    }
                    break;

                case "RelativeLayout":
                {
                    v = new MobPanelRelative(context, attrs);
                }
                break;

                case "FrameLayout":
                {
                    v = new MobFrame(context, attrs);
                }
                break;

                case "TextView":
                {
                    v = new MobLabel(context, attrs);
                }
                break;

                case "EditText":
                    if (type_ == "num")
                    {
                        v = new MobNumEdit(context, attrs);
                    }
                    else
                    if (type_ == "date")
                    {
                        v = new MobDateEdit(context, attrs);
                    }
                    else
                    {
                        v = new MobTextBox(context, attrs);
                    }
                    break;

                case "Button":
                {
                    v = new MobButton(context, attrs);
                }
                break;

                case "DatePicker":
                {
                    v = new MobDatePicker(context, attrs);
                }
                break;

                case "TimePicker":
                {
                    v = new MobTimePicker(context, attrs);
                }
                break;

                case "TabHost":
                {
                    v = new MobTabControl(context, attrs);
                }
                break;
                }

                //  if (v == null)
                //     ToolMobile.log("OnCreateView undefined for [" + name + "] with tag [" + tag_ + "]");


                return(v);
            }
Example #29
0
        public static void InitializeAttributes(this IElement element, IAttributeSet attrs)
        {
            if (element is View view && view.Id > 0)
            {
                element.ID = DroidFactory.MainActivity.Resources.GetResourceEntryName(view.Id);
            }

            if (attrs == null)
            {
                return;
            }
            const int adj    = Element.AutoLayoutIndex + 1;
            var       column = attrs.GetAttributeIntValue(XmlNamespace, "column", adj);

            if (column > adj)
            {
                element.ColumnIndex = column - 1;
            }
            var columnSpan = attrs.GetAttributeIntValue(XmlNamespace, "columnSpan", 1);

            if (columnSpan > 1)
            {
                element.ColumnSpan = columnSpan;
            }
            var row = attrs.GetAttributeIntValue(XmlNamespace, "row", adj);

            if (row > adj)
            {
                element.RowIndex = row - 1;
            }
            var rowSpan = attrs.GetAttributeIntValue(XmlNamespace, "rowSpan", 1);

            if (rowSpan > 1)
            {
                element.RowSpan = rowSpan;
            }
            var hAligns             = Enum.GetNames(typeof(HorizontalAlignment)).Select(h => h.ToLower()).ToArray();
            var horizontalAlignment = attrs.GetAttributeListValue(XmlNamespace, "horizontalAlignment", hAligns, 0);

            if (horizontalAlignment > 0)
            {
                element.HorizontalAlignment = (HorizontalAlignment)horizontalAlignment;
            }
            var vAligns           = Enum.GetNames(typeof(VerticalAlignment)).Select(v => v.ToLower()).ToArray();
            var verticalAlignment = attrs.GetAttributeListValue(XmlNamespace, "verticalAlignment", vAligns, 0);

            if (verticalAlignment > 0)
            {
                element.VerticalAlignment = (VerticalAlignment)verticalAlignment;
            }
            var visibles   = Enum.GetNames(typeof(Visibility)).Select(v => v.ToLower()).ToArray();
            var visibility = attrs.GetAttributeListValue(XmlNamespace, "visibility", visibles, 0);

            if (visibility > 0)
            {
                element.Visibility = (Visibility)visibility;
            }

            string font = attrs.GetAttributeValue(XmlNamespace, "font");

            if (font != null)
            {
                var fontProp = Device.Reflector.GetProperty(typeof(Font), font);
                if (fontProp != null)
                {
                    var value = fontProp.GetValue(Font.PreferredLabelFont);
                    Device.Reflector.GetProperty(element.GetType(), "Font")?.SetValue(element, value);
                }
                else
                {
                    var defaults     = MXContainer.Resolve <IPlatformDefaults>(typeof(IPlatformDefaults));
                    var defaultsProp = Device.Reflector.GetProperty(defaults.GetType(), font);
                    if (defaultsProp != null)
                    {
                        var value = defaultsProp.GetValue(defaults);
                        Device.Reflector.GetProperty(element.GetType(), "Font")?.SetValue(element, value);
                    }
                }
            }

            element.SetColor(attrs, "BackgroundColor");
            element.SetColor(attrs, "ForegroundColor");

            var margin = attrs.GetAttributeValue(XmlNamespace, "margin");

            if (!string.IsNullOrEmpty(margin))
            {
                var padValues = margin.Split(',').Select(p => p.TryParseDouble()).ToList();
                switch (padValues.Count)
                {
                case 1:
                    element.Margin = new Thickness(padValues[0]);
                    break;

                case 2:
                    element.Margin = new Thickness(padValues[0], padValues[1]);
                    break;

                case 4:
                    element.Margin = new Thickness(padValues[0], padValues[1], padValues[2], padValues[3]);
                    break;

                default:
                    throw new FormatException("Invalid margin format: " + margin);
                }
            }

            var left   = ParseThickness(attrs, "marginLeft", (int)element.Margin.Left);
            var top    = ParseThickness(attrs, "marginTop", (int)element.Margin.Top);
            var right  = ParseThickness(attrs, "marginRight", (int)element.Margin.Right);
            var bottom = ParseThickness(attrs, "marginBottom", (int)element.Margin.Bottom);

            element.Margin = new Thickness(left, top, right, bottom);

            var submitKey = attrs.GetAttributeValue(XmlNamespace, "submitKey");

            if (submitKey != null && element is IControl control)
            {
                control.SubmitKey = submitKey;
            }
        }
Example #30
0
 public InsetTextView(Context context, IAttributeSet attrs, int defStyle) :
     base(context, attrs, defStyle)
 {
     text = attrs.GetAttributeValue(null, "text");
     Initialize();
 }
        void Initialize(IAttributeSet attrs = null)
        {
            maxValue = 127;

            if (attrs != null) {
                channel_name = attrs.GetAttributeValue ("http://schemas.android.com/apk/lib/QuMixDroid_Controls", "channel_name");
            }
        }
Example #32
0
 private void LoadValuesFromXml(IAttributeSet attrs)
 {
     _title = attrs.GetAttributeValue(XmlNamespaceAndroid, "title");
     _units = attrs.GetAttributeValue(XmlNamespaceSessions, "units");
 }
Example #33
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)
         {
         }
     }
 }
Example #34
0
 public InsetTextView(Context context, IAttributeSet attrs, int defStyle)
     : base(context, attrs, defStyle)
 {
     text = attrs.GetAttributeValue (null, "text");
     Initialize ();
 }
        public global::Android.Views.View OnCreateView(string name, Context context, IAttributeSet attrs)
        {
            String viewFullName = string.Format("android.widget.{0}", name); // this is bad as it will only do the normal controls....
            var id = attrs.GetAttributeValue(BindingConstants.BindingNamespace, BindingConstants.IdString);

            var view = _layoutInflater.CreateView(viewFullName, null, attrs);

            if (view == null || id == null)
            {
                return view;
            }

            var node = FindNodeWithId(_rootnode, id);

            if (node != null)
            {
                BindingFactory bf = new BindingFactory();
                foreach (var property in node.Value.Properties)
                {
                    Add(view, property.Value, node.Value);
                }

            }
            return view;
        }
        private void SetValuesFromXml(IAttributeSet attrs)
        {
            maxValue = attrs.GetAttributeIntValue (ANDROIDNS, "max", 100);
            minValue = attrs.GetAttributeIntValue (APPLICATIONNS, "min", 0);

            unitsLeft = GetAttributeStringValue (attrs, APPLICATIONNS, "unitsLeft", "");
            var units = GetAttributeStringValue (attrs, APPLICATIONNS, "units", "");
            unitsRight = GetAttributeStringValue (attrs, APPLICATIONNS, "unitsRight", units);

            var newInterval = attrs.GetAttributeValue (APPLICATIONNS, "interval");
            if (newInterval != null)
                int.TryParse (newInterval, out interval);
        }