我有一個我在軸上繪製的字符串列表。我想旋轉字符串(同樣,旋轉時它們應該保持在同一水平軸上)。 我嘗試使用下面的代碼:如何沿一個軸旋轉字符串列表?
namespace DrawString
{
struct StringData
{
public string StringName;
public int X;
public int Y;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Font mFont = new Font("Arial", 10.0f, FontStyle.Bold);
List<StringData> data = new List<StringData> { new StringData() { StringName = "Label1", X = 10, Y = 30 },
new StringData() { StringName = "Label2", X = 130, Y = 30 }};
private void Form1_Paint(object sender, PaintEventArgs e)
{
foreach (var str in data)
{
e.Graphics.RotateTransform(30);
e.Graphics.DrawString(str.StringName, mFont, new SolidBrush(Color.Black), new Point(str.X, str.Y));
e.Graphics.ResetTransform();
}
}
}
}
但由於圖形旋轉兩個字符串的一次,造成一個String要高於其他這是行不通的。如何以字符串的中心作爲旋轉軸單獨旋轉它們?
不知道如何解決你的問題,但我猜使用TranslateClip可以幫助的東西一點點(以其他框架,翻譯經常有助於改變旋轉的中心) – luiscubal 2010-09-14 18:33:29