惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
WordPress大学
WordPress大学
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
Microsoft Security Blog
Microsoft Security Blog
G
GRAHAM CLULEY
N
News | PayPal Newsroom
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
美团技术团队
J
Java Code Geeks
I
Intezer
The Cloudflare Blog
SecWiki News
SecWiki News
S
Secure Thoughts
Microsoft Azure Blog
Microsoft Azure Blog
V2EX - 技术
V2EX - 技术
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
D
DataBreaches.Net
S
Security Affairs
Help Net Security
Help Net Security
S
Securelist
F
Full Disclosure
C
Check Point Blog
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园_首页
G
Google Developers Blog
Google Online Security Blog
Google Online Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog

博客园 - 心有

go语言最好的帮助在哪里? go语言的init函数 我的go语言上机测试代码 解决golang.org不能访问的问题 win7下安装32位GoSublime Package oracle和sybase的帮助文档 用bat文件设置程序启动环境 go语言 windows 32位编译环境搭建 Go没有枚举类型(enums),用const常量的iota替代 oracle数据库性能优化 - 降低IO c语言中的大数运算模块 C#的timer类问题~! 计划任务工具 cron 的配置和说明 TRACERT命令及用法 linux下挂载windows的共享文件目录ftp文件夹到/root/wind目录 Linux 用户(user)和用户组(group)管理概述 Linux用户和用户组的管理概述 用NetTerm连接虚拟机的telnet服务,打造轻松自如的虚拟机实验环境 请高人指点下,手机震动时从平台上掉入水中,是用户使用不当还是手机设计缺陷,维修费用由谁承担?
c#长字符串显示省略号 - 心有 - 博客园
心有 · 2007-02-22 · via 博客园 - 心有

        // 功能:将输入的str字符串格式化成width宽度能输出的字符串,如果字符串太长,则格式化为"start...end"格式
        // str -- 要格式化的字符串
        // width -- 最大的输出长度
        // prefixCount -- 前缀字符个数
        public string StringFormat(Graphics g, Font ft, string str, float width, int prefixCount)
        {
            SizeF sf;

            sf = g.MeasureString(str, ft);
            if(sf.Width <= width)
            {
                return str;
            }
            else
            {
                string result = "";
                string strTemp;
                SizeF sfTemp = new SizeF(0, 0);
                float wdTemp;
                int i;
                bool flag = false;

                if (prefixCount < str.Length)
                {
                    result = str.Substring(0, prefixCount) + "...";
                    sfTemp = g.MeasureString(result, ft);
                    flag = true;
                }

                if (flag && sfTemp.Width < width)
                {
                    strTemp = "";
                    wdTemp = width - sfTemp.Width;
                    for (i = str.Length - 1; i > 0; i--)
                    {
                        strTemp = str[i] + strTemp;
                        sfTemp = g.MeasureString(strTemp, ft);
                        if (sfTemp.Width >= wdTemp)
                        {
                            i++;
                            break;
                        }
                    }

                    result += str.Substring(i);

                    return result;
                }
                else
                {
                    strTemp = "";
                    sfTemp = g.MeasureString("...", ft);
                    wdTemp = width - sfTemp.Width;
                    for (i = 0; i < str.Length; i++)
                    {
                        strTemp += str[i];
                        sfTemp = g.MeasureString(strTemp, ft);
                        if (sfTemp.Width >= wdTemp)
                        {
                            i--;
                            break;
                        }
                    }

                    result = str.Substring(0, i) + "...";

                    return result;
                }
            }
        }