mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-12 00:40:34 +02:00
Add a vertical label control
This commit is contained in:
parent
fcac7a4ce1
commit
6310711136
23
Core/Controls/LabelVertical.cs
Normal file
23
Core/Controls/LabelVertical.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
sealed class LabelVertical : Label{
|
||||
public int LineHeight { get; set; }
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e){
|
||||
int y = (int)Math.Floor((ClientRectangle.Height-Text.Length*LineHeight)/2F)-2; // 2 = random
|
||||
|
||||
using(Brush brush = new SolidBrush(ForeColor)){
|
||||
foreach(char chr in Text){
|
||||
string str = chr.ToString();
|
||||
float x = (ClientRectangle.Width-e.Graphics.MeasureString(str, Font).Width)/2F;
|
||||
|
||||
e.Graphics.DrawString(str, Font, brush, x, y);
|
||||
y += LineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,9 @@
|
||||
<Compile Include="Core\Controls\FlatProgressBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Core\Controls\LabelVertical.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Core\Controls\TabButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
Loading…
Reference in New Issue
Block a user