Added new method to Fix Large Font + Dispose Graphics after usage

This commit is contained in:
ivandrofly 2015-05-21 17:23:05 +01:00
parent 0d5c196dd9
commit 1f425a99ea

View File

@ -1105,7 +1105,7 @@ namespace Nikse.SubtitleEdit.Logic
int count = 0;
for (int i = 0; i < words.Length; i++)
{
var regEx = new Regex("\\b" + words[i] + "\\b", (RegexOptions.CultureInvariant|RegexOptions.ExplicitCapture));
var regEx = new Regex("\\b" + words[i] + "\\b", (RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture));
count += regEx.Matches(text).Count;
}
return count;
@ -3435,5 +3435,18 @@ namespace Nikse.SubtitleEdit.Logic
return lines;
}
public static void FixLargeFonts(Control mainCtrl, Control ctrl)
{
using (Graphics graphics = mainCtrl.CreateGraphics())
{
SizeF textSize = graphics.MeasureString(ctrl.Text, mainCtrl.Font);
if (textSize.Height > ctrl.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7.5);
SetButtonHeight(mainCtrl, newButtonHeight, 1);
}
}
}
}
}