本文整理汇总了C#中System.Windows.Automation.AutomationElement.GetRuntimeId方法的典型用法代码示例。如果您正苦于以下问题:C# AutomationElement.GetRuntimeId方法的具体用法?C# AutomationElement.GetRuntimeId怎么用?C# AutomationElement.GetRuntimeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Automation.AutomationElement
的用法示例。
在下文中一共展示了AutomationElement.GetRuntimeId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
public static bool Compare (AutomationElement el1, AutomationElement el2)
{
if (el1 == null)
throw new ArgumentNullException ("el1");
if (el2 == null)
throw new ArgumentNullException ("el2");
return Compare (el1.GetRuntimeId (),
el2.GetRuntimeId ());
}
示例2: EventListenerClientSide
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
#region Constructors
internal EventListenerClientSide(AutomationElement elRoot, Delegate clientCallback, EventListener l)
{
_eventListener = l;
_refElement = elRoot;
// Ensure that RuntimeId is cached on elRoot so that later compares can be done w/o accessing the native element
_refRid = elRoot.GetRuntimeId();
_clientCallback = clientCallback;
_callbackDelegate = new UiaCoreApi.UiaEventCallback(OnEvent);
_gch = GCHandle.Alloc(_callbackDelegate);
//
}
示例3: Remove
public static EventListener Remove(AutomationEvent eventId, AutomationElement element, Delegate handler)
{
// Create a prototype to seek
int[] runtimeId = (element == null) ? null : element.GetRuntimeId();
EventListener prototype = new EventListener(eventId.Id, runtimeId, handler);
lock (_events)
{
LinkedListNode<EventListener> node = _events.Find(prototype);
if (node == null)
{
throw new ArgumentException("event handler not found");
}
EventListener result = node.Value;
_events.Remove(node);
return result;
}
}
示例4: IsListeningFor
// IsListeningFor - called by UIAccess client during removal of listeners. Returns
// true if rid, eventId and clientCallback represent this listener instance.
internal bool IsListeningFor(AutomationEvent eventId, AutomationElement el, Delegate clientCallback)
{
// Removing the event handler using the element RuntimeId prevents problems with dead elements
int[] rid = null;
try
{
rid = el.GetRuntimeId();
}
catch( ElementNotAvailableException )
{
// This can't be the element this instance is holding because when
// creating this instance we caused the RuntimeId to be cached.
return false;
}
if( !Misc.Compare( _refRid, rid ) )
return false;
if( _eventListener.EventId != eventId )
return false;
if (_clientCallback != clientCallback)
return false;
return true;
}
示例5: AutomationElementGetRuntimeId
public static void AutomationElementGetRuntimeId(AutomationElement element)
{
Dump("GetRuntimeId()", true, element);
try
{
object obj = element.GetRuntimeId();
}
catch (Exception exception)
{
VerifyException(element, exception, typeof(ElementNotAvailableException));
}
}
示例6: OnWindowShowOrOpen
// OnWindowShowOrOpen - Called by the WindowShowOrOpenTracker class when UI is shown or created
private static void OnWindowShowOrOpen( IntPtr hwnd, AutomationElement rawEl )
{
bool doWindowOpenedEvent = false;
bool doStructureChangedEvent = false;
lock ( _classLock )
{
if (_listeners != null)
{
// if rawEl is w/in the scope of any listeners then register for events in the new UI
for (int i = 0; i < _listeners.Count; i++)
{
EventListenerClientSide ec = (EventListenerClientSide)_listeners[i];
EventListener l = ec.EventListener;
if ( l.EventId == WindowPattern.WindowOpenedEvent )
doWindowOpenedEvent = true;
if ( l.EventId == AutomationElement.StructureChangedEvent )
doStructureChangedEvent = true;
// Only advise UI contexts if the provider might raise that event.
if (!ShouldAdviseProviders( l.EventId ))
continue;
// Only advise UI contexts if the element is w/in scope of the reference element
if (!ec.WithinScope( rawEl ))
continue;
// Notify the server side
UiaCoreApi.UiaEventAddWindow(ec.EventHandle, hwnd);
}
}
}
// Piggy-back on the listener for Windows hiding or closing to raise WindowClosed and StructureChanged events.
if ( doWindowOpenedEvent )
{
if ( HwndProxyElementProvider.IsWindowPatternWindow( NativeMethods.HWND.Cast( hwnd ) ) )
{
// Go ahead and raise a client-side only WindowOpenedEvent (if anyone is listening)
AutomationEventArgs e = new AutomationEventArgs( WindowPattern.WindowOpenedEvent );
RaiseEventInThisClientOnly( WindowPattern.WindowOpenedEvent, rawEl, e);
}
}
if ( doStructureChangedEvent )
{
// Filter on the control elements. Otherwise, this is extremely noisy. Consider not filtering if there is feedback.
//ControlType ct = (ControlType)rawEl.GetPropertyValue( AutomationElement.ControlTypeProperty );
//if ( ct != null )
{
// Last,raise an event for structure changed
StructureChangedEventArgs e = new StructureChangedEventArgs( StructureChangeType.ChildAdded, rawEl.GetRuntimeId() );
RaiseEventInThisClientOnly(AutomationElement.StructureChangedEvent, rawEl, e);
}
}
}
示例7: IsDifferent
/// <summary>
/// Compares the two automation elements and returns if
/// they are identical or not
/// </summary>
/// <param name="ele1">first element</param>
/// <param name="ele2">second element</param>
/// <returns></returns>
public static bool IsDifferent(AutomationElement ele1, AutomationElement ele2)
{
bool retVal;
if (ele1 == null || ele2 == null)
{
return true;
}
try
{
retVal = !Automation.Compare(ele1.GetRuntimeId(), ele2.GetRuntimeId());
}
catch
{
retVal = true;
}
Log.Debug(retVal ? "YES" : "NO");
return retVal;
}
示例8: BasicEventListener
public BasicEventListener(AutomationEvent eventKind, AutomationElement element, AutomationEventHandler handler) :
base(eventKind.Id, element.GetRuntimeId(), handler)
{
Debug.Assert(handler != null);
this._basicHandler = handler;
}
示例9: StructureEventListener
public StructureEventListener(AutomationEvent eventKind, AutomationElement element, StructureChangedEventHandler handler) :
base(AutomationElement.StructureChangedEvent.Id, element.GetRuntimeId(), handler)
{
Debug.Assert(handler != null);
this._structureChangeHandler = handler;
}
示例10: PropertyEventListener
public PropertyEventListener(AutomationEvent eventKind, AutomationElement element, AutomationPropertyChangedEventHandler handler) :
base(AutomationElement.AutomationPropertyChangedEvent.Id, element.GetRuntimeId(), handler)
{
Debug.Assert(handler != null);
this._propChangeHandler = handler;
}
示例11: Compare
// compare two AutomationElements
internal static bool Compare(AutomationElement el1, AutomationElement el2)
{
CheckNonNull(el1, el2);
return Compare(el1.GetRuntimeId(), el2.GetRuntimeId());
}