Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created November 8, 2019 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/98a2cd4051ee250f5fa8b072c9617263 to your computer and use it in GitHub Desktop.
Save bjoerntx/98a2cd4051ee250f5fa8b072c9617263 to your computer and use it in GitHub Desktop.
private void rulerBar1_MouseDoubleClick(object sender, MouseEventArgs e)
{
// calculate zoom factor
float fZoomFactor = (float)textControl1.ZoomFactor / 100;
// get the click location in the ruler bar
int iClickLocation = (int)((e.X * iDpiX) + (textControl1.ScrollLocation.X * fZoomFactor));
// loop through all tab positions
foreach (int tabPosition in textControl1.Paragraphs.GetItem(
textControl1.Selection.Start).Format.TabPositions)
{
// retrieve the exact location including zoom factor
int iTabLocation = (int)((tabPosition +
textControl1.Sections.GetItem().Format.PageMargins.Left) * fZoomFactor);
// if click location matches tab position
// open the tab dialog
if (iClickLocation >= iTabLocation - 50 && iClickLocation <= iTabLocation + 50)
{
textControl1.TabDialog(); // open dialog
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment