I have a textbox on top of an image overlay, which the user can interfere with. Now I want to draw the string onto that image via Graphics, but if I use the direct values of the box for drawing, the text isn't aligned correctly at all. Any tips on how to improve it, or any better way or doing it?
if (item is TextBox)
{
var usedItem = item as TextBox;
var p1 = new System.Drawing.Point((int)Math.Round(usedItem.Margin.Left), (int)Math.Round(usedItem.Margin.Top));
var font = new System.Drawing.Font("Segoe UI", (float)(usedItem.FontSize) );
g.DrawString(usedItem.Text, font, new System.Drawing.SolidBrush((System.Drawing.Color)new System.Drawing.ColorConverter().ConvertFromString(new System.Windows.Media.BrushConverter().
ConvertToString(usedItem.Foreground))), p1);
}