資源簡介
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個文件信息
評論
共有 條評論