當前位置: 首頁>>代碼示例>>C#>>正文


C# Interactivity.RoutedEventArgs類代碼示例

本文整理匯總了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);
        }
開發者ID:Sergey-Terekhin,項目名稱:Perspex,代碼行數:12,代碼來源:InteractiveTests.cs

示例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);
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:12,代碼來源:InteractiveTests.cs

示例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));
                }
            }
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:12,代碼來源:Gestures.cs

示例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));
                }
            }
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:16,代碼來源:Gestures.cs

示例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);
        }
開發者ID:Sergey-Terekhin,項目名稱:Perspex,代碼行數:18,代碼來源:InteractiveTests.cs

示例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);
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:22,代碼來源:InteractiveTests.cs

示例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);
                }
            }
        }
開發者ID:rdterner,項目名稱:Perspex,代碼行數:16,代碼來源:SelectingItemsControl.cs

示例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;
 }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:10,代碼來源:Menu.cs

示例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;
 }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:9,代碼來源:Menu.cs

示例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;
                }
            }
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:19,代碼來源:SelectingItemsControl.cs

示例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);
                }
            }
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:25,代碼來源:FocusManager.cs

示例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);
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:23,代碼來源:InteractiveTests.cs

示例13: RaiseClickEvent

        /// <summary>
        /// Raises the <see cref="Click"/> event.
        /// </summary>
        private void RaiseClickEvent()
        {
            RoutedEventArgs click = new RoutedEventArgs
            {
                RoutedEvent = ClickEvent,
            };

            this.RaiseEvent(click);
        }
開發者ID:Scellow,項目名稱:Perspex,代碼行數:12,代碼來源:Button.cs

示例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;
                    }
                }
            }
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:19,代碼來源:MenuItem.cs

示例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);
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:19,代碼來源:InteractiveTests.cs


注:本文中的Perspex.Interactivity.RoutedEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。