本文整理汇总了C#中TreeScope类的典型用法代码示例。如果您正苦于以下问题:C# TreeScope类的具体用法?C# TreeScope怎么用?C# TreeScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeScope类属于命名空间,在下文中一共展示了TreeScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCacheRequest
public static CacheRequest BuildCacheRequest(TreeScope treeScope, params AutomationProperty[] properties)
{
var cr = new CacheRequest { TreeScope = treeScope };
foreach (var property in properties)
cr.Add(property);
return cr;
}
示例2: GetAllChildNodes
public AutomationElementCollection GetAllChildNodes(AutomationElement element, AutomationProperty automationProperty, object value, TreeScope treeScope)
{
var allChildNodes = element.FindAll(treeScope, GetPropertyCondition(automationProperty, value));
if (allChildNodes == null)
throw new ElementNotAvailableException("Not able to find the child nodes of the element");
return allChildNodes;
}
示例3: FindElementByNameFilteredByControlTypeAndMouseClick
/// <summary>
/// Get automationelement by name, filtered by classname - mouse click if found
/// </summary>
/// <param name="parent"></param>
/// <param name="automationName">case-insensitive automation name</param>
/// <param name="controlType"></param>
/// <param name="controlType2"></param>
/// <exception cref="ApplicationException">if matching element not found</exception>
/// <exception cref="ApplicationException">if specified element is not enabled</exception>
public static void FindElementByNameFilteredByControlTypeAndMouseClick(AutomationElement parent, string automationName, ControlType controlType, ControlType controlType2, TimeSpan mouseClickDelay, TreeScope treeScope)
{
FindElementByNameFilteredByControlTypeWithTimeoutAndMouseClick(parent, automationName, controlType, controlType2,
AddinTestUtility.FindRibbonButtonsTimeout, //findDelay
mouseClickDelay,
treeScope);
}
示例4: btnProps_Click
/// <summary>
/// Responds to button click; saves options and starts
/// the UI Automation worker thread.
/// </summary>
/// <param name="sender">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
private void btnProps_Click(object sender, EventArgs e)
{
// Convert Drawing.Point to Windows.Point.
var drawingPoint = Cursor.Position;
_targetPoint = new Point(drawingPoint.X, drawingPoint.Y);
// Save caching settings in member variables so UI isn't accessed
// directly by the other thread.
_elementMode = rbFull.Checked ? AutomationElementMode.Full : AutomationElementMode.None;
// For simplicity, always include Element in scope.
_cacheScope = TreeScope.Element;
if (cbDescendants.Checked)
{
_cacheScope |= TreeScope.Descendants;
}
// Note: if descendants are specified, children
// are automatically included.
else if (cbChildren.Checked)
{
_cacheScope |= TreeScope.Children;
}
_fetcher = new UiAutomationFetcher(this, _targetPoint,
_cacheScope, _elementMode);
// Start another thread to do the UI Automation work.
var threadDelegate = new ThreadStart(StartWorkerThread);
_workerThread = new Thread(threadDelegate) {Priority = ThreadPriority.Highest};
_workerThread.Start();
OutputResults("Wait..." + Environment.NewLine);
}
示例5: FindAll
internal static IEnumerable<AutomationElement> FindAll(
AutomationElement parent,
TreeScope scope,
Condition condition)
{
return FindAll(parent, scope, condition, FindTimeout);
}
示例6: AddAutomationPropertyChangedEventHandler
public static void AddAutomationPropertyChangedEventHandler(AutomationElement element, TreeScope scope, AutomationPropertyChangedEventHandler eventHandler, params AutomationProperty[] properties)
{
Utility.ValidateArgumentNonNull(element, "element");
Utility.ValidateArgumentNonNull(eventHandler, "eventHandler");
Utility.ValidateArgumentNonNull(properties, "properties");
if (properties.Length == 0)
{
throw new ArgumentException("AtLeastOnePropertyMustBeSpecified");
}
int[] propertyIdArray = new int[properties.Length];
for (int i = 0; i < properties.Length; ++i)
{
Utility.ValidateArgumentNonNull(properties[i], "properties");
propertyIdArray[i] = properties[i].Id;
}
try
{
PropertyEventListener listener = new PropertyEventListener(AutomationElement.StructureChangedEvent, element, eventHandler);
Factory.AddPropertyChangedEventHandler(
element.NativeElement,
(UIAutomationClient.TreeScope)scope,
CacheRequest.CurrentNativeCacheRequest,
listener,
propertyIdArray);
ClientEventList.Add(listener);
}
catch (System.Runtime.InteropServices.COMException e)
{
Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
}
}
示例7: AddStructureChangedEventHandler
public static void AddStructureChangedEventHandler (
IRawElementProviderSimple provider, TreeScope scope,
StructureChangedEventHandler eventHandler)
{
var entry = new StructureChangedEventEntry (provider, scope, eventHandler);
lock (structureChangedEventEntries)
structureChangedEventEntries.Add (entry);
}
示例8: TryElementByCondition
public static AutomationElement TryElementByCondition(this AutomationElement element, TreeScope scope, Condition condition)
{
var result = scope == TreeScope.Parent || scope == TreeScope.Ancestors ?
new TreeWalker(condition).GetParent(element) :
element.FindFirst(scope, condition);
return result;
}
示例9: AddAutomationEventHandler
public static void AddAutomationEventHandler (AutomationEvent eventId,
IRawElementProviderSimple provider, TreeScope scope,
AutomationEventHandler eventHandler)
{
var entry = new AutomationEventEntry (eventId, provider, scope, eventHandler);
lock (automationEventEntries)
automationEventEntries.Add (entry);
}
示例10: getAutomationElement
public static AutomationElement getAutomationElement(AutomationElement parent, TreeScope scope, ControlType type, string name)
{
var element = parent.FindFirst(scope, new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, type),
new PropertyCondition(AutomationElement.NameProperty, name),
Automation.ControlViewCondition));
return element;
}
示例11: UiAutomationFetcher
/// <summary>
/// Constructor.
/// </summary>
/// <param name="form">The application form.</param>
/// <param name="targetPoint">The screen coordinates of the cursor.</param>
/// <param name="scope">The TreeScope for caching.</param>
/// <param name="mode">The mode for caching.</param>
public UiAutomationFetcher(FetchTimerForm form,
Point targetPt,
TreeScope scope, AutomationElementMode cacheMode)
{
_appForm = form;
_treeScope = scope;
_targetPoint = targetPt;
_mode = cacheMode;
}
示例12: AddAutomationPropertyChangedEventHandler
public static void AddAutomationPropertyChangedEventHandler (
IRawElementProviderSimple provider, TreeScope scope,
AutomationPropertyChangedEventHandler eventHandler,
int [] properties)
{
var entry = new PropertyChangedEventEntry (provider, scope, properties, eventHandler);
lock (propertyChangedEventEntries)
propertyChangedEventEntries.Add (entry);
}
示例13: Event
internal static async Task<AutomationEventArgs> Event(
AutomationEvent eventId,
AutomationElement element = null,
TreeScope scope = TreeScope.Descendants)
{
using (var waitr = new Waiter(eventId, element, scope))
{
await waitr.Completion.Task;
return waitr.EvtArgs;
}
}
示例14: GetElement
public AutomationElement GetElement(AutomationElement rootElement, AutomationProperty property, object value, TreeScope searchScope)
{
AutomationElement aeMainWindow = null;
int numWaits = 0;
do
{
aeMainWindow = rootElement.FindFirst(searchScope, new PropertyCondition(property, value));
++numWaits;
Thread.Sleep(200);
} while (aeMainWindow == null && numWaits < 50);
return aeMainWindow;
}
示例15: AddAutomationPropertyChangedEventHandler
public void AddAutomationPropertyChangedEventHandler (IElement element, TreeScope scope, AutomationPropertyChangedEventHandler eventHandler, AutomationProperty[] properties)
{
if (element == null)
return;
ClientElement clientElement = element as ClientElement;
if (clientElement == null) {
Log.Error ("[ClientAutomationSource.AddAutomationPropertyChangedEventHandler] Not ClientElement");
return;
}
int [] propertyIds = Array.ConvertAll (properties, p => p.Id);
ClientEventManager.AddAutomationPropertyChangedEventHandler (
clientElement.Provider, scope, eventHandler, propertyIds);
}