我正在使用带有自定义TabControl
控件的主题。
控件使用DrawString
方法为每个标签绘制文本,如下所示:
using (SolidBrush B = new SolidBrush(FC))
{
G.DrawString(TabPages[i].Text, Theme.GlobalFont(FontStyle.Regular, 10), B, new Point(TabRect.X + 50, TabRect.Y + 12));
}
将文本更改为希伯来语,并将控件的RightToLeftLayout
更改为true后,文本将翻转为:
我尝试在线搜索并发现您可以使用Transform
来修改文本,但我相信情况并非如此,因为它应该是一项简单的任务。这是控件的完整类:
class FirefoxMainTabControl : TabControl
{
#region " Private "
private Graphics G;
private Rectangle TabRect;
#endregion
private Color FC = Color.Blue;
#region " Control "
public FirefoxMainTabControl()
{
DoubleBuffered = true;
ItemSize = new Size(43, 152);
Alignment = TabAlignment.Left;
SizeMode = TabSizeMode.Fixed;
}
protected override void OnCreateControl()
{
base.OnCreateControl();
SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
try
{
for (int i = 0; i <= TabPages.Count - 1; i++)
{
TabPages[i].BackColor = Color.White;
TabPages[i].ForeColor = Color.FromArgb(66, 79, 90);
TabPages[i].Font = Theme.GlobalFont(FontStyle.Regular, 10);
}
}
catch
{
}
}
protected override void OnPaint(PaintEventArgs e)
{
G = e.Graphics;
G.SmoothingMode = SmoothingMode.HighQuality;
G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
base.OnPaint(e);
G.Clear(Color.FromArgb(66, 79, 90));
for (int i = 0; i <= TabPages.Count - 1; i++)
{
TabRect = GetTabRect(i);
if (SelectedIndex == i)
{
using (SolidBrush B = new SolidBrush(Color.FromArgb(52, 63, 72)))
{
G.FillRectangle(B, TabRect);
}
FC = Helpers.GreyColor(245);
using (SolidBrush B = new SolidBrush(Color.FromArgb(255, 175, 54)))
{
G.FillRectangle(B, new Rectangle(TabRect.Location.X - 3, TabRect.Location.Y + 1, 5, TabRect.Height - 2));
}
}
else
{
FC = Helpers.GreyColor(192);
using (SolidBrush B = new SolidBrush(Color.FromArgb(66, 79, 90)))
{
G.FillRectangle(B, TabRect);
}
}
using (SolidBrush B = new SolidBrush(FC))
{
G.DrawString(TabPages[i].Text, Theme.GlobalFont(FontStyle.Regular, 10), B, new Point(TabRect.X + 50, TabRect.Y + 12));
}
if ((ImageList != null))
{
if (!(TabPages[i].ImageIndex < 0))
{
G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Rectangle(TabRect.X + 19, TabRect.Y + ((TabRect.Height / 2) - 10), 18, 18));
}
}
}
}
#endregion
}