本文整理汇总了C#中System.Windows.Forms.TabControl.IndexForTabPage方法的典型用法代码示例。如果您正苦于以下问题:C# TabControl.IndexForTabPage方法的具体用法?C# TabControl.IndexForTabPage怎么用?C# TabControl.IndexForTabPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TabControl
的用法示例。
在下文中一共展示了TabControl.IndexForTabPage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTab
//.........这里部分代码省略.........
tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
dc.DrawLine (tmp_pen, bounds.Left + 3, bounds.Top, bounds.Left + 1, bounds.Top + 2);
dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Top + 2, bounds.Left + 1, bounds.Bottom - 2);
dc.DrawLine (tmp_pen, bounds.Left + 1, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom);
}
interior = new Rectangle (bounds.Left + 2, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
string_format.FormatFlags = StringFormatFlags.DirectionVertical;
break;
default:
// TabAlignment.Right
tab_interior = new Rectangle (bounds.Left, bounds.Top + 2, bounds.Width - 2, bounds.Height - 2);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right, bounds.Top + 2), tab_second_color, tab_first_color)) {
dc.FillRectangle (lgbr, tab_interior);
}
int l_diff = is_selected ? 2 : 0;
// edges
tmp_pen = ResPool.GetPen (tab_edge_color);
dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top, bounds.Right - 1, bounds.Top + 1);
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom);
// inner border
tmp_pen = ResPool.GetPen (Color.White);
dc.DrawLine (tmp_pen, bounds.Left + l_diff, bounds.Top + 1, bounds.Right - 2, bounds.Top + 1);
dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
// border
tmp_pen = ResPool.GetPen (border_pressed_dark_color);
dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
using (LinearGradientBrush lgbr = new LinearGradientBrush (new Point (bounds.Left, bounds.Top + 2), new Point (bounds.Right - 2, bounds.Top + 2), border_pressed_light_color, border_pressed_dark_color)) {
int diff = is_selected ? 3 : 1;
using (Pen lgbrpen = new Pen (lgbr)) {
dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Top, bounds.Right - diff, bounds.Top);
dc.DrawLine (lgbrpen, bounds.Left + l_diff, bounds.Bottom, bounds.Right - diff, bounds.Bottom);
}
}
if (page.Focused) {
tmp_pen = ResPool.GetPen (tab_focus_color);
dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top + 1, bounds.Right - 3, bounds.Bottom - 1);
dc.DrawLine (tmp_pen, bounds.Right - 2, bounds.Top + 2, bounds.Right - 2, bounds.Bottom - 2);
tmp_pen = ResPool.GetPen (tab_top_border_focus_color);
dc.DrawLine (tmp_pen, bounds.Right - 3, bounds.Top, bounds.Right - 1, bounds.Top + 2);
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 2);
dc.DrawLine (tmp_pen, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 3, bounds.Bottom);
}
interior = new Rectangle (bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, bounds.Height - 8);
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
string_format.FormatFlags = StringFormatFlags.NoWrap;
string_format.FormatFlags = StringFormatFlags.DirectionVertical;
break;
}
}
if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) {
if (tab.Alignment == TabAlignment.Left) {
int wo = interior.Width / 2;
int ho = interior.Height / 2;
dc.TranslateTransform (interior.X + wo, interior.Y + ho);
dc.RotateTransform (180);
dc.DrawString (page.Text, page.Font, ResPool.GetSolidBrush (SystemColors.ControlText), 0, 0, string_format);
dc.ResetTransform ();
} else {
dc.DrawString (page.Text, page.Font,
ResPool.GetSolidBrush (SystemColors.ControlText),
interior, string_format);
}
} else if (page.Text != null) {
DrawItemState state = DrawItemState.None;
if (page == tab.SelectedTab)
state |= DrawItemState.Selected;
DrawItemEventArgs e = new DrawItemEventArgs (dc,
tab.Font, bounds, tab.IndexForTabPage (page),
state, page.ForeColor, page.BackColor);
tab.OnDrawItemInternal (e);
return res;
}
return res;
}