public void TestKeyActionPriority() { int countPlay2 = 0; KeyAction play2 = new KeyAction(new KeyConfig { Name = "PLAY_2", Key = spaceHotkey }, () => countPlay2++, 1); KeyContext context = new KeyContext(); context.AddAction(play); context.AddAction(play2); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); context = new KeyContext(); context.AddAction(play2); context.AddAction(play); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); Assert.AreEqual(2, countPlay2); Assert.AreEqual(0, countPlay); }
public void TestGlobalContextWithACurrentContextPriorities() { App.Current.KeyContextManager.GlobalKeyContext.AddAction(globalAction); App.Current.KeyContextManager.GlobalKeyContext.AddAction(fastForward); KeyContext context = new KeyContext(); context.AddAction(play); context.AddAction(forward); context.AddAction(fastForward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(globalHotkey); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); App.Current.KeyContextManager.HandleKeyPressed(globalHotkey); App.Current.KeyContextManager.HandleKeyPressed(shiftRightHotkey); Assert.AreEqual(2, countPlay); Assert.AreEqual(1, countForward); Assert.AreEqual(1, countFastForward); Assert.AreEqual(2, countGlobal); }
public void TestContextPriorities1() { KeyContext context = new KeyContext(); context.AddAction(forward); context.AddAction(play); KeyContext tempContext = new KeyContext(); tempContext.AddAction(fastForward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); App.Current.KeyContextManager.AddContext(tempContext); App.Current.KeyContextManager.HandleKeyPressed(shiftRightHotkey); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); App.Current.KeyContextManager.RemoveContext(tempContext); App.Current.KeyContextManager.HandleKeyPressed(shiftRightHotkey); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); Assert.AreEqual(3, countPlay); Assert.AreEqual(3, countForward); Assert.AreEqual(1, countFastForward); }
public void TestContextPriorities2() { int countPlay2 = 0; KeyAction play2 = new KeyAction(new KeyConfig { Name = "PLAY_2", Key = spaceHotkey }, () => countPlay2++); KeyContext context = new KeyContext(); context.AddAction(play); context.AddAction(forward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); KeyContext context2 = new KeyContext(); context2.AddAction(play2); App.Current.KeyContextManager.AddContext(context2); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); App.Current.KeyContextManager.RemoveContext(context2); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); Assert.AreEqual(1, countPlay2); Assert.AreEqual(1, countPlay); Assert.AreEqual(1, countForward); }
public void SetUp() { videoPlayerVM = new VideoPlayerVM(); videoPlayerControllerMock = new Mock <IVideoPlayerController> (); videoPlayerVM.Player = videoPlayerControllerMock.Object; Project project = Utils.CreateProject(false); var period = new Period(); period.Nodes.Add(new TimeNode { Start = new Time(0), Stop = new Time(3000) }); project.Periods.Add(period); projectVM = new DummyProjectVM { Model = project }; camSyncVM = new CameraSynchronizationVM { VideoPlayer = videoPlayerVM, Project = projectVM }; camSyncController = new CameraSynchronizationController(); videoPlayerControllerMock.ResetCalls(); stateControllerMock.ResetCalls(); KeyContext context = new KeyContext(); foreach (KeyAction action in camSyncController.GetDefaultKeyActions()) { context.AddAction(action); } App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); }
public void NewKeyContexts_TempContextAdded_RemoveAfterTimeExpires() { // Arrange AutoResetEvent resetEvent = new AutoResetEvent(false); KeyTemporalContext tmpContext = new KeyTemporalContext(); tmpContext.AddAction(play); tmpContext.Duration = 100; tmpContext.ExpiredTimeAction = () => resetEvent.Set(); KeyContext context = new KeyContext(); context.AddAction(forward); mockToolkit.Setup(x => x.Invoke(It.IsAny <EventHandler> ())).Callback(() => Task.Factory.StartNew(() => tmpContext.ExpiredTimeAction())); // Act App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { tmpContext, context }); Assert.AreEqual(2, App.Current.KeyContextManager.CurrentKeyContexts.Count); // Assert resetEvent.WaitOne(); Assert.AreEqual(1, App.Current.KeyContextManager.CurrentKeyContexts.Count); resetEvent.Dispose(); }
public void Setup() { settings.EncodingSettings.OutputFile = Path.GetTempFileName(); App.Current.DatabaseManager = new LocalDatabaseManager(); project = Utils.CreateProject(); projectVM = new LMProjectVM { Model = project }; LMProjectAnalysisVM viewModel = new LMProjectAnalysisVM(); viewModel.VideoPlayer = videoPlayerVM; viewModel.Project = projectVM; projectsManager = new ProjectAnalysisController(); projectsManager.SetViewModel(viewModel); projectsManager.Start(); KeyContext context = new KeyContext(); foreach (KeyAction action in projectsManager.GetDefaultKeyActions()) { context.AddAction(action); } App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); }
public DashboardEditorController() { eventButtons = new List <AnalysisEventButtonVM> (); editDashboardKeyContext = new KeyContext(); editDashboardKeyContext.AddAction( new KeyAction(App.Current.HotkeysService.GetByName(GeneralUIHotkeys.DELETE), () => ViewModel.DeleteButton.Execute(ViewModel.Selection.FirstOrDefault()), 10) ); }
public void TestAddTemporalContext() { KeyContext context = new KeyContext(); context.AddAction(forward); context.AddAction(play); KeyContext tempContext = new KeyContext(); tempContext.AddAction(fastForward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.AddContext(tempContext); Assert.AreEqual(tempContext, App.Current.KeyContextManager.CurrentKeyContexts [ App.Current.KeyContextManager.CurrentKeyContexts.Count - 1]); }
public void TestHotkeyNotFallbacksCorrectly() { bool fallback = false; VAS.App.Current.EventsBroker.Subscribe <KeyPressedEvent> ( (e) => fallback = true ); KeyContext context = new KeyContext(); context.AddAction(play); context.AddAction(forward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); Assert.AreEqual(false, fallback); }
public void TestKeyContextWithAllActions() { KeyContext context = new KeyContext(); context.AddAction(play); context.AddAction(forward); context.AddAction(fastForward); App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(spaceHotkey); App.Current.KeyContextManager.HandleKeyPressed(rightHotkey); App.Current.KeyContextManager.HandleKeyPressed(shiftRightHotkey); Assert.AreEqual(2, countPlay); Assert.AreEqual(1, countForward); Assert.AreEqual(1, countFastForward); }
public KeyContext GetKeyContext() { var keyContext = new KeyContext(); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(GeneralUIHotkeys.ZOOM_IN), () => codingwidget.ZoomIn())); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(GeneralUIHotkeys.ZOOM_OUT), () => codingwidget.ZoomOut())); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(LMGeneralUIHotkeys.SHOW_ZONAL_TAGS), () => codingwidget.ShowZonalTags())); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(LMGeneralUIHotkeys.SHOW_DASHBOARD), () => codingwidget.ShowDashboard())); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(LMGeneralUIHotkeys.SHOW_TIMELINE), () => codingwidget.ShowTimeline())); keyContext.AddAction( new VKeyAction(App.Current.HotkeysService.GetByName(GeneralUIHotkeys.FIT_TIMELINE), () => codingwidget.FitTimeline())); return(keyContext); }
public KeyContext GetKeyContext() { var keyContext = new KeyContext(); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(GeneralUIHotkeys.COPY), blackboard.Copy) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(GeneralUIHotkeys.PASTE), blackboard.Paste) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(GeneralUIHotkeys.DELETE), blackboard.DeleteSelection) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_SELECT"), selectbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_ERASER"), eraserbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_PENCIL_TOOL"), penbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_TEXT_TOOL"), textbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_LINE_TOOL"), linebutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_X_TOOL"), crossbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_SQUARE"), rectanglebutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_FILLED_SQUARE"), rectanglefilledbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_CIRCLE"), ellipsebutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_FILLED_CIRCLE"), ellipsefilledbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_COUNTER"), numberbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_CLEAR_ALL"), clearbutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(GeneralUIHotkeys.DELETE), blackboard.DeleteSelection) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(GeneralUIHotkeys.SAVE), () => { if (savetoprojectbutton.Visible) { savetoprojectbutton.Click(); } }) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName("DRAWING_TOOL_EXPORT_IMAGE"), savebutton.Click) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_RIGHT), () => blackboard.MoveSelected(new Point(MOVE_OFFSET, 0))) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_LEFT), () => blackboard.MoveSelected(new Point(-MOVE_OFFSET, 0))) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_UP), () => blackboard.MoveSelected(new Point(0, -MOVE_OFFSET))) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_DOWN), () => blackboard.MoveSelected(new Point(0, MOVE_OFFSET))) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_TO_FRONT), () => blackboard.MoveToFront()) ); keyContext.AddAction( new KeyAction( App.Current.HotkeysService.GetByName(DrawingToolHotkeys.DRAWING_TOOL_MOVE_TO_BACK), () => blackboard.MoveToBack()) ); return(keyContext); }