Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XStringFormat Added Set/GetTabStops Methods #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,43 @@ public void DrawPath(XPen pen, XBrush brush, XGraphicsPath path)
// ----- DrawString ---------------------------------------------------------------------------

public void DrawString(string s, XFont font, XBrush brush, XRect rect, XStringFormat format)
{
{
Realize(font, brush, 0);

// Handle XStringFormat TabStops
float firstTabOffset;
float[] tabs = format.GetTabStops(out firstTabOffset);
string[] sSplit = s.Split('\t');

if (tabs.Length > 0 && sSplit.Length > 1)
{
// Calculate absolute xOffset
float[] xOffset = new float[tabs.Length+1];
xOffset[0] = firstTabOffset;
for (int i = 0; i < tabs.Length; i++)
{
xOffset[i+1] = xOffset[i]+tabs[i];
}

// Draw each Tab-Part of the String as an individual-String on xOffset Position
for (int i = 0; i < sSplit.Length; i++)
{
XRect xRect = new XRect(rect.X, rect.Y, rect.Width, rect.Height);

if (i < xOffset.Length)
{
xRect.X += xOffset[i];
}
else
{
xRect.X += xOffset[xOffset.Length - 1];
}
DrawString(sSplit[i], font, brush, xRect, XStringFormats.TopLeft);
}
return;
}


double x = rect.X;
double y = rect.Y;

Expand Down
Loading