资源简介
C#利用GDI+绘制旋转文字,矩形内可以根据布局方式排列文本
代码片段和文件信息
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#程序 源码 遗传
- asp.net+c#学生信息管理系统C/S程序+源代
- C#俄罗斯方块源文件和资源文件
- 考试管理系统(C#源码 C/S架构)
- C# TCP助手异步通讯
- C# 串口通讯Demo(VS2010)
-
用c#+AE做 st
yleserver 和 Renderer程序 - C# Socket多客户端异步通信
- XTable C#WinFom下的一个表格的自定义控
- c# 操作word强大类库牛人版pixysoft.off
- AspNetPager asp.net 分页控件
- C# 一个完整的客户端和服务器端
- C# 导入excel到datagridview
- C# 链接PLC
- CRC校验源代码C#
- 基于C#的超市进销存销售管理系统的设
- C#实现串口操作包括读写串口,显示数
- c#图像相似度比较demo
- 非常好看的winform 自定义日期控件
- PC微信加密图片解密源码C#
- 燕山大学C#实验报告
- 非常好看的winform 自定义日期控件可直
- 基于C#MVC停车管理系统
- C#结合Halcon,对图像也可以拍照进行轮
- Color_Seg_Kmeans.zip
- TCP/IP通信c#例程
- 猜数字游戏的C#实现带界面
- Visionpro 脚本 C#
- C#串口编程基础入门
- ASP.net视频教程从入门到高级+电子书
评论
共有 条评论