本文整理汇总了C#中Perspex.Interactivity.RoutedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# RoutedEventArgs类的具体用法?C# RoutedEventArgs怎么用?C# RoutedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoutedEventArgs类属于Perspex.Interactivity命名空间,在下文中一共展示了RoutedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Direct_Event_Should_Go_Straight_To_Source
public void Direct_Event_Should_Go_Straight_To_Source()
{
var ev = new RoutedEvent("test", RoutingStrategies.Direct, typeof(RoutedEventArgs), typeof(TestInteractive));
var invoked = new List<string>();
EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
var target = CreateTree(ev, handler, RoutingStrategies.Direct);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(new[] { "2b" }, invoked);
}
示例2: Bubbling_Event_Should_Bubble_Up
public void Bubbling_Event_Should_Bubble_Up()
{
var ev = new RoutedEvent("test", RoutingStrategies.Bubble, typeof(RoutedEventArgs), typeof(TestInteractive));
var invoked = new List<string>();
EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
var target = this.CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(new[] { "2b", "1" }, invoked);
}
示例3: PointerReleased
private static void PointerReleased(RoutedEventArgs ev)
{
if (ev.Route == RoutingStrategies.Bubble)
{
var e = (PointerReleasedEventArgs)ev;
if (s_lastPress == e.Source)
{
s_lastPress.RaiseEvent(new RoutedEventArgs(TappedEvent));
}
}
}
示例4: PointerPressed
private static void PointerPressed(RoutedEventArgs ev)
{
if (ev.Route == RoutingStrategies.Bubble)
{
var e = (PointerPressedEventArgs)ev;
if (e.ClickCount <= 1)
{
s_lastPress = e.Source;
}
else if (e.ClickCount == 2 && s_lastPress == e.Source)
{
e.Source.RaiseEvent(new RoutedEventArgs(DoubleTappedEvent));
}
}
}
示例5: Direct_Event_Should_Have_Route_Set_To_Direct
public void Direct_Event_Should_Have_Route_Set_To_Direct()
{
var ev = new RoutedEvent("test", RoutingStrategies.Direct, typeof(RoutedEventArgs), typeof(TestInteractive));
bool called = false;
EventHandler<RoutedEventArgs> handler = (s, e) =>
{
Assert.Equal(RoutingStrategies.Direct, e.Route);
called = true;
};
var target = CreateTree(ev, handler, RoutingStrategies.Direct);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.True(called);
}
示例6: Bubbling_Subscription_Should_Not_Catch_Tunneling
public void Bubbling_Subscription_Should_Not_Catch_Tunneling()
{
var ev = new RoutedEvent(
"test",
RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
typeof(RoutedEventArgs),
typeof(TestInteractive));
var count = 0;
EventHandler<RoutedEventArgs> handler = (s, e) =>
{
Assert.Equal(RoutingStrategies.Bubble, e.Route);
++count;
};
var target = this.CreateTree(ev, handler, RoutingStrategies.Bubble);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(2, count);
}
示例7: ContainerSelectionChanged
/// <summary>
/// Called when a container raises the <see cref="IsSelectedChangedEvent"/>.
/// </summary>
/// <param name="e">The event.</param>
private void ContainerSelectionChanged(RoutedEventArgs e)
{
if (!_ignoreContainerSelectionChanged)
{
var selectable = (ISelectable)e.Source;
if (selectable != null)
{
UpdateSelectionFromEventSource(e.Source, selectable.IsSelected);
}
}
}
示例8: OnMenuClick
/// <summary>
/// Called when a submenu is clicked somewhere in the menu.
/// </summary>
/// <param name="e">The event args.</param>
private void OnMenuClick(RoutedEventArgs e)
{
Close();
FocusManager.Instance.Focus(null);
e.Handled = true;
}
示例9: OnLostFocus
/// <summary>
/// Called when the menu loses focus.
/// </summary>
/// <param name="e">The event args.</param>
protected override void OnLostFocus(RoutedEventArgs e)
{
base.OnLostFocus(e);
SelectedItem = null;
}
示例10: ItemIsSelectedChanged
/// <summary>
/// Called when the selection on a child item changes.
/// </summary>
/// <param name="e">The event args.</param>
protected virtual void ItemIsSelectedChanged(RoutedEventArgs e)
{
var selectable = e.Source as ISelectable;
if (selectable != null && selectable != this && selectable.IsSelected)
{
var container = this.ItemContainerGenerator.GetItemForContainer((Control)selectable);
if (container != null)
{
this.SelectedItem = container;
e.Handled = true;
}
}
}
示例11: OnPreviewPointerPressed
/// <summary>
/// Global handler for pointer pressed events.
/// </summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event args.</param>
private void OnPreviewPointerPressed(object sender, RoutedEventArgs e)
{
if (sender == e.Source)
{
var ev = (PointerPressEventArgs)e;
var element = (ev.Device.Captured as IInputElement) ?? (e.Source as IInputElement);
if (element == null || !CanFocus(element))
{
element = element.GetSelfAndVisualAncestors()
.OfType<IInputElement>()
.FirstOrDefault(x => CanFocus(x));
}
if (element != null)
{
this.Focus(element);
}
}
}
示例12: Events_Should_Have_Route_Set
public void Events_Should_Have_Route_Set()
{
var ev = new RoutedEvent(
"test",
RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
typeof(RoutedEventArgs),
typeof(TestInteractive));
var invoked = new List<RoutingStrategies>();
EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(e.Route);
var target = this.CreateTree(ev, handler, RoutingStrategies.Bubble | RoutingStrategies.Tunnel);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(new[]
{
RoutingStrategies.Tunnel,
RoutingStrategies.Tunnel,
RoutingStrategies.Bubble,
RoutingStrategies.Bubble,
},
invoked);
}
示例13: RaiseClickEvent
/// <summary>
/// Raises the <see cref="Click"/> event.
/// </summary>
private void RaiseClickEvent()
{
RoutedEventArgs click = new RoutedEventArgs
{
RoutedEvent = ClickEvent,
};
this.RaiseEvent(click);
}
示例14: OnSubmenuOpened
/// <summary>
/// Called when a submenu is opened on this MenuItem or a child MenuItem.
/// </summary>
/// <param name="e">The event args.</param>
protected virtual void OnSubmenuOpened(RoutedEventArgs e)
{
var menuItem = e.Source as MenuItem;
if (menuItem != null && menuItem.Parent == this)
{
foreach (var child in this.Items.OfType<MenuItem>())
{
if (child != menuItem && child.IsSubMenuOpen)
{
child.IsSubMenuOpen = false;
}
}
}
}
示例15: Direct_Class_Handlers_Should_Be_Called
public void Direct_Class_Handlers_Should_Be_Called()
{
var ev = new RoutedEvent(
"test",
RoutingStrategies.Direct,
typeof(RoutedEventArgs),
typeof(TestInteractive));
var invoked = new List<string>();
EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
var target = this.CreateTree(ev, null, 0);
ev.AddClassHandler(typeof(TestInteractive), handler, RoutingStrategies.Direct);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(new[] { "2b" }, invoked);
}