Example #1
0
 public StubCommandsProxy()
 {
     RefreshMapCommand = new CompositeCommand();
     ResetMapPanAndZoomCommand = new CompositeCommand();
     LoginCommand = new CompositeCommand();
     SelectActiveGameCommand = new CompositeCommand();
 }
 public SlideDisplay()
 {
     refresher = new DispatcherTimer();
     refresher.Interval = new TimeSpan(0, 0, 5);
     refresher.Tick += new EventHandler(refresherTick);
     refresher.Start();
     thumbnailList = new ObservableCollection<Slide>();
     thumbnailList.CollectionChanged += OnThumbnailCollectionChanged;
     SlideIndex = new SlideIndexConverter(thumbnailList);
     myMaxSlideIndex = -1;
     TeachersCurrentSlideIndex = -1;
     IsNavigationLocked = calculateNavigationLocked();
     InitializeComponent();
     DataContext = this;
     slides.PreviewKeyDown += new KeyEventHandler(KeyPressed);
     Commands.SyncedMoveRequested.RegisterCommand(new DelegateCommand<int>(MoveToTeacher));
     Commands.MoveTo.RegisterCommand(new DelegateCommand<Location>((loc) => MoveTo(loc, true), (loc) => slideInConversation(loc)));
     //Commands.ForcePageRefresh.RegisterCommand(new DelegateCommand<int>((slideIndex) => MoveTo(slideIndex, true), slideInConversation));
     Commands.UpdateConversationDetails.RegisterCommand(new DelegateCommand<ConversationDetails>(Display));
     Commands.AddSlide.RegisterCommand(new DelegateCommand<object>(addSlide, canAddSlide));
     Commands.MoveToNext.RegisterCommand(new DelegateCommand<object>(moveToNext, isNext));
     Commands.MoveToPrevious.RegisterCommand(new DelegateCommand<object>(moveToPrevious, isPrevious));
     Commands.JoinConversation.RegisterCommand(new DelegateCommand<ConversationDetails>(JoinConversation));
     Commands.ReceiveTeacherStatus.RegisterCommand(new DelegateCommand<TeacherStatus>(receivedStatus, (_unused) => { return StateHelper.mustBeInConversation(); }));
     Commands.EditConversation.RegisterCommand(new DelegateCommand<object>(EditConversation));
     Commands.UpdateNewSlideOrder.RegisterCommand(new DelegateCommand<int>(reorderSlides));
     Commands.LeaveLocation.RegisterCommand(new DelegateCommand<object>(resetLocationLocals));
     var paste = new CompositeCommand();
     paste.RegisterCommand(new DelegateCommand<object>(HandlePaste));
     slides.InputBindings.Add(new KeyBinding(paste, Key.V, ModifierKeys.Control));
     InputBindings.Add(new KeyBinding(paste, Key.V, ModifierKeys.Control));
 }
Example #3
0
 private static void Requery(CompositeCommand command)
 {
     if (command.RegisteredCommands.Count() > 0)
     {
         var delegateCommand = command.RegisteredCommands[0];
         delegateCommand.GetType().InvokeMember("RaiseCanExecuteChanged", BindingFlags.InvokeMethod, null, delegateCommand, new object[] { });
     }
 }
Example #4
0
 public SelfUnregisterableCommand(CompositeCommand command)
 {
     Command = command;
 }
Example #5
0
        public void RegisteringCommandTwiceThrows()
        {
            var compositeCommand = new CompositeCommand();
            var duplicateCommand = new TestCommand();
            compositeCommand.RegisterCommand(duplicateCommand);

            compositeCommand.RegisterCommand(duplicateCommand);
        }
Example #6
0
        public void RegisteringCommandInItselfThrows()
        {
            var compositeCommand = new CompositeCommand();

            compositeCommand.RegisterCommand(compositeCommand);
        }
Example #7
0
        public void ShouldIgnoreChangesToIsActiveDuringExecution()
        {
            var firstCommand = new MockActiveAwareCommand { IsActive = true };
            var secondCommand = new MockActiveAwareCommand { IsActive = true };

            // During execution set the second command to inactive, this should not affect the currently
            // executed selection.  
            firstCommand.ExecuteAction += new Action<object>((object parameter) => secondCommand.IsActive = false);

            var compositeCommand = new CompositeCommand(true);

            compositeCommand.RegisterCommand(firstCommand);
            compositeCommand.RegisterCommand(secondCommand);
            
            compositeCommand.Execute(null);

            Assert.IsTrue(secondCommand.WasExecuted);
        }
Example #8
0
        public void ShouldNotMonitorActivityIfUseActiveMonitoringFalse()
        {
            var mockCommand = new MockActiveAwareCommand();
            mockCommand.IsValid = true;
            mockCommand.IsActive = true;
            var nonActiveAwareCompositeCommand = new CompositeCommand(false);
            bool canExecuteChangedRaised = false;
            nonActiveAwareCompositeCommand.RegisterCommand(mockCommand);
            nonActiveAwareCompositeCommand.CanExecuteChanged += delegate
            {
                canExecuteChangedRaised = true;
            };

            mockCommand.IsActive = false;

            Assert.IsFalse(canExecuteChangedRaised);

            nonActiveAwareCompositeCommand.Execute(null);

            Assert.IsTrue(mockCommand.WasExecuted);
        }
Example #9
0
        public void ActivityCausesActiveAwareCommandToRequeryCanExecute()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            activeAwareCommand.RegisterCommand(command);
            command.IsActive = true;

            bool globalCanExecuteChangeFired = false;
            activeAwareCommand.CanExecuteChanged += delegate
                                                        {
                                                            globalCanExecuteChangeFired = true;
                                                        };

            Assert.IsFalse(globalCanExecuteChangeFired);
            command.IsActive = false;
            Assert.IsTrue(globalCanExecuteChangeFired);
        }
Example #10
0
        public void DispatchCommandShouldIgnoreInactiveCommandsInCanExecuteVote()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand commandOne = new MockActiveAwareCommand() { IsActive = false, IsValid = false };
            MockActiveAwareCommand commandTwo = new MockActiveAwareCommand() { IsActive = true, IsValid = true };

            activeAwareCommand.RegisterCommand(commandOne);
            activeAwareCommand.RegisterCommand(commandTwo);

            Assert.IsTrue(activeAwareCommand.CanExecute(null));
        }
Example #11
0
        public void DispatchCommandDoesNotIncludeInactiveRegisteredCommandInVoting()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            activeAwareCommand.RegisterCommand(command);
            command.IsValid = true;
            command.IsActive = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null), "Registered Click is inactive so should not participate in CanExecute vote");

            command.IsActive = true;

            Assert.IsTrue(activeAwareCommand.CanExecute(null));

            command.IsValid = false;

            Assert.IsFalse(activeAwareCommand.CanExecute(null));

        }
Example #12
0
        public void MultiDispatchCommandDoesNotExecutesInactiveRegisteredCommands()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand(true);
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            command.IsActive = false;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsFalse(command.WasExecuted);
        }
Example #13
0
        public void MultiDispatchCommandExecutesActiveRegisteredCommands()
        {
            CompositeCommand activeAwareCommand = new CompositeCommand();
            MockActiveAwareCommand command = new MockActiveAwareCommand();
            command.IsActive = true;
            activeAwareCommand.RegisterCommand(command);

            activeAwareCommand.Execute(null);

            Assert.IsTrue(command.WasExecuted);
        }