コード例 #1
0
ファイル: Button.cs プロジェクト: Fedorm/core-master
 private void AnimateUp()
 {
     if (_view != null)
     {
         if (_selectedBackground != null)
         {
             _view.BackgroundColor = _mainBackground;
             _mainBackground.Dispose();
             _mainBackground = null;
         }
     }
 }
コード例 #2
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         if (PlaceholderColor != null)
         {
             PlaceholderColor.Dispose();
             PlaceholderColor = null;
         }
     }
 }
コード例 #3
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                SelectedColor?.Dispose();
                SelectedColor = null;

                StartingColor?.Dispose();
                StartingColor = null;

                ColorPicked = null;
            }
        }
コード例 #4
0
 private void BackgroundAnimationUp()
 {
     if (_mainBackground != null)
     {
         _view.BackgroundColor = _mainBackground;
         _mainBackground.Dispose();
         _mainBackground = null;
     }
     else if (_mainBackgroundImage != null)
     {
         _view.Layer.Contents = _mainBackgroundImage;
         _mainBackgroundImage.Dispose();
         _mainBackgroundImage = null;
     }
 }
コード例 #5
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <returns>The dispose.</returns>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _pickerCell    = null;
         _selectedCache = null;
         _source        = null;
         _parent        = null;
         _accentColor.Dispose();
         _accentColor = null;
         _titleColor?.Dispose();
         _titleColor = null;
         _background?.Dispose();
         _background = null;
         _tableView  = null;
     }
     base.Dispose(disposing);
 }
コード例 #6
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (oldTextShadowColor != null)
                {
                    oldTextShadowColor.Dispose();
                    oldTextShadowColor = null;
                }

                if (oldDetailTextShadowColor != null)
                {
                    oldDetailTextShadowColor.Dispose();
                    oldDetailTextShadowColor = null;
                }
            }
            base.Dispose(disposing);
        }
コード例 #7
0
        public static UIImage ImageWithColor(this UIImage image, UIColor color1)
        {
            UIGraphics.BeginImageContextWithOptions(image.Size, false, image.CurrentScale);

            using (var context = UIGraphics.GetCurrentContext())
            {
                context.TranslateCTM(0, image.Size.Height);
                context.ScaleCTM(1.0f, -1.0f);
                context.SetBlendMode(CGBlendMode.Normal);
                var rect = new CGRect(0, 0, image.Size.Width, image.Size.Height);
                context.ClipToMask(rect, image.CGImage);
                color1.SetFill();
                context.FillRect(rect);
                var newImage = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();

                image.Dispose();
                color1.Dispose();

                return(newImage);
            }
        }
コード例 #8
0
        protected override IBound ReApply(IDictionary <Type, IStyle> styles, IBound styleBound, IBound maxBound)
        {
            // we forbid execution of SetSpannedString()
            _blinkAllowed = false;

            IStyleHelper helper = StyleSheetContext.Current.CreateHelper(styles, CurrentStyleSheet, this);

            if (styles.Count > 0)
            {
                _view.Text = _text;

                // background color, borders, background image
                UIImage image = helper.SetBackgroundSettings(this);
                if (image != null && image != _backgroundImage)
                {
                    _backgroundImage.Dispose();
                    _backgroundImage      = image;
                    _view.Layer.Contents  = _backgroundImage.CGImage;
                    _view.BackgroundColor = UIColor.Clear;
                }

                // font
                UIFont f;
                if (helper.FontChanged(styleBound.Height, out f))
                {
                    _view.Font = f;
                }

                // word wrap
                IWhiteSpace whiteSpace;
                bool        whiteSpaceChanged = helper.TryGet(out whiteSpace);
                bool        nowrap            = whiteSpace.Kind == WhiteSpaceKind.Nowrap;
                if (whiteSpaceChanged)
                {
                    if (!nowrap)
                    {
                        _view.TextContainer.LineBreakMode        = UILineBreakMode.WordWrap;
                        _view.TextContainer.MaximumNumberOfLines = 0;
                    }
                    else
                    {
                        _view.TextContainer.LineBreakMode        = UILineBreakMode.TailTruncation;
                        _view.TextContainer.MaximumNumberOfLines = 1;
                    }
                }

                // text-format
                ITextFormat textFormat;
                bool        formatChanged = helper.TryGet(out textFormat);
                _textFormat = textFormat.Format;

                switch (_textFormat)
                {
                case TextFormatValues.Text:
                {
                    _view.AttributedText = new NSAttributedString();
                    _view.Text           = _text;

                    // text color
                    ITextColor textColor;
                    if (helper.TryGet(out textColor) || formatChanged)
                    {
                        _view.TextColor = _textColor = textColor.ToColorOrClear();
                    }

                    // selected-color
                    ISelectedColor selectedColor;
                    if (helper.TryGet(out selectedColor) || formatChanged)
                    {
                        _selectedColor = selectedColor.ToNullableColor();
                    }
                }
                break;

                case TextFormatValues.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}");

                    ITextColor textColor;
                    formatChanged |= helper.TryGet(out textColor);
                    _textHtmlSpan  = string.Format(span, textColor.Value.Hex, "{0}");

                    // selected-color
                    ISelectedColor selectedColor;
                    formatChanged |= helper.TryGet(out selectedColor);
                    if (selectedColor.ToNullableColor() != null)
                    {
                        _selectedHtmlSpan = string.Format(span, selectedColor.Value.Hex, "{0}");
                    }

                    if (formatChanged)
                    {
                        SetSpannedText(_textHtmlSpan);
                    }
                }
                break;

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

                // selected-background
                ISelectedBackground selectedBackground;
                if (helper.TryGet(out selectedBackground))
                {
                    UIColor color = selectedBackground.ToNullableColor();
                    if (_backgroundImage != null && color != null)
                    {
                        _selectedBackgroundImage = GetFilteredImage(_backgroundImage, color).CGImage;
                        color.Dispose();
                    }
                    else
                    {
                        _selectedBackground = color;
                    }
                }

                // text align
                ITextAlign textAlign;
                if (helper.TryGet(out textAlign))
                {
                    SetTextAlign(textAlign.Align, nowrap);
                }

                // text padding
                float screenWidth  = ApplicationContext.Current.DisplayProvider.Width;
                float screenHeight = ApplicationContext.Current.DisplayProvider.Height;
                float pl           = helper.Get <IPaddingLeft>().CalcSize(styleBound.Width, screenWidth);
                float pt           = helper.Get <IPaddingTop>().CalcSize(styleBound.Height, screenHeight);
                float pr           = helper.Get <IPaddingRight>().CalcSize(styleBound.Width, screenWidth);
                float pb           = helper.Get <IPaddingBottom>().CalcSize(styleBound.Height, screenHeight);
                _view.TextContainerInset = new UIEdgeInsets(pt, pl, pb, pr);
            }
            _blinkAllowed = true;

            // resize by background image
            IBound bound = GetBoundByImage(styleBound, maxBound, _backgroundImage);

            // size to content
            return(MergeBoundByContent(CurrentStyleSheet.Helper, bound, maxBound, _view.TextContainerInset,
                                       _backgroundImage != null));
        }
コード例 #9
0
        protected override IBound Apply(IStyleSheet stylesheet, IBound styleBound, IBound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            _view.Text = _text;

            IStyleSheetHelper style = stylesheet.Helper;

            // background color, borders, background image
            _backgroundImage = stylesheet.SetBackgroundSettings(this);
            if (_backgroundImage != null)
            {
                _view.Layer.Contents  = _backgroundImage.CGImage;
                _view.BackgroundColor = UIColor.Clear;
            }

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

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

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

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

                // text color
                _view.TextColor = _textColor = style.Color(this).ToColorOrClear();

                // selected-color
                _selectedColor = style.SelectedColor(this).ToNullableColor();

                break;

            case TextFormatValues.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.Color(this).Hex, "{0}");

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

                SetSpannedText(_textHtmlSpan);
                break;

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

            // selected-background
            UIColor selectedBackground = style.SelectedBackground(this).ToNullableColor();

            if (selectedBackground != null)
            {
                if (_backgroundImage != null)
                {
                    _selectedBackgroundImage = GetFilteredImage(_backgroundImage, selectedBackground).CGImage;
                    selectedBackground.Dispose();
                }
                else
                {
                    _selectedBackground = selectedBackground;
                }
            }

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

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

            // text align
            SetTextAlign(style.TextAlign(this), nowrap);

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

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

            // resize by background image
            IBound bound = GetBoundByImage(styleBound, maxBound, _backgroundImage);

            // size to content
            return(MergeBoundByContent(style, bound, maxBound, _view.TextContainerInset, _backgroundImage != null));
        }
コード例 #10
0
ファイル: Button.cs プロジェクト: Fedorm/core-master
        protected override IBound Apply(IStyleSheet stylesheet, IBound styleBound, IBound maxBound)
        {
            base.Apply(stylesheet, styleBound, maxBound);

            IStyleSheetHelper style = stylesheet.Helper;

            // background color, borders, background image
            UIImage backgroundImage = stylesheet.SetBackgroundSettings(this);

            if (backgroundImage != null)
            {
                _view.SetBackgroundImage(backgroundImage, UIControlState.Normal);
            }

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

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

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

            _view.TitleLabel.LineBreakMode = !nowrap ? UILineBreakMode.WordWrap : UILineBreakMode.TailTruncation;

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

            switch (_textFormat)
            {
            case TextFormatValues.Text:
                SetText();

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

                // selected-color
                using (UIColor selectedColor = style.SelectedColor(this).ToNullableColor())
                    if (selectedColor != null)
                    {
                        _view.SetTitleColor(selectedColor, UIControlState.Highlighted);
                    }

                break;

            case TextFormatValues.Html:
                string whitespace = nowrap ? "nowrap" : "normal";
                string span       =
                    string.Format(
                        "<span style=\"font-family: {0}; font-size: {1:F0}; color: {2}; white-space: {3}\">{4}</span>"
                        , _view.Font.FamilyName, _view.Font.PointSize, "{0}", whitespace, "{1}");
                // text color
                _textHtmlSpan = string.Format(span, style.Color(this).Hex, "{0}");

                // selected-color
                IColorInfo selectedColorInfo = style.SelectedColor(this);
                if (selectedColorInfo != null)
                {
                    _selectedHtmlSpan = string.Format(span, selectedColorInfo.Hex, "{0}");
                }

                SetSpannedText(_textHtmlSpan);
                break;

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

            // selected-background
            UIColor selectedBackground = style.SelectedBackground(this).ToNullableColor();

            if (selectedBackground != null)
            {
                if (backgroundImage != null)
                {
                    using (UIImage selectedImage = GetFilteredImage(backgroundImage, selectedBackground))
                        _view.SetBackgroundImage(selectedImage, UIControlState.Highlighted);
                    selectedBackground.Dispose();
                }
                else
                {
                    _selectedBackground = selectedBackground;
                }
            }

            // text align
            SetTextAlign(style.TextAlign(this, TextAlignValues.Center), nowrap);
            {
                // text padding
                float pl = style.PaddingLeft(this, styleBound.Width);
                float pt = style.PaddingTop(this, styleBound.Height);
                float pr = style.PaddingRight(this, styleBound.Width);
                float pb = style.PaddingBottom(this, styleBound.Height);
                _view.ContentEdgeInsets = new UIEdgeInsets(pt, pl, pb, pr);

                // resize by background image
                IBound bound = GetBoundByImage(styleBound, maxBound, backgroundImage);

                // size to content
                bound = MergeBoundByContent(style, bound, maxBound, _view.ContentEdgeInsets, backgroundImage != null);

                _view.TitleLabel.PreferredMaxLayoutWidth = bound.Width - pl - pr;

                return(bound);
            }
        }