Skip to content

Commit

Permalink
Fixed multi line text positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Abev08 committed Mar 19, 2024
1 parent f5227cd commit f20782e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ public void SetTextDisplayed(string text, Notifications.TextPosition position, d

private void UpdateTextDesiredPosition(VideoParameters video)
{
var lineCount = 1;
double lineSpacing = tbText.FontSize * 0.75d;
switch (tbTextPositionAnchor)
{
case Notifications.TextPosition.TOPLEFT:
Expand Down Expand Up @@ -367,7 +369,8 @@ private void UpdateTextDesiredPosition(VideoParameters video)
tbText.VerticalAlignment = VerticalAlignment.Top;
tbText.HorizontalAlignment = HorizontalAlignment.Left;
tbTextDesiredPosition.x = video.Left;
tbTextDesiredPosition.y = video.Top - (video.Height / 2d) - (tbText.FontSize / 2d);
foreach (char c in tbText.Text) if (c == '\n') lineCount++;
tbTextDesiredPosition.y = video.Top - (video.Height / 2d) - (lineSpacing * lineCount);
break;
case Notifications.TextPosition.VIDEOCENTER:
tbText.VerticalAlignment = VerticalAlignment.Top;
Expand All @@ -379,7 +382,8 @@ private void UpdateTextDesiredPosition(VideoParameters video)
tbText.VerticalAlignment = VerticalAlignment.Top;
tbText.HorizontalAlignment = HorizontalAlignment.Left;
tbTextDesiredPosition.x = video.Left;
tbTextDesiredPosition.y = video.Top + (video.Height / 2d) + (tbText.FontSize / 2d);
foreach (char c in tbText.Text) if (c == '\n') lineCount++;
tbTextDesiredPosition.y = video.Top + (video.Height / 2d) + (lineSpacing * lineCount);
break;
}
}
Expand Down

0 comments on commit f20782e

Please sign in to comment.