コード例 #1
0
        private int LineHeight()
        {
            if (_lineHeight == 0)
            {
                if (_richTextBox.Lines.Any(line => line.Length != 0))
                {
                    _lineHeight = TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, 0);
                }
            }

            return(_lineHeight == 0 ? 12 : _lineHeight);
        }
コード例 #2
0
        private void DrawLines(IEnumerable <TextPos> list, DrawType type)
        {
            foreach (var textPos in list)
            {
                var start = _richTextBox.GetPositionFromCharIndex(textPos.Start);
                var end   = _richTextBox.GetPositionFromCharIndex(textPos.End);

                // The position above now points to the top left corner of the character.
                // We need to account for the character height so the underlines go
                // to the right place.
                end.X   += 1;
                start.Y += TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, textPos.Start);
                end.Y   += TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, textPos.End);

                if (start.X == -1 || end.X == -1)
                {
                    continue;
                }

                // Draw the wavy underline/mark
                if (start.Y < end.Y)
                {
                    switch (type)
                    {
                    case DrawType.Wave:
                        DrawWave(start, new Point(_richTextBox.Width - 3, start.Y));
                        DrawWave(new Point(3, end.Y), end);
                        break;

                    case DrawType.Mark:
                        DrawMark(start, new Point(_richTextBox.Width - 3, start.Y));
                        DrawMark(new Point(0, end.Y), end);
                        break;
                    }
                }
                else
                {
                    switch (type)
                    {
                    case DrawType.Wave:
                        DrawWave(start, end);
                        break;

                    case DrawType.Mark:
                        DrawMark(start, end);
                        break;
                    }
                }
            }
        }
コード例 #3
0
        private int LineHeight()
        {
            if (!EnvUtils.RunningOnWindows())
            {
                return(12);
            }

            if (_lineHeight == 0 && !EnvUtils.RunningOnWindows())
            {
                if (_richTextBox.Lines.Any(line => line.Length != 0))
                {
                    _lineHeight = TextBoxHelper.GetBaselineOffsetAtCharIndex(_richTextBox, 0);
                }
            }

            return(_lineHeight == 0 ? 12 : _lineHeight);
        }