1
0
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:
chylex 2017-06-20 11:48:44 +02:00
parent fcac7a4ce1
commit 6310711136
2 changed files with 26 additions and 0 deletions

View 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;
}
}
}
}
}

View File

@ -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>