本文整理汇总了C#中System.Windows.Forms.ToolStripItem.GetCurrentParent方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItem.GetCurrentParent方法的具体用法?C# ToolStripItem.GetCurrentParent怎么用?C# ToolStripItem.GetCurrentParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripItem
的用法示例。
在下文中一共展示了ToolStripItem.GetCurrentParent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetToolStripItemText
private void SetToolStripItemText(ToolStripItem toolStripItem, string text)
{
if(toolStripItem.GetCurrentParent().InvokeRequired)
{
toolStripItem.GetCurrentParent().Invoke(new Action<ToolStripItem, string>(SetToolStripItemText), new object[] { toolStripItem, text });
}
else
{
toolStripItem.Text = text;
}
}
示例2: InvalidateSelection
public static void InvalidateSelection(ArrayList originalSelComps, ToolStripItem nextSelection, IServiceProvider provider, bool shiftPressed)
{
if ((nextSelection != null) && (provider != null))
{
Region r = null;
Region region = null;
int width = 1;
int num2 = 2;
ToolStripItemDesigner designer = null;
bool flag = false;
try
{
Rectangle empty = Rectangle.Empty;
IDesignerHost host = (IDesignerHost) provider.GetService(typeof(IDesignerHost));
if (host != null)
{
foreach (Component component in originalSelComps)
{
ToolStripItem item = component as ToolStripItem;
if ((item != null) && (((originalSelComps.Count > 1) || ((originalSelComps.Count == 1) && (item.GetCurrentParent() != nextSelection.GetCurrentParent()))) || (((item is ToolStripSeparator) || (item is ToolStripControlHost)) || (!item.IsOnDropDown || item.IsOnOverflow))))
{
designer = host.GetDesigner(item) as ToolStripItemDesigner;
if (designer != null)
{
empty = designer.GetGlyphBounds();
GetAdjustedBounds(item, ref empty);
empty.Inflate(width, width);
if (r == null)
{
r = new Region(empty);
empty.Inflate(-num2, -num2);
r.Exclude(empty);
}
else
{
region = new Region(empty);
empty.Inflate(-num2, -num2);
region.Exclude(empty);
r.Union(region);
}
}
else if (item is DesignerToolStripControlHost)
{
flag = true;
}
}
}
}
if (((r != null) || flag) || shiftPressed)
{
BehaviorService service = (BehaviorService) provider.GetService(typeof(BehaviorService));
if (service != null)
{
if (r != null)
{
service.Invalidate(r);
}
designer = host.GetDesigner(nextSelection) as ToolStripItemDesigner;
if (designer != null)
{
empty = designer.GetGlyphBounds();
GetAdjustedBounds(nextSelection, ref empty);
empty.Inflate(width, width);
r = new Region(empty);
empty.Inflate(-num2, -num2);
r.Exclude(empty);
service.Invalidate(r);
}
}
}
}
finally
{
if (r != null)
{
r.Dispose();
}
if (region != null)
{
region.Dispose();
}
}
}
}
示例3: RenderSeparatorInternal
private void RenderSeparatorInternal(Graphics g, ToolStripItem item, Rectangle bounds, bool vertical) {
Color foreColor = ColorTable.SeparatorDark;
Color highlightColor = ColorTable.SeparatorLight;
Pen foreColorPen = new Pen(foreColor);
Pen highlightColorPen = new Pen(highlightColor);
// undone emplore caching.
bool disposeForeColorPen = true;
bool disposeHighlightColorColorPen = true;
bool isASeparator = item is ToolStripSeparator;
bool isAHorizontalSeparatorNotOnDropDownMenu = false;
if (isASeparator) {
if (vertical) {
if (!item.IsOnDropDown) {
// center so that it matches office
bounds.Y +=3;
bounds.Height = Math.Max(0, bounds.Height -6);
}
}
else {
// offset after the image margin
ToolStripDropDownMenu dropDownMenu = item.GetCurrentParent() as ToolStripDropDownMenu;
if (dropDownMenu != null) {
if (dropDownMenu.RightToLeft == RightToLeft.No) {
// scoot over by the padding (that will line you up with the text - but go two PX before so that it visually looks
// like the line meets up with the text).
bounds.X += dropDownMenu.Padding.Left -2;
bounds.Width = dropDownMenu.Width - bounds.X;
}
else {
// scoot over by the padding (that will line you up with the text - but go two PX before so that it visually looks
// like the line meets up with the text).
bounds.X += 2;
bounds.Width = dropDownMenu.Width - bounds.X - dropDownMenu.Padding.Right;
}
}
else {
isAHorizontalSeparatorNotOnDropDownMenu = true;
}
}
}
try {
if (vertical) {
if (bounds.Height >= 4) {
bounds.Inflate(0, -2); // scoot down 2PX and start drawing
}
bool rightToLeft = (item.RightToLeft == RightToLeft.Yes);
Pen leftPen = (rightToLeft) ? highlightColorPen : foreColorPen;
Pen rightPen = (rightToLeft) ? foreColorPen : highlightColorPen;
// Draw dark line
int startX = bounds.Width / 2;
g.DrawLine(leftPen, startX, bounds.Top, startX, bounds.Bottom - 1);
// Draw highlight one pixel to the right
startX++;
g.DrawLine(rightPen, startX, bounds.Top + 1, startX, bounds.Bottom);
}
else {
//
// horizontal separator
// Draw dark line
if (isAHorizontalSeparatorNotOnDropDownMenu && bounds.Width >= 4) {
bounds.Inflate(-2, 0); // scoot down 2PX and start drawing
}
int startY = bounds.Height / 2;
g.DrawLine(foreColorPen, bounds.Left, startY, bounds.Right - 1, startY);
if (!isASeparator || isAHorizontalSeparatorNotOnDropDownMenu) {
// Draw highlight one pixel to the right
startY++;
g.DrawLine(highlightColorPen, bounds.Left + 1, startY, bounds.Right - 1, startY);
}
}
}
finally {
if (disposeForeColorPen && foreColorPen != null) {
foreColorPen.Dispose();
}
if (disposeHighlightColorColorPen && highlightColorPen != null) {
highlightColorPen.Dispose();
}
}
}
示例4: LooksPressed
private static bool LooksPressed(ToolStripItem item)
{
var parent = item.GetCurrentParent();
if (parent is MenuStrip) return false;
if (parent is ContextMenuStrip) return false;
if (parent is ToolStripDropDown) return false;
if (item.Pressed) return true;
{
var a = item as ToolStripDropDownButton;
if (a != null && a.IsOnDropDown) return true;
}
{
var a = item as ToolStripSplitButton;
if (a != null && a.IsOnDropDown) return true;
}
return false;
}
示例5: SetFormCaptionByToolStripItem
private void SetFormCaptionByToolStripItem(ToolStripItem tsi)
{
tsi.GetCurrentParent().FindForm().Text = string.Format("Журнал (Смена: {0})", GetFormCaption());
}
示例6: CommonParent
private bool CommonParent(ToolStripItem oldSelection, ToolStripItem newSelection)
{
ToolStrip currentParent = oldSelection.GetCurrentParent();
ToolStrip strip2 = newSelection.GetCurrentParent();
return (currentParent == strip2);
}
示例7: RenderSeparatorInternal
private void RenderSeparatorInternal(Graphics g, ToolStripItem item, Rectangle bounds, bool vertical)
{
Color separatorDark = this.ColorTable.SeparatorDark;
Color separatorLight = this.ColorTable.SeparatorLight;
Pen pen = new Pen(separatorDark);
Pen pen2 = new Pen(separatorLight);
bool flag = true;
bool flag2 = true;
bool flag3 = item is ToolStripSeparator;
bool flag4 = false;
if (flag3)
{
if (vertical)
{
if (!item.IsOnDropDown)
{
bounds.Y += 3;
bounds.Height = Math.Max(0, bounds.Height - 6);
}
}
else
{
ToolStripDropDownMenu currentParent = item.GetCurrentParent() as ToolStripDropDownMenu;
if (currentParent != null)
{
if (currentParent.RightToLeft == RightToLeft.No)
{
bounds.X += currentParent.Padding.Left - 2;
bounds.Width = currentParent.Width - bounds.X;
}
else
{
bounds.X += 2;
bounds.Width = (currentParent.Width - bounds.X) - currentParent.Padding.Right;
}
}
else
{
flag4 = true;
}
}
}
try
{
if (vertical)
{
if (bounds.Height >= 4)
{
bounds.Inflate(0, -2);
}
bool flag5 = item.RightToLeft == RightToLeft.Yes;
Pen pen3 = flag5 ? pen2 : pen;
Pen pen4 = flag5 ? pen : pen2;
int num = bounds.Width / 2;
g.DrawLine(pen3, num, bounds.Top, num, bounds.Bottom - 1);
num++;
g.DrawLine(pen4, num, bounds.Top + 1, num, bounds.Bottom);
}
else
{
if (flag4 && (bounds.Width >= 4))
{
bounds.Inflate(-2, 0);
}
int num2 = bounds.Height / 2;
g.DrawLine(pen, bounds.Left, num2, bounds.Right - 1, num2);
if (!flag3 || flag4)
{
num2++;
g.DrawLine(pen2, bounds.Left + 1, num2, bounds.Right - 1, num2);
}
}
}
finally
{
if (flag && (pen != null))
{
pen.Dispose();
}
if (flag2 && (pen2 != null))
{
pen2.Dispose();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:85,代码来源:ToolStripProfessionalRenderer.cs