本文整理汇总了C#中System.Windows.Forms.Control.GetControlAncestors方法的典型用法代码示例。如果您正苦于以下问题:C# Control.GetControlAncestors方法的具体用法?C# Control.GetControlAncestors怎么用?C# Control.GetControlAncestors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.GetControlAncestors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateHelpStack
private static void UpdateHelpStack()
{
needStackUpdate = false;
// Retrieving all windows in a z-sorted way is a "time consuming" (~ 0.05ms) and API-heavy
// query, and we don't need to be that accurate. Don't do it every time. Once a second is enough.
bool updateGlobalWindows =
globalWindows == null ||
(DateTime.Now - lastGlobalWindowUpdate).TotalMilliseconds > 1000 ||
globalWindows.Any(f => f.IsDisposed);
if (updateGlobalWindows)
{
lastGlobalWindowUpdate = DateTime.Now;
globalWindows = EditorHelper.GetZSortedAppWindows();
}
// Iterate through our list of windows to find the one we're hovering
foreach (Form form in globalWindows)
{
if (!form.Visible) continue;
if (!new Rectangle(form.Location, form.Size).Contains(Cursor.Position)) continue;
Point localPos = form.PointToClient(Cursor.Position);
hoveredControl = form.GetChildAtPointDeep(localPos, GetChildAtPointSkip.Invisible | GetChildAtPointSkip.Transparent);
break;
}
Control c;
HelpInfo help;
// Get rid of disposed Controls
c = hoveredHelpProvider as Control;
if (c == null || c.IsDisposed)
{
hoveredHelpProvider = null;
hoveredHelpCaptured = false;
}
// An IHelpProvider has captured the mouse: Ask what to do with it.
if (hoveredHelpCaptured)
{
help = hoveredHelpProvider.ProvideHoverHelp(c.PointToClient(Cursor.Position), ref hoveredHelpCaptured);
// Update provider's help info
stack.UpdateFromProvider(hoveredHelpProvider, help);
// If still in charge: Return early.
if (hoveredHelpCaptured) return;
}
// No IHelpProvider in charge: Find one that provides help
help = null;
IHelpProvider lastHelpProvider = hoveredHelpProvider;
foreach (IHelpProvider hp in hoveredControl.GetControlAncestors<IHelpProvider>())
{
c = hp as Control;
help = hp.ProvideHoverHelp(c.PointToClient(Cursor.Position), ref hoveredHelpCaptured);
hoveredHelpProvider = hp;
if (help != null || hoveredHelpCaptured) break;
}
// Update help system based on the result.
if (lastHelpProvider != hoveredHelpProvider)
stack.UpdateFromProvider(lastHelpProvider, hoveredHelpProvider, help);
else if (hoveredHelpProvider != null)
stack.UpdateFromProvider(hoveredHelpProvider, help);
}
示例2: UpdateHelpStack
private static void UpdateHelpStack()
{
needStackUpdate = false;
foreach (Form f in EditorHelper.GetZSortedAppWindows())
{
if (!f.Visible) continue;
if (!new Rectangle(f.Location, f.Size).Contains(Cursor.Position)) continue;
Point localPos = f.PointToClient(Cursor.Position);
hoveredControl = f.GetChildAtPointDeep(localPos, GetChildAtPointSkip.Invisible | GetChildAtPointSkip.Transparent);
break;
}
Control c;
HelpInfo help;
// Get rid of disposed Controls
c = hoveredHelpProvider as Control;
if (c == null || c.IsDisposed)
{
hoveredHelpProvider = null;
hoveredHelpCaptured = false;
}
// An IHelpProvider has captured the mouse: Ask what to do with it.
if (hoveredHelpCaptured)
{
help = hoveredHelpProvider.ProvideHoverHelp(c.PointToClient(Cursor.Position), ref hoveredHelpCaptured);
// Update provider's help info
stack.UpdateFromProvider(hoveredHelpProvider, help);
// If still in charge: Return early.
if (hoveredHelpCaptured) return;
}
// No IHelpProvider in charge: Find one that provides help
help = null;
IHelpProvider lastHelpProvider = hoveredHelpProvider;
foreach (IHelpProvider hp in hoveredControl.GetControlAncestors<IHelpProvider>())
{
c = hp as Control;
help = hp.ProvideHoverHelp(c.PointToClient(Cursor.Position), ref hoveredHelpCaptured);
hoveredHelpProvider = hp;
if (help != null || hoveredHelpCaptured) break;
}
// Update help system based on the result.
if (lastHelpProvider != hoveredHelpProvider)
stack.UpdateFromProvider(lastHelpProvider, hoveredHelpProvider, help);
else if (hoveredHelpProvider != null)
stack.UpdateFromProvider(hoveredHelpProvider, help);
}