Esempio n. 1
0
        public bool SetProperties(AGS.API.SizeF baseSize, string text = null, ITextConfig config = null, int?maxWidth = null,
                                  PointF?scaleUp = null, PointF?scaleDown  = null, int caretPosition = 0, bool renderCaret = false,
                                  bool cropText  = false, bool measureOnly = false)
        {
            bool configIsDifferent = config != null && !config.Equals(_config);
            bool changeNeeded      =
                (text != null && text != _text) ||
                configIsDifferent ||
                (maxWidth != null && maxWidth.Value != _maxWidth) ||
                !baseSize.Equals(_baseSize) ||
                _caretPosition != caretPosition ||
                _renderCaret != renderCaret ||
                cropText != _cropText ||
                measureOnly != _measureOnly ||
                (scaleUp != null && !scaleUp.Value.Equals(_scaleUp)) ||
                (scaleDown != null && !scaleDown.Value.Equals(_scaleDown));

            if (!changeNeeded)
            {
                return(false);
            }

            _text = text;
            if (configIsDifferent)
            {
                _config     = AGSTextConfig.Clone(config);
                _spaceWidth = measureSpace();
            }
            if (maxWidth != null)
            {
                _maxWidth = maxWidth.Value;
            }
            _cropText    = cropText;
            _measureOnly = measureOnly;
            if (scaleUp != null)
            {
                _scaleUp = scaleUp.Value;
            }
            if (scaleDown != null)
            {
                _scaleDown = scaleDown.Value;
            }

            _baseSize      = baseSize;
            _caretPosition = caretPosition;
            _renderCaret   = renderCaret;

            prepareBitmapDraw();

            return(true);
        }
Esempio n. 2
0
        public void SetProperties(AGS.API.SizeF baseSize, string text = null, ITextConfig config = null, int?maxWidth = null,
                                  int caretPosition = 0, bool renderCaret = false, bool?cropText = null)
        {
            bool changeNeeded =
                (text != null && text != _text) ||
                (config != null && config != _config) ||
                (maxWidth != null && maxWidth.Value != _maxWidth) ||
                !baseSize.Equals(_baseSize) ||
                _caretPosition != caretPosition ||
                _renderCaret != renderCaret ||
                (cropText != null && cropText.Value != _cropText);

            if (!changeNeeded)
            {
                return;
            }

            _text = text;
            if (config != null && config != _config)
            {
                _config     = config;
                _spaceWidth = measureSpace();
            }
            if (maxWidth != null)
            {
                _maxWidth = maxWidth.Value;
            }
            if (cropText != null)
            {
                _cropText = cropText.Value;
            }
            _baseSize      = baseSize;
            _caretPosition = caretPosition;
            _renderCaret   = renderCaret;

            drawToBitmap();
        }