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


C# RoutedEvent类代码示例

本文整理汇总了C#中RoutedEvent的典型用法代码示例。如果您正苦于以下问题:C# RoutedEvent类的具体用法?C# RoutedEvent怎么用?C# RoutedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RoutedEvent类属于命名空间,在下文中一共展示了RoutedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UIElement_RaiseEvent_FocusChangedEvent_Test2

        public MFTestResults UIElement_RaiseEvent_FocusChangedEvent_Test2()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Log.Comment("Raising FocusChangedEventEvents and Verifying");
            //addToEvtRoute = false;
            btnEvent = false;
            fcsEvent = true;
            _fcsEventCntr = 0;
            rEvents = new RoutedEvent[] { Buttons.GotFocusEvent, Buttons.LostFocusEvent };
            for (int i = 0; i < rEvents.Length; i++)
            {
                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                 new DispatcherOperationCallback(AddToHandler), rEvents[i]);

                FocusChangedEventArgs fcea = new FocusChangedEventArgs(null, DateTime.Now, mainWindow, mainWindow);
                fcea.RoutedEvent = rEvents[i];

                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(RaiseEvent), fcea);
                if (_fcsEventCntr != i + 1)
                {
                    Log.Comment("FocusChangedEvent '" + rEvents[i].Name + "' event not raised");
                    testResult = MFTestResults.Fail;
                }
            }
            fcsEvent = false;

            return testResult;
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:29,代码来源:UIElementTests.cs

示例2: AddRoutedEventHandler

        private static void AddRoutedEventHandler(
            Hashtable table,
            RoutedEvent routedEvent,
            RoutedEventHandler handler,
            bool handledEventsToo)
        {
            if (routedEvent == null || handler == null)
            {
                throw new ArgumentNullException();
            }

            // Create a new RoutedEventHandler
            RoutedEventHandlerInfo routedEventHandlerInfo =
                new RoutedEventHandlerInfo(handler, handledEventsToo);

            // Get the entry corresponding to the given RoutedEvent
            ArrayList handlers = (ArrayList)table[routedEvent];
            if (handlers == null)
            {
                table[routedEvent] = (handlers = new ArrayList());
            }

            // Add the RoutedEventHandlerInfo to the list
            handlers.Add(routedEventHandlerInfo);
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:25,代码来源:UIElement.cs

示例3: UIElement_RaiseEvent_ButtonEvent_Test1

        public MFTestResults UIElement_RaiseEvent_ButtonEvent_Test1()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Log.Comment("Raising ButtonEvents and Verifying");
            //addToEvtRoute = false;
            btnEvent = true;
            fcsEvent = false;
            _btnEventCntr = 0;
            rEvents = new RoutedEvent[] { Buttons.ButtonDownEvent, Buttons.ButtonUpEvent,             
                Buttons.PreviewButtonDownEvent, Buttons.PreviewButtonUpEvent};
            for (int i = 0; i < rEvents.Length; i++)
            {
                //rEvent = rEvents[i];
                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(AddToHandler), rEvents[i]);

                ButtonEventArgs bea = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined1);
                bea.RoutedEvent = rEvents[i];

                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(RaiseEvent), bea);
                if (_btnEventCntr != i + 1)
                {
                    Log.Comment("ButtonEvent '" + rEvents[i].Name + "' event not raised");
                    testResult = MFTestResults.Fail;
                }
            }
            btnEvent = false;

            return testResult;
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:31,代码来源:UIElementTests.cs

示例4: PropertyValueChangedEventArgs

 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyValueChangedEventArgs"/> class.
 /// </summary>
 /// <param name="routedEvent">The routed event.</param>
 /// <param name="property">The property.</param>
 /// <param name="oldValue">The old value.</param>
 public PropertyValueChangedEventArgs(RoutedEvent routedEvent, PropertyItem property, object oldValue)
     : base(routedEvent, property)
 {
     Property = property;
     NewValue = property.PropertyValue;
     OldValue = oldValue;
 }
开发者ID:denkhaus,项目名称:WPG,代码行数:13,代码来源:PropertyValueChangedEventArgs.cs

示例5: AddHandler

 public static void AddHandler(object target, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo) {
     if (null == target)
         throw new ArgumentNullException("target");
     if (null == routedEvent)
         throw new ArgumentNullException("routedEvent");
     if (null == handler)
         throw new ArgumentNullException("handler");
     //
     RoutedEventKey key = routedEvent.Key;
     if (!routedEvents.ContainsKey(key))
         throw new ArgumentException("Specified routed event is not registered.", "routedEvent");
     RoutedEventInfo routedEventInfo = routedEvents[key];
     bool needAddTarget = true;
     if (routedEventInfo.targetsList != null) {
         RoutedEventTargetInfo targetInfo = routedEventInfo.targetsList.FirstOrDefault(info => info.target == target);
         if (null != targetInfo) {
             if (targetInfo.handlersList == null)
                 targetInfo.handlersList = new List<DelegateInfo>();
             targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
             needAddTarget = false;
         }
     }
     if (needAddTarget) {
         RoutedEventTargetInfo targetInfo = new RoutedEventTargetInfo(target);
         targetInfo.handlersList = new List<DelegateInfo>();
         targetInfo.handlersList.Add(new DelegateInfo(handler, handledEventsToo));
         if (routedEventInfo.targetsList == null)
             routedEventInfo.targetsList = new List<RoutedEventTargetInfo>();
         routedEventInfo.targetsList.Add(targetInfo);
     }
 }
开发者ID:CxSoftware,项目名称:consoleframework,代码行数:31,代码来源:EventManager.cs

示例6: MouseButtonEventArgs

 public MouseButtonEventArgs(RoutedEvent routedEvent, object originalSource, MouseDevice mouseDevice, int timestamp, Point absolutePosition, MouseButton changedButton, MouseButtonState buttonState, int clickCount)
     : base(routedEvent, originalSource, mouseDevice, timestamp, absolutePosition)
 {
     this.ChangedButton = changedButton;
     this.ButtonState = buttonState;
     this.ClickCount = clickCount;
 }
开发者ID:highzion,项目名称:Granular,代码行数:7,代码来源:MouseEventArgs.cs

示例7: UvmlRoutedEventHandlerMutator

        /// <summary>
        /// Initializes a new instance of the <see cref="UvmlRoutedEventHandlerMutator"/> class.
        /// </summary>
        /// <param name="revtID">The event which is being mutated.</param>
        /// <param name="revtHandler">The event handler to add to the event.</param>
        public UvmlRoutedEventHandlerMutator(RoutedEvent revtID, UvmlNode revtHandler)
        {
            Contract.Require(revtID, nameof(revtID));
            Contract.Require(revtHandler, nameof(revtHandler));

            this.revtID = revtID;
            this.revtHandler = revtHandler;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:13,代码来源:UvmlRoutedEventHandlerMutator.cs

示例8: MouseButtonEventArgs

 public MouseButtonEventArgs(object source, RoutedEvent routedEvent, Point rawPosition,
                             MouseButtonState leftButton, MouseButtonState middleButton,
                             MouseButtonState rightButton,
                             MouseButton button, int clickCount = 1)
     : base(source, routedEvent, rawPosition, leftButton, middleButton, rightButton) {
     this.button = button;
     this.clickCount = clickCount;
 }
开发者ID:CxSoftware,项目名称:consoleframework,代码行数:8,代码来源:MouseEventArgs.cs

示例9: WpfXamlMember

 public WpfXamlMember(RoutedEvent re, 
     EventInfo eventInfo,
     XamlSchemaContext schemaContext, 
     bool useV3Rules) 
     : base(eventInfo, schemaContext)
 { 
     RoutedEvent = re;
     _useV3Rules = useV3Rules;
     _underlyingMemberIsKnown = true;
 } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:10,代码来源:WpfXamlMember.cs

示例10: ScrollChangedEventArgs

 public ScrollChangedEventArgs(RoutedEvent routedEvent, object originalSource, Point offset, Point offsetChange, Size extent, Point extentChange, Size viewport, Point viewportChange)
     : base(routedEvent, originalSource)
 {
     this.Offset = offset;
     this.OffsetChange = offsetChange;
     this.Extent = extent;
     this.ExtentChange = extentChange;
     this.Viewport = viewport;
     this.ViewportChange = viewportChange;
 }
开发者ID:highzion,项目名称:Granular,代码行数:10,代码来源:ScrollChangedEventArgs.cs

示例11: RemoveHandler

        /// <summary>
        /// Removes a handler for a routed event from the specified input element.
        /// </summary>
        /// <param name="dobj">The input element from which to remove the event handler.</param>
        /// <param name="routedEvent">A <see cref="RoutedEvent"/> that identifies the routed event for which to remove a handler.</param>
        /// <param name="handler">A delegate that represents the handler to remove from the element for the specified routed event.</param>
        public static void RemoveHandler(DependencyObject dobj, RoutedEvent routedEvent, Delegate handler)
        {
            var element = dobj as IInputElement;
            if (element != null)
            {
                element.RemoveHandler(routedEvent, handler);
                return;
            }

            throw new ArgumentException(PresentationStrings.NotAnInputElement.Format("dobj"));
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:17,代码来源:IInputElementHelper.cs

示例12: 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);
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:12,代码来源:InteractiveTests.cs

示例13: Tunneling_Event_Should_Tunnel

        public void Tunneling_Event_Should_Tunnel()
        {
            var ev = new RoutedEvent("test", RoutingStrategies.Tunnel, 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.Bubble | RoutingStrategies.Tunnel);

            var args = new RoutedEventArgs(ev, target);
            target.RaiseEvent(args);

            Assert.Equal(new[] { "1", "2b" }, invoked);
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:12,代码来源:InteractiveTests.cs

示例14: MouseButtonEventArgs

 internal MouseButtonEventArgs(RoutedEvent routedEvent,
     MouseButton changedButton,
     MouseButtonState buttonState,
     int clickCount,
     System.Windows.Input.MouseButtonEventArgs args)
     : base(routedEvent)
 {
     this.ChangedButton = changedButton;
     this.ButtonState = buttonState;
     this.ClickCount = clickCount;
     this.originalMouseButtonEventArgs = args;
 }
开发者ID:mparsin,项目名称:Elements,代码行数:12,代码来源:MouseButtonState.cs

示例15: Activate

        /// <inheritdoc/>
        void IRoutedEventRaisedNotificationSubscriber.ReceiveRoutedEventRaisedNotification(DependencyObject dobj, RoutedEvent evt, RoutedEventData data)
        {
            if (!data.Handled || handled)
            {
                Activate(dobj);

                if (setHandled)
                {
                    data.Handled = true;
                }
            }
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:13,代码来源:UvssEventTrigger.cs


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