本文整理汇总了C#中System.Windows.Controls.MediaElement.RemoveHandler方法的典型用法代码示例。如果您正苦于以下问题:C# MediaElement.RemoveHandler方法的具体用法?C# MediaElement.RemoveHandler怎么用?C# MediaElement.RemoveHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.MediaElement
的用法示例。
在下文中一共展示了MediaElement.RemoveHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRemoveHandler
public void AddRemoveHandler ()
{
Delegate eh = new EventHandler ((object sender, EventArgs ea) => { });
Delegate keh = new KeyEventHandler ((object sender, KeyEventArgs ea) => { });
Delegate meh = new MouseButtonEventHandler ((object sender, MouseButtonEventArgs ea) => { });
Delegate weh = new MouseWheelEventHandler ((object sender, MouseWheelEventArgs ea) => { });
Delegate teh = new TextCompositionEventHandler ((object sender, TextCompositionEventArgs ea) => { });
// OK
RoutedEvent [] events1 = new RoutedEvent [] { UIElement.KeyDownEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonDownEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseWheelEvent, UIElement.TextInputEvent, UIElement.TextInputStartEvent, UIElement.TextInputUpdateEvent };
Delegate [] handlers1 = new Delegate [] { keh, keh, meh, meh, weh, teh, teh, teh };
// ArgumentNullException
RoutedEvent [] events2 = new RoutedEvent [] { null, UIElement.KeyUpEvent };
Delegate [] handlers2 = new Delegate [] { keh, null };
// ArgumentException
RoutedEvent [] events3 = new RoutedEvent [] { FrameworkElement.LoadedEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.TextInputUpdateEvent, UIElement.MouseWheelEvent };
Delegate [] handlers3 = new Delegate [] { eh, meh, keh, teh, eh , meh};
// NotImplementedException
RoutedEvent [] events4 = new RoutedEvent [] { UIElement.ManipulationCompletedEvent, UIElement.ManipulationDeltaEvent, UIElement.ManipulationStartedEvent };
Delegate [] handlers4 = new Delegate [] { eh, eh, eh };
UIElement ctrl = new MediaElement ();
// AddHandler
for (int i = 0; i < events1.Length; i++) {
ctrl.AddHandler (events1 [i], handlers1 [i], false);
}
for (int i = 0; i < events2.Length; i++) {
Assert.Throws<ArgumentNullException> (() => ctrl.AddHandler (events2 [i], handlers2 [i], false));
}
for (int i = 0; i < events3.Length; i++) {
Assert.Throws<ArgumentException> (() => ctrl.AddHandler (events3 [i], handlers3 [i], false));
}
for (int i = 0; i < events4.Length; i++) {
Assert.Throws<NotImplementedException> (() => ctrl.AddHandler (events4 [i], handlers4 [i], false));
}
// RemoveHandler
for (int i = 0; i < events1.Length; i++) {
ctrl.RemoveHandler (events1 [i], handlers1 [i]);
}
for (int i = 0; i < events2.Length; i++) {
Assert.Throws<ArgumentNullException> (() => ctrl.RemoveHandler (events2 [i], handlers2 [i]));
}
for (int i = 0; i < events3.Length; i++) {
Assert.Throws<ArgumentException> (() => ctrl.RemoveHandler (events3 [i], handlers3 [i]));
}
for (int i = 0; i < events4.Length; i++) {
Assert.Throws<NotImplementedException> (() => ctrl.RemoveHandler (events4 [i], handlers4 [i]));
}
}