Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        public CharMetric Init(
            int lineIndex, int lineHeight,
            char ch, double x,
            int index, int originalIndex, int columnLen,
            Color color, Color backgroundColor,
            IFont fontId, double width, double adjustY)
        {
            LineIndex             = lineIndex;
            LineHeight            = lineHeight;
            Char                  = ch;
            IndexEachLine         = index;
            OriginalIndexEachLine = originalIndex;
            ColumnLen             = columnLen;
            Color                 = color;
            BackgroundColor       = backgroundColor;
            Font                  = fontId;
            Width                 = width;
            Left                  = x;
            Right                 = Left + Width;
            Y        = MathUtil.RoundAwayFromZeroToInt32(lineIndex * lineHeight + adjustY);
            CharRect = new Rect2D(
                (int)x,
                lineIndex * lineHeight,
                CharSize.RoundWidth(width),
                lineHeight);
            CharRange = new TextRange(
                lineIndex, originalIndex,
                lineIndex, originalIndex + 1);

            return(this);
        }
Esempio n. 2
0
        void ComputeCharacterSizes()
        {
            var chars = words.SelectMany(w => w.ToCharArray()).Distinct().ToArray();
            var rect  = new Rect();
            var array = new char[1];

            foreach (var c in chars)
            {
                array [0] = c;
                textPaint.GetTextBounds(array, 0, 1, rect);
                charMetrics [c] = new CharSize {
                    Height = rect.Height(), Width = rect.Width()
                };
            }
        }
Esempio n. 3
0
        public static CharSize GetSize(EAW eaw, CharSize EAW_A_To = CharSize.HalfWidth)
        {
            switch (eaw)
            {
            case EAW.F:
            case EAW.W:
                return(CharSize.FullWidth);

            case EAW.H:
            case EAW.Na:
            case EAW.N:
                return(CharSize.HalfWidth);

            case EAW.A:
                return(EAW_A_To);

            default:
                throw new IndexOutOfRangeException("Unknown Char");
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        public void Move(TextPos pos, bool isResetBaseX)
        {
            Pos = pos;

            _textView.DrawingMetricsMeasurer.CalcTotalWidth(
                Pos.LineIndex, Pos.CharIndex,
                out var totalWidth, out var totalColumnCount);

            Location           = new Point2D(CharSize.RoundWidth(totalWidth), _textView.GetLineHeight() * Pos.LineIndex);
            CurrentColumnIndex = totalColumnCount;

            if (isResetBaseX)
            {
                BaseX = Location.X;
            }

            if (_textView.SharedInfo.HasFocus)
            {
                _isCaretPositive = true;
                _blinkTimer.Restart();
            }
        }
Esempio n. 5
0
 internal int GetLineHeight()
 {
     return(CharSize.RoundHeight(
                Math.Max(AsciiFont.MeasureChar('A').Height, JpFont.MeasureChar('あ').Height) + _settings.lineHeightAdjust));
 }
Esempio n. 6
0
 /// <summary></summary>
 public int CalcWidth() => CharSize.RoundWidth(
     _textView.AsciiFont.MeasureChar('9').Width *CalcDisplayDigits()) + 45;