protected override void Setup()
        {
            currentCellService = UIServiceProvider.GetService <ICurrentCellService>(TargetElement);
            Debug.Assert(currentCellService != null);

            inputService = UIServiceProvider.GetService <InputService>(TargetElement);
            Debug.Assert(inputService != null);

            scrollService = UIServiceProvider.GetService <IVerticalScrollService>(TargetElement);
            Debug.Assert(scrollService != null);

            inputService.RegisterKeyActionGestures(AsLineKeyAction(MoveLineDown), new KeyGesturesFactory(Key.Down, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));
            inputService.RegisterKeyActionGestures(AsLineKeyAction(MoveLineUp), new KeyGesturesFactory(Key.Up, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));
            inputService.RegisterKeyActionGestures(AsLineKeyAction(MovePageDown), new KeyGesturesFactory(Key.PageDown, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));
            inputService.RegisterKeyActionGestures(AsLineKeyAction(MovePageUp), new KeyGesturesFactory(Key.PageUp, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));
            inputService.RegisterKeyActionGestures(AsLineKeyAction(MoveToTop), new KeyGesturesFactory(Key.Home, ModifierKeys.Control));
            inputService.RegisterKeyActionGestures(AsLineKeyAction(MoveToBottom), new KeyGesturesFactory(Key.End, ModifierKeys.Control));

            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveRight), new KeyGesturesFactory(Key.Tab));
            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveRight), new KeyGesturesFactory(Key.Right, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));

            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveLeft), new KeyGesturesFactory(Key.Tab, ModifierKeys.Shift));
            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveLeft), new KeyGesturesFactory(Key.Left, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Control, ModifierKeys.Shift)));

            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveToLeftMost), new KeyGesturesFactory(Key.Home));
            inputService.RegisterKeyActionGestures(AsFieldKeyAction(MoveToRightMost), new KeyGesturesFactory(Key.End));

            inputService.RegisterMouseActionGestures(MouseClicked, new MouseGesturesFactory(MouseAction.LeftClick, InputGesturesFactory.AllCombinationsOf(ModifierKeys.Shift, ModifierKeys.Control)));
        }
 public CurrentCellServiceEventsHelper(ICurrentCellService target, EventInvocationValidator assertConditions)
 {
     this.target                        = target;
     this.assertConditions              = assertConditions;
     target.PreviewCurrentCellChanging += cellChangingEventHelper.Handler;
     target.CurrentCellChanged         += cellChangedEventHelper.Handler;
 }
Esempio n. 3
0
            protected override void Cleanup()
            {
                EditMode.TargetElement.RemoveHandler(FrameworkElement.PreviewKeyDownEvent, (RoutedEventHandler)TargetElement_PreviewKeyDown);
                EditMode.TargetElement.RemoveHandler(FrameworkElement.PreviewKeyUpEvent, (RoutedEventHandler)TargetElement_PreviewKeyUp);

                currentCellService = UIServiceProvider.GetService <ICurrentCellService>(EditMode.TargetElement);
                currentCellService.CurrentCellChanged -= currentCellService_CurrentCellChanged;
            }
Esempio n. 4
0
        public virtual void Setup()
        {
            CurrentCellService = UIServiceProvider.GetService <ICurrentCellService>(TargetElement);
            CommandRegulator   = UIServiceProvider.GetService <ICommandRegulationService>(TargetElement);

            CommandRegulator.PreviewCanExecute            += PreviewCanExecuteCommand;
            CurrentCellService.PreviewCurrentCellChanging += DataGridEditingExtender_PreviewCurrentChanging;
        }
Esempio n. 5
0
            protected override void Setup()
            {
                EditMode.TargetElement.AddHandler(FrameworkElement.PreviewKeyDownEvent, (RoutedEventHandler)TargetElement_PreviewKeyDown, true);
                EditMode.TargetElement.AddHandler(FrameworkElement.PreviewKeyUpEvent, (RoutedEventHandler)TargetElement_PreviewKeyUp, true);

                currentCellService = UIServiceProvider.GetService <ICurrentCellService>(EditMode.TargetElement);
                currentCellService.CurrentCellChanged         += currentCellService_CurrentCellChanged;
                currentCellService.PreviewCurrentCellChanging += currentCellService_PreviewCurrentCellChanging;
            }
        public void AttachToElement(FrameworkElement element)
        {
            TargetElement      = element;
            currentCellService = UIServiceProvider.GetService <ICurrentCellService>(TargetElement);
            currentCellService.CurrentCellChanged += new EventHandler(currentCellService_CurrentCellChanged);

            TargetElement.PreviewGotKeyboardFocus  += TargetElement_PreviewGotKeyboardFocus;
            TargetElement.PreviewLostKeyboardFocus += TargetElement_PreviewLostKeyboardFocus;
        }
        private void ExpectNoEvents(ICurrentCellService target, Action test)
        {
            var helper = new CurrentCellServiceEventsHelper(target, new CurrentCellServiceEventsHelper.EventInvocationValidator((pc, c) =>
            {
                Assert.IsFalse(pc.HandlerInvoked, "PreviewChange event was raised");
                Assert.IsFalse(c.HandlerInvoked, "Changed event was raised");
            }));

            helper.RunTest(test);
        }
        private void ExpectNonCancelableEvents(ICurrentCellService target, Action test)
        {
            var helper = new CurrentCellServiceEventsHelper(target, new CurrentCellServiceEventsHelper.EventInvocationValidator((pc, c) =>
            {
                Assert.AreEqual(1, pc.HandlerInvocationCount, "Expected preview change to be raised once.");
                Assert.IsFalse(pc.LastInocationEventArgs.IsCancelable, "Expected preview change to non-cancelable.");
                Assert.AreEqual(1, c.HandlerInvocationCount, "Expected change event to be raised once.");
            }));

            helper.RunTest(test);
        }
        public void DetachFromElement(FrameworkElement element)
        {
            if (TargetElement == null)
            {
                log.WarnFormat("Detaching extender {0} from {1} twice", this, element);
                return;
            }

            currentCellService.CurrentCellChanged  -= new EventHandler(currentCellService_CurrentCellChanged);
            TargetElement.PreviewLostKeyboardFocus -= TargetElement_PreviewLostKeyboardFocus;
            TargetElement.PreviewGotKeyboardFocus  -= TargetElement_PreviewGotKeyboardFocus;
            TargetElement      = null;
            currentCellService = null;
        }