示例#1
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            base.Apply(stylesheet, styleBound, maxBound);

            // background color, borders
            style.SetBackgroundSettings(this);

            // text color
            _view.TextColor = style.ColorOrClear <BitMobile.Controls.StyleSheet.Color> (this);

            // placeholder color
            _placeholderColor = style.Color <PlaceholderColor> (this);
            SetupPlaceholder(_placeholder);

            // font
            UIFont f = style.Font(this, styleBound.Height);

            if (f != null)
            {
                _view.Font = f;
            }

            // padding
            _view.PaddingLeft   = style.Padding <PaddingLeft> (this, styleBound.Width);
            _view.PaddingTop    = style.Padding <PaddingTop> (this, styleBound.Height);
            _view.PaddingRight  = style.Padding <PaddingRight> (this, styleBound.Width);
            _view.PaddingBottom = style.Padding <PaddingBottom> (this, styleBound.Height);

            // text align
            switch (style.TextAlign(this))
            {
            case TextAlign.Align.Left:
                _view.TextAlignment = UITextAlignment.Left;
                break;

            case TextAlign.Align.Center:
                _view.TextAlignment = UITextAlignment.Center;
                break;

            case TextAlign.Align.Right:
                _view.TextAlignment = UITextAlignment.Right;
                break;
            }

            _view.Text = _text;

            return(styleBound);
        }
示例#2
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            // background color, background image, borders
            if (!InitBackgroundImage(stylesheet))
            {
                style.SetBackgroundSettings(this);
            }
            _backgroundColor = _view.BackgroundColor;

            // selected-color
            _selectedColor = style.Color <SelectedColor> (this);

            return(LayoutChildren(stylesheet, styleBound, maxBound));
        }
示例#3
0
		public override Bound Apply (StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
		{
			base.Apply (stylesheet, styleBound, maxBound);

			StyleHelper style = stylesheet.GetHelper<StyleHelper> ();

			// background image
			if (InitImage (stylesheet)) {
				_view.Image = _backgroungImageCache;

				// selected-color
				var selectedColor = style.Color<SelectedColor> (this);
				if (selectedColor != null)
					_selectedImage = GetFilteredImage (_backgroungImageCache, selectedColor);
			}

			return styleBound;
		}
示例#4
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);


            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            // background color, background image, borders
            if (InitBackgroundImage(stylesheet))
            {
                _view.SetBackgroundImage(_backgroundImageCache, UIControlState.Normal);
            }
            else
            {
                style.SetBackgroundSettings(this);
            }

            // font
            UIFont f = style.Font(this, styleBound.Height);

            if (f != null)
            {
                _view.Font = f;
            }

            // text color
            _textColor = style.ColorOrClear <Color> (this);
            _view.SetTitleColor(_textColor, UIControlState.Normal);

            // selected-color
            var selectedColor = style.Color <SelectedColor> (this);

            if (selectedColor != null)
            {
                _view.SetTitleColor(selectedColor, UIControlState.Highlighted);
            }

            _view.SetTitle(_text, UIControlState.Normal);
            return(styleBound);
        }
示例#5
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            _view.Text = _text;

            // background color, borders
            style.SetBackgroundSettings(this);

            //  text-format
            _textFormat = style.TextFormat(this);

            // font
            UIFont f = style.Font(this, styleBound.Height);

            if (f != null)
            {
                _view.Font = f;
            }

            switch (_textFormat)
            {
            case TextFormat.Format.Text:
                _view.Text = _text;

                // text color
                _view.TextColor = _textColor = style.ColorOrClear <BitMobile.Controls.StyleSheet.Color> (this);

                // selected-color
                _selectedColor = style.Color <SelectedColor> (this);

                break;

            case TextFormat.Format.Html:
                string span = string.Format("<span style=\"font-family: {0}; font-size: {1:F0}; color: {2}\">{3}</span>", _view.Font.FamilyName, _view.Font.PointSize, "{0}", "{1}");

                // text color
                _textHtmlSpan = string.Format(span, style.ColorString <BitMobile.Controls.StyleSheet.Color> (this), "{0}");

                // selected-color
                string selectedColor = style.ColorString <SelectedColor> (this);
                if (selectedColor != null)
                {
                    _selectedHtmlSpan = string.Format(span, selectedColor, "{0}");
                }

                SetSpannedText(_textHtmlSpan);
                break;

            default:
                throw new NotImplementedException("Text format not found: " + _textFormat);
            }

            // word wrap
            bool nowrap = style.WhiteSpaceKind(this) == WhiteSpace.Kind.Nowrap;

            if (!nowrap)
            {
                _view.TextContainer.LineBreakMode        = UILineBreakMode.WordWrap;
                _view.TextContainer.MaximumNumberOfLines = 0;
            }
            else
            {
                _view.TextContainer.LineBreakMode        = UILineBreakMode.TailTruncation;
                _view.TextContainer.MaximumNumberOfLines = 1;
            }

            // text align
            switch (style.TextAlign(this))
            {
            case TextAlign.Align.Left:
                _view.TextAlignment = UITextAlignment.Left;
                break;

            case TextAlign.Align.Center:
                _view.TextAlignment = UITextAlignment.Center;
                break;

            case TextAlign.Align.Right:
                if (nowrap)
                {
                    _view.TextContainer.LineBreakMode = UILineBreakMode.HeadTruncation;
                }
                _view.TextAlignment = UITextAlignment.Right;
                break;
            }

            // text padding
            float pl = style.Padding <PaddingLeft> (this, styleBound.Width);
            float pt = style.Padding <PaddingTop> (this, styleBound.Height);
            float pr = style.Padding <PaddingRight> (this, styleBound.Width);
            float pb = style.Padding <PaddingBottom> (this, styleBound.Height);

            _view.TextContainerInset = new UIEdgeInsets(pt, pl, pb, pr);

            Bound resultBound = styleBound;

            // size to content
            bool sizeByWidth  = style.SizeToContentWidth(this);
            bool sizeByHeight = style.SizeToContentHeight(this);

            if (sizeByWidth || sizeByHeight)
            {
                float measureWidth  = sizeByWidth ? maxBound.Width : styleBound.Width;
                float measureHeight = sizeByHeight ? maxBound.Height : styleBound.Height;

                SizeF size = _view.SizeThatFits(new SizeF(measureWidth, measureHeight));

                float w = sizeByWidth ? size.Width + pl + pr : styleBound.Width;
                float h = sizeByHeight ? size.Height + pt + pb : styleBound.Height;

                resultBound = new Bound(w, h);
            }

            return(resultBound);
        }
示例#6
0
        public override Bound Apply(StyleSheet.StyleSheet stylesheet, Bound styleBound, Bound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            StyleHelper style = stylesheet.GetHelper <StyleHelper> ();

            // background color, borders
            style.SetBackgroundSettings(this);

            // text color
            _view.TextColor = style.ColorOrClear <Color> (this);

            // placeholder color
            UIColor placeholderColor = style.Color <PlaceholderColor> (this);

            if (placeholderColor != null)
            {
                _placeholderView.TextColor = placeholderColor;
            }

            // font
            UIFont f = style.Font(this, styleBound.Height);

            if (f != null)
            {
                _view.Font = f;
            }

            // padding
            float pl = style.Padding <PaddingLeft> (this, styleBound.Width);
            float pt = style.Padding <PaddingTop> (this, styleBound.Height);
            float pr = style.Padding <PaddingRight> (this, styleBound.Width);
            float pb = style.Padding <PaddingBottom> (this, styleBound.Height);

            if (ApplicationContext.OSVersion.Major >= 7)
            {
                _view.TextContainerInset = new UIEdgeInsets(pt, pl, pb, pr);
            }

            // text align
            switch (style.TextAlign(this))
            {
            case TextAlign.Align.Left:
                _view.TextAlignment = UITextAlignment.Left;
                break;

            case TextAlign.Align.Center:
                _view.TextAlignment = UITextAlignment.Center;
                break;

            case TextAlign.Align.Right:
                _view.TextAlignment = UITextAlignment.Right;
                break;
            }

            _placeholderView.Font  = _view.Font;
            _placeholderView.Frame = new System.Drawing.RectangleF(pl, pt, maxBound.Width - (pl + pr), maxBound.Height - (pt + pb));
            _placeholderView.SizeToFit();

            return(styleBound);
        }