bloxstrap/Bloxstrap/UI/Utility/Rendering.cs
pizzaboxer 94fe52245e
Refactor UI code structuring
109 changed files :D
2023-07-02 13:10:04 +01:00

25 lines
739 B
C#

using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace Bloxstrap.UI.Utility
{
static class Rendering
{
public static double GetTextWidth(TextBlock textBlock)
{
return new FormattedText(
textBlock.Text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(textBlock.FontFamily, textBlock.FontStyle, textBlock.FontWeight, textBlock.FontStretch),
textBlock.FontSize,
Brushes.Black,
new NumberSubstitution(),
VisualTreeHelper.GetDpi(textBlock).PixelsPerDip
).Width;
}
}
}