fastcoloredtextbox 中文不重叠
DrawLineChars方法:
private void DrawLineChars(PaintEventArgs e, int firstChar, int lastChar, int iLine, int iWordWrapLine, int x,
                                   int y)
        {
            Line line = lines[iLine];
            LineInfo lineInfo = LineInfos[iLine];
            int from = lineInfo.GetWordWrapStringStartPosition(iWordWrapLine);
            int to = lineInfo.GetWordWrapStringFinishPosition(iWordWrapLine, line);
int startX = x;
            if (startX < LeftIndent)
                firstChar++;
lastChar = Math.Min(to - from, lastChar);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
//folded block ?
            if (lineInfo.VisibleState == VisibleState.StartOfHiddenBlock)
            {
                //rendering by FoldedBlockStyle
                FoldedBlockStyle.Draw(e.Graphics, new Point(startX + firstChar * CharWidth, y),
                                      new Range(this, from + firstChar, iLine, from + lastChar + 1, iLine));
            }
            else
            {
                //render by custom styles
                StyleIndex currentStyleIndex = StyleIndex.None;
                int iLastFlushedChar = firstChar - 1;
                int isChinaese = 0;
                SizeF sizef = GetCharSize(new Font("宋体", 10), '中');
                int len = (int)sizef.Width - CharWidth;
                int nextLen = 0;
                for (int iChar = firstChar; iChar <= lastChar; iChar++)
                {
                    StyleIndex style = line[from + iChar].style;
                    if (IsChina(line[from + iChar].c))
                    {
                        isChinaese++;
                    }
                    if (currentStyleIndex != style)
                    {
FlushRendering(e.Graphics, currentStyleIndex,
                                       new Point(startX + (iLastFlushedChar + 1) * CharWidth+nextLen, y),
                                       new Range(this, from + iLastFlushedChar + 1, iLine, from + iChar, iLine));
                        iLastFlushedChar = iChar - 1;
                        currentStyleIndex = style;
                        if (isChinaese > 0)
                        {
                            nextLen = len * isChinaese;
                        }
                    }
                }
                FlushRendering(e.Graphics, currentStyleIndex, new Point(startX + (iLastFlushedChar + 1) * CharWidth+nextLen, y),
                               new Range(this, from + iLastFlushedChar + 1, iLine, from + lastChar + 1, iLine));
            }
//draw selection
            if (!Selection.IsEmpty && lastChar >= firstChar)
            {
                e.Graphics.SmoothingMode = SmoothingMode.None;
                var textRange = new Range(this, from + firstChar, iLine, from + lastChar + 1, iLine);
                textRange = Selection.GetIntersectionWith(textRange);
                if (textRange != null && SelectionStyle != null)
                {
                    SelectionStyle.Draw(e.Graphics, new Point((startX + (textRange.Start.iChar - from) * CharWidth) * 2, y),
                                        textRange);
                }
            }
        }
//判断是否是中文
        public bool IsChina(char c)
        {
bool BoolValue = false;
            if (Convert.ToInt32(c) < Convert.ToInt32(Convert.ToChar(128)))
            {
                BoolValue = false;
            }
            else
            {
                return BoolValue = true;
            }
            return BoolValue;
        }
//IME mode
            if (range.tb.ImeAllowed)
            for (int i = range.Start.iChar; i < range.End.iChar; i++)
            {
                
                SizeF size = FastColoredTextBox.GetCharSize(f, line[i].c);
                
                var gs = gr.Save();
                //float k = size.Width>range.tb.CharWidth + 1?range.tb.CharWidth / size.Width:1;
                //gr.TranslateTransform(x, y+(1-k)*range.tb.CharHeight/2);
                //gr.ScaleTransform(k, (float)Math.Sqrt(k));
                //gr.DrawString(line[i].c.ToString(), f, ForeBrush, 0, 0, stringFormat);
                //gr.Restore(gs);
               
                if(size.Width>range.tb.CharWidth*1.5f)
                    gr.DrawString(line[i].c.ToString(), f, ForeBrush, x, y+range.tb.CharHeight/4, stringFormat);
                else
                    gr.DrawString(line[i].c.ToString(), f, ForeBrush, x, y, stringFormat);
                if (IsChina(line[i].c))
                {
                    x += size.Width;
                }
                else
                {
                    x += dx;
                }
            }
fastcoloredtextbox 中文不重叠的更多相关文章
- cmder中文显示相关问题解决方案(1.3以上版本)
		
cmder虽然Windows命令行的进阶版,虽然好看易用,但其中文编码一直是个问题.网上有不少博客给出解决方案,大部分都已因为版本更新失效.本文解决方案针对1.3以上版本的cmder用户 中文字体重叠 ...
 - Window 命令行神器:cmder
		
http://cmder.net/ https://github.com/cmderdev/cmder/releases/ 官网下载地址 http://www.360doc.com/content ...
 - cmder中文乱码、文字重叠等问题
		
对于玩linux的同学来说,win7中的cmd弱爆了,今天我在微博中看到cmder这个工具,自己安装了,觉得不错,就此分享给大家 下载安装到这里http://bliker.github.io/cmde ...
 - fastcoloredtextbox控件   看下是否解决了中文
		
该控件解决中文网址 未测试是否解决 想保存 http://www.dullong.com/share-a-code-can-be-highlighted-components-fastco ...
 - 中文分词工具探析(一):ICTCLAS (NLPIR)
		
1. 前言 ICTCLAS是张华平在2000年推出的中文分词系统,于2009年更名为NLPIR.ICTCLAS是中文分词界元老级工具了,作者开放出了free版本的源代码(1.0整理版本在此). 作者在 ...
 - linux中字体的安装以及Terminal字体重叠问题解决
		
安装wps的时候,经常会提示你系统字体缺失,这些字体网上都有,就不分享了,直接讲安装吧. 就比如这个Wingdings字体,在字体目录中新建一个目录Wingdings,将ttf字体文件复制进去,在终端 ...
 - 【python之路2】CMD中执行python程序中文显示乱码
		
在IDLE中执行下面代码,中文显示正常: # -*- coding:utf-8 -*- st=raw_input("请输入内容")print st 但在CMD中执行e:\hello ...
 - 【APP设计利器】Sketch 41 Mac中文破解版(含汉化插件)
		
Sketch是一款拥有美观界面和强大功能适用于所有设计师的专业矢量绘图工具.它旨在为美术设计师创造出一款更优秀的作品,不是复制品,而是提升品.Sketch简约的设计是基于无限的规模和层次的绘图空间,免 ...
 - UTF-8和GBK等中文字符编码格式介绍及相互转换
		
我们有很多时候需要使用中文编码格式,比如gbk.gb2312等,但是因为主要针对中文编码设置,因此并不完全通用,这样一来就有了在各编码间相互转换的需求,比如和UTF8的转换.可是在我使用的过程中,却发 ...
 
随机推荐
- 【Java】关于JVM运行时内存空间、JVM垃圾回收机制
			
参考的优秀文章 <深入理解Java虚拟机 JVM高级特性与最佳实线>(机械工业出版社) Java虚拟机的堆.栈.堆栈如何去理解? 聊聊JVM的年轻代 前言 本文是<深入理解Java虚 ...
 - jQuery 添加元素
			
jQuery 添加元素 1.append 在被选元素的结尾插入内容 $(document).ready(function(){ $("button").click(function ...
 - 用JavaBean实现数据库的连接和关闭,在jsp页面输出数据库中student表中学生的信息
			
package com.hanqi.test; import java.sql.*; public class XveSheng { Connection conn; Statement st; Re ...
 - 初识onselectstart
			
onselectstart几乎可以用于所有对象,其触发时间为目标对象被开始选中时(即选中动作刚开始,尚未实质性被选中). 实例: 在做拖拽效果的时候,为了防止js选中页面上的其他元素,onselect ...
 - 《BI项目笔记》历年外观质量均值变化分析Cube的建立
			
分析主题主要维度:烟叶级别.烟叶级别按等级信息.烟叶级别按分级标准(标准维度)产地(父子维度)检测时间(时间维度,以Tqc_Raw_PresentationQuality . CheckTime字段派 ...
 - win10离线安装.net framework 3.5
			
1.挂载win10系统镜像 2.执行命令 Dism /online /enable-feature /featurename:NetFX3 /All /Source:I:\sources\sxs /L ...
 - 转帖-[教程] Win7精简教程(简易中度)2016年8月-0day
			
[教程] Win7精简教程(简易中度)2016年8月 0day 发表于 2016-8-19 16:08:41 https://www.itsk.com/thread-370260-1-1.html ...
 - MySQL浮点计算存在的问题与解决方案
			
如有疑问请联系微信:onesoft007 在计算机中,浮点数往往很难精确表示,那么浮点数运算结果也往往难以精确表示.MySQL同样也存在这个问题,并表现在如下几个方面. 问题 1.相同的输入,可 ...
 - jQuery实现滚动效果详解1
			
声明:第一次写原创,本人初学,很多地方一知半解,本篇算是一个学习的笔记,欢迎批评指正,转载请注明. 今天要做的效果是在网上经常能看到多幅图片向左无缝滚动,鼠标滑过动画暂停,鼠标滑出动画继续的效果.网上 ...
 - CASE表达式的使用
			
我们在开发过程中,经常需要针对一列,基于条件逻辑来返回一个值,那么,这时候就需要使用到CASE表达式了. 例如,以下对Products表的查询就在SELECT语句中使用了CASE表达式,以生成用于描述 ...