资源简介
C#利用GDI+绘制旋转文字,矩形内可以根据布局方式排列文本
![](http://www.nz998.com/pic/30425.jpg)
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace RotateText
{
public partial class FormMain : Form
{
private Font _font = new Font(“Arial“ 12);
private Brush _brush = new SolidBrush(Color.Black);
private Pen _pen = new Pen(Color.Black 1f);
private string _text = “Crow Soft“;
public FormMain()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
GraphicsText graphicsText = new GraphicsText();
graphicsText.Graphics = e.Graphics;
// 绘制围绕点旋转的文本
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
graphicsText.DrawString(_text _font _brush new PointF(100 80) format 45f);
graphicsText.DrawString(_text _font _brush new PointF(200 80) format -45f);
graphicsText.DrawString(_text _font _brush new PointF(300 80) format 90f);
graphicsText.DrawString(_text _font _brush new PointF(400 80) format -60f);
// 绘制矩形内旋转的文本
// First line
RectangleF rc = RectangleF.FromLTRB(50 150 200 230);
RectangleF rect = rc;
format.Alignment = StringAlignment.Near;
e.Graphics.DrawRectangle(_pen rect.Left rect.Top rect.Width rect.Height);
graphicsText.DrawString(_text _font _brush rect format 30);
rect.Location += new SizeF(180 0);
format.LineAlignment = StringAlignment.Near;
e.Graphics.DrawRectangle(_pen rect.Left rect.Top rect.Width rect.Height);
graphicsText.DrawString(_text _font _brush rect format -30);
rect.Location += new SizeF(180 0);
format.LineAlignment = StringAlignment.Center;
e.Graphics.DrawRectangle(_pen rect.Left rect.Top rect.Width rect.Height);
graphicsText.DrawString(_text _font _brush rect format -90);
rect.Location += new SizeF(180 0);
format.LineAlignment = StringAlignment.Far;
e.Graphics.DrawRectangle(_pen rect.Left rect.Top rect.Width rect.Height);
graphicsText.DrawString(_text _font _brush rect format 70);
// Second line
rect = rc;
rect.Location += new SizeF(0 100);
format.Alignment = StringAlignment.Center;
e.Graphics.DrawRectangle(_pen rect.Left rect.Top rect.Width rect.Height);
graphicsText.DrawString(_text _font _brush rect format 40);
rect.Location += new SizeF(180 0);
format.LineAlignment = StringAlignment.Near;
e.Gra
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-28 16:22 RotateText\
目录 0 2013-11-28 16:31 RotateText\RotateText\
文件 2666 2013-11-28 17:06 RotateText\RotateText\FormMain.Designer.cs
文件 4937 2013-11-28 17:20 RotateText\RotateText\FormMain.cs
文件 5817 2013-11-28 17:06 RotateText\RotateText\FormMain.resx
文件 5290 2013-11-28 17:20 RotateText\RotateText\GraphicsText.cs
文件 505 2013-11-28 16:22 RotateText\RotateText\Program.cs
目录 0 2013-11-28 16:22 RotateText\RotateText\Properties\
文件 1432 2013-11-28 16:22 RotateText\RotateText\Properties\AssemblyInfo.cs
文件 2848 2013-11-28 16:22 RotateText\RotateText\Properties\Resources.Designer.cs
文件 5612 2013-11-28 16:22 RotateText\RotateText\Properties\Resources.resx
文件 1095 2013-11-28 16:22 RotateText\RotateText\Properties\Settings.Designer.cs
文件 249 2013-11-28 16:22 RotateText\RotateText\Properties\Settings.settings
文件 3737 2013-11-28 16:52 RotateText\RotateText\RotateText.csproj
目录 0 2013-11-28 16:22 RotateText\RotateText\bin\
目录 0 2013-11-28 16:56 RotateText\RotateText\bin\Debug\
文件 12288 2013-11-28 17:20 RotateText\RotateText\bin\Debug\RotateText.exe
文件 30208 2013-11-28 17:20 RotateText\RotateText\bin\Debug\RotateText.pdb
文件 11600 2013-11-28 17:26 RotateText\RotateText\bin\Debug\RotateText.vshost.exe
目录 0 2013-11-28 17:26 RotateText\RotateText\bin\Release\
目录 0 2013-11-28 16:22 RotateText\RotateText\obj\
目录 0 2013-11-28 16:22 RotateText\RotateText\obj\x86\
目录 0 2013-11-28 17:20 RotateText\RotateText\obj\x86\Debug\
文件 2164 2013-11-28 16:22 RotateText\RotateText\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6281 2013-11-28 17:20 RotateText\RotateText\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 230 2013-11-28 17:06 RotateText\RotateText\obj\x86\Debug\GenerateResource.read.1.tlog
文件 570 2013-11-28 17:06 RotateText\RotateText\obj\x86\Debug\GenerateResource.write.1.tlog
文件 180 2013-11-28 17:06 RotateText\RotateText\obj\x86\Debug\RotateText.FormMain.resources
文件 180 2013-11-28 16:52 RotateText\RotateText\obj\x86\Debug\RotateText.Properties.Resources.resources
文件 664 2013-11-28 17:26 RotateText\RotateText\obj\x86\Debug\RotateText.csproj.FileListAbsolute.txt
文件 12288 2013-11-28 17:20 RotateText\RotateText\obj\x86\Debug\RotateText.exe
............此处省略4个文件信息
相关资源
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
- C#TCP 通信(TCP发送16进制)
- C# sql实现批量导入数据到数据库
评论
共有 条评论