当前位置: 首页>>代码示例>>C#>>正文


C# MediaElement.RemoveHandler方法代码示例

本文整理汇总了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]));
			}

		}
开发者ID:dfr0,项目名称:moon,代码行数:54,代码来源:UIElementTest.cs


注:本文中的System.Windows.Controls.MediaElement.RemoveHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。