本文整理汇总了C#中IInputElement.RaiseEvent方法的典型用法代码示例。如果您正苦于以下问题:C# IInputElement.RaiseEvent方法的具体用法?C# IInputElement.RaiseEvent怎么用?C# IInputElement.RaiseEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInputElement
的用法示例。
在下文中一共展示了IInputElement.RaiseEvent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaiseCursorEvents
/// <summary>
/// Raises the cursor events.
/// </summary>
/// <param name="element">The ui element under the cursor.</param>
/// <param name="cursorPosition">Cursor position.</param>
public void RaiseCursorEvents(IInputElement element, Point cursorPosition)
{
element.RaiseEvent(new HandCursorEventArgs(KinectEvents.HandCursorMoveEvent, cursorPosition));
if (element != _lastElement)
{
if (_lastElement != null)
_lastElement.RaiseEvent(new HandCursorEventArgs(KinectEvents.HandCursorLeaveEvent, cursorPosition));
element.RaiseEvent(new HandCursorEventArgs(KinectEvents.HandCursorEnterEvent, cursorPosition));
}
_lastElement = element;
}
示例2: CheckMouseEvent
private static void CheckMouseEvent(TestWindow window, IInputElement button, RoutedEvent routedEvent, bool shouldBeHandled)
{
var args = new MouseButtonEventArgs(Mouse.PrimaryDevice, (int) DateTime.Now.Ticks, MouseButton.Left);
args.RoutedEvent = routedEvent;
button.RaiseEvent(args);
window.ProcessEvents();
Assert.AreEqual(shouldBeHandled, args.Handled);
}
示例3: OnRaiseEndEditEvent
private bool OnRaiseEndEditEvent(IInputElement uiElement)
{
if (uiElement == null) return false;
var arg = new CellEditRoutedEventArgs(EndEditEvent, this);
uiElement.RaiseEvent(arg);
if (arg.HasChanged)
{
//arg.ChangedSet.ForEach(x => DirtyItems.Add(x));
//_isDirty = true;
LayerContainer.OnRaiseAfterMouseUpEvent(this); // 刷新控制, 重绘
}
return arg.HasChanged;
}
示例4: ProcessKeyEventArgs
private bool ProcessKeyEventArgs( KeyEventArgs e, IInputElement target )
{
bool retval = false;
if( target != null )
{
//foward the event to the child check box
Key realKey;
if( ( e.Key == Key.None ) && ( e.SystemKey != Key.None ) )
{
realKey = e.SystemKey;
}
else
{
realKey = e.Key;
}
//in XBAP the Keyboard.PrimaryDevice.ActiveSource will throw ,therefore, protect against the throw and suppress the exception
//if its the one we expect.
try
{
KeyEventArgs kea = new KeyEventArgs( Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, realKey );
kea.RoutedEvent = e.RoutedEvent;
//send the event
target.RaiseEvent( kea );
retval = kea.Handled;
}
catch( SecurityException ex )
{
//if the exception is for the UIPermission, then we want to suppress it
if( ( ex.PermissionType.FullName == "System.Security.Permissions.UIPermission" ) == false )
{
//not correct type, then rethrow the exception
throw;
}
else //this means that we are in XBAP
{
//we want to handle speciallly the case where the space was pressed (so that checkbox works in XBAP)
//condition taken from the System ChecckBox
if( ( e.RoutedEvent == Keyboard.KeyDownEvent )
&& ( e.Key == Key.Space )
&& ( ( Keyboard.Modifiers & ( ModifierKeys.Control | ModifierKeys.Alt ) ) != ModifierKeys.Alt )
&& ( this.IsMouseCaptured == false ) )
{
if( this.IsChecked.HasValue == true )
{
if( this.IsChecked.Value == false )
{
this.IsChecked = true;
}
else if( this.IsThreeState == false )
{
this.IsChecked = false;
}
else
{
this.IsChecked = null;
}
}
else
{
this.IsChecked = false;
}
retval = true;
}
}
}
}
return retval;
}
示例5: RightClick
private void RightClick(IInputElement element)
{
element.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right)
{
RoutedEvent = Mouse.MouseDownEvent
});
element.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right)
{
RoutedEvent = Mouse.MouseUpEvent
});
DispatcherUtil.DoEvents();
}
示例6: GetInfoForElement
private AccessKeyInformation GetInfoForElement(IInputElement element, string key)
{
AccessKeyInformation info = new AccessKeyInformation();
if (element != null)
{
AccessKeyPressedEventArgs args = new AccessKeyPressedEventArgs(key);
element.RaiseEvent(args);
info.Scope = args.Scope;
info.target = args.Target;
if (info.Scope == null)
{
info.Scope = GetSourceForElement(element);
}
}
else
{
info.Scope = CriticalGetActiveSource();
}
return info;
}
示例7: OnDeactivateStoryboardCompleted
private static void OnDeactivateStoryboardCompleted(
IInputElement snackbar, SnackbarMessage message)
{
var args = new SnackbarMessageEventArgs(DeactivateStoryboardCompletedEvent, message);
snackbar.RaiseEvent(args);
}
示例8: NavigateToUri
private static void NavigateToUri(IInputElement sourceElement, Uri targetUri, string targetWindow)
{
Debug.Assert(targetUri != null);
//
// This prevents against multi-threaded spoofing attacks.
//
DependencyObject dObj = (DependencyObject)sourceElement;
dObj.VerifyAccess();
//
// Spoofing countermeasure makes sure the URI hasn't changed since display in the status bar.
//
Uri cachedUri = Hyperlink.s_cachedNavigateUri.Value;
// ShouldPreventUriSpoofing is checked last in order to avoid incurring a first-chance SecurityException
// in common scenarios.
if (cachedUri == null || cachedUri.Equals(targetUri) || !ShouldPreventUriSpoofing)
{
//
// We treat FixedPage seperately to maintain backward compatibility
// with the original separate FixedPage implementation of this, which
// calls the GetLinkUri method.
if (!(sourceElement is Hyperlink))
{
targetUri = FixedPage.GetLinkUri(sourceElement, targetUri);
}
RequestNavigateEventArgs navigateArgs = new RequestNavigateEventArgs(targetUri, targetWindow);
navigateArgs.Source = sourceElement;
sourceElement.RaiseEvent(navigateArgs);
if (navigateArgs.Handled)
{
//
// The browser's status bar should be cleared. Otherwise it will still show the
// hyperlink address after navigation has completed.
// !! We have to do this after the current callstack is unwound in order to keep
// the anti-spoofing state valid. A particular attach is to do a bogus call to
// DoClick() in a mouse click preview event and then change the NavigateUri.
//
dObj.Dispatcher.BeginInvoke(DispatcherPriority.Send,
new System.Threading.SendOrPostCallback(ClearStatusBarAndCachedUri), sourceElement);
}
}
}
示例9: RaiseMouseLeaveNode
private void RaiseMouseLeaveNode(IInputElement nv)
{
View.Dispatcher.Invoke(() =>
{
nv.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0) { RoutedEvent = Mouse.MouseLeaveEvent });
});
DispatcherUtil.DoEvents();
}
示例10: RaiseContextMenuOpeningEvent
private bool RaiseContextMenuOpeningEvent(IInputElement source, double x, double y,bool userInitiated)
{
// Fire the event
ContextMenuEventArgs args = new ContextMenuEventArgs(source, true /* opening */, x, y);
DependencyObject sourceDO = source as DependencyObject;
if (userInitiated && sourceDO != null)
{
if (InputElement.IsUIElement(sourceDO))
{
((UIElement)sourceDO).RaiseEvent(args, userInitiated);
}
else if (InputElement.IsContentElement(sourceDO))
{
((ContentElement)sourceDO).RaiseEvent(args, userInitiated);
}
else if (InputElement.IsUIElement3D(sourceDO))
{
((UIElement3D)sourceDO).RaiseEvent(args, userInitiated);
}
else
{
source.RaiseEvent(args);
}
}
else
{
source.RaiseEvent(args);
}
if (!args.Handled)
{
// No one handled the event, auto show any available ContextMenus
// Saved from the bubble up the tree where we looked for a set ContextMenu property
DependencyObject o = args.TargetElement;
if ((o != null) && ContextMenuService.ContextMenuIsEnabled(o))
{
// Retrieve the value
object menu = ContextMenuService.GetContextMenu(o);
ContextMenu cm = menu as ContextMenu;
cm.SetValue(OwnerProperty, o);
cm.Closed += new RoutedEventHandler(OnContextMenuClosed);
if ((x == -1.0) && (y == -1.0))
{
// We infer this to mean that the ContextMenu was opened with the keyboard
cm.Placement = PlacementMode.Center;
}
else
{
// If there is a CursorLeft and CursorTop, it was opened with the mouse.
cm.Placement = PlacementMode.MousePoint;
}
// Clear any open tooltips
RaiseToolTipClosingEvent(true /*reset */);
cm.SetCurrentValueInternal(ContextMenu.IsOpenProperty, BooleanBoxes.TrueBox);
return true; // A menu was opened
}
return false; // There was no menu to open
}
// Clear any open tooltips since someone else opened one
RaiseToolTipClosingEvent(true /*reset */);
return true; // The event was handled by someone else
}
示例11: UpdateIsDefaulted
private void UpdateIsDefaulted(IInputElement focus)
{
// If it's not a default button, or nothing is focused, or it's disabled then it's not defaulted.
if (!IsDefault || focus == null || !IsEnabled)
{
SetValue(IsDefaultedPropertyKey, BooleanBoxes.FalseBox);
return;
}
DependencyObject focusDO = focus as DependencyObject;
object thisScope, focusScope;
// If the focused thing is not in this scope then IsDefaulted = false
AccessKeyPressedEventArgs e;
object isDefaulted = BooleanBoxes.FalseBox;
try
{
// Step 1: Determine the AccessKey scope from currently focused element
e = new AccessKeyPressedEventArgs();
focus.RaiseEvent(e);
focusScope = e.Scope;
// Step 2: Determine the AccessKey scope from this button
e = new AccessKeyPressedEventArgs();
this.RaiseEvent(e);
thisScope = e.Scope;
// Step 3: Compare scopes
if (thisScope == focusScope && (focusDO == null || (bool)focusDO.GetValue(KeyboardNavigation.AcceptsReturnProperty) == false))
{
isDefaulted = BooleanBoxes.TrueBox;
}
}
finally
{
SetValue(IsDefaultedPropertyKey, isDefaulted);
}
}