// Constructors and destructor public TaskGridSyncConfigureMessage(TaskGrid taskGrid, Action sendToServer) : base() { TaskGrid = taskGrid; SendToServer = sendToServer; taskGrid.ConfigureSync += TaskGrid_ConfigureSync; }
public MainWindow() { InitializeComponent(); AppState = new State(); TaskGrid.ItemsSource = Tasks; // Implement "sticky" scrolling. If the control is scrolled to the bottom, keep it that // way when new items are added. Otherwise, don't change the scroll position. // HACK: Wait a second for the initial cached to be populated, otherwise this takes ages. Task.Delay(3000).ContinueWith(_ => { this.Dispatcher.Invoke(() => { var viewer = GetScrollViewer(TaskGrid); Tasks.CollectionChanged += (sender, args) => { if (viewer.VerticalOffset >= viewer.ScrollableHeight - 1) { TaskGrid.ScrollIntoView(Tasks.Last()); } }; }); }); Task.Run(() => DoNetwork()); }
// Constructors and destructor public TaskGridSyncZoomMessage(TaskGrid taskGrid) { TaskGrid = taskGrid; Sent(); TaskGrid.ZoomSync += TaskGrid_ZoomSync; }
public void Primary(TaskGrid taskGrid) { this.bg.mainTexture = Resources.Load <Texture>(taskGrid.bg); this.title.text = taskGrid.title; this.content.text = taskGrid.content; this.index = taskGrid.index; }
protected virtual void StateController_CurrentStateUpdated(State currentState) { if (TaskGrid.IsConfigured && !TaskGrid.IsCompleted) { TaskGrid.Show(false); } }
// Methods public void SyncGrid(TaskGrid taskGrid) { if (gridEvent == GridEvent.Completed) { taskGrid.SetCompleted(); } else if (gridEvent == GridEvent.SetDragging) { taskGrid.SetDragged(isDragging); } else if (gridEvent == GridEvent.SetZooming) { taskGrid.SetZoomed(isZooming); } else { var container = taskGrid.At(new Vector2Int((int)containerPosition.x, (int)containerPosition.y)); if (gridEvent == GridEvent.ItemSelected) { var item = container.Elements[itemIndex]; taskGrid.SetItemSelected(item, container); } else if (gridEvent == GridEvent.ItemMoved) { taskGrid.SetItemMoved(container); } } }
protected virtual void TaskGrid_CompleteSync() { gridEvent = GridEvent.Completed; SendToServer(); TaskGrid.SetCompleted(); }
// Constructors and destructor public TaskGridSyncDragMessage(TaskGrid taskGrid) { TaskGrid = taskGrid; Sent(); TaskGrid.DragSync += TaskGrid_DragSync; }
protected virtual void TaskGrid_SetZoomingSync(bool isZooming) { this.isZooming = isZooming; gridEvent = GridEvent.SetZooming; SendToServer(); TaskGrid.SetZoomed(isZooming); }
protected virtual void TaskGrid_ItemMoveSync(Container container) { containerPosition = TaskGrid.GetPosition(container); gridEvent = GridEvent.ItemMoved; SendToServer(); TaskGrid.SetItemMoved(container); }
public void TaskGrid_Instanciate_ReturnsDefaultGridSize() { // Arrange & Act var taskGrid = new TaskGrid(); // Assert Assert.IsTrue(taskGrid.GridSize.X == 5 && taskGrid.GridSize.Y == 5); }
protected virtual void TaskGrid_Completed() { TaskGrid.Show(false); if (FingerCursorsInput != null) { FingerCursorsInput.DeactivateCursors(); FingerCursorsInput.enabled = false; } }
// TODO: remove, for debug testing only protected virtual void Update() { if (Input.GetKeyUp(KeyCode.B)) { OnConfigureExperimentSync(); StateController.BeginExperiment(); } if (Input.GetKeyUp(KeyCode.N)) { if (TaskGrid.IsConfigured) { TaskGrid.SetCompleted(); } StateController.NextState(); } if (Input.GetKeyUp(KeyCode.A)) { OnActivateTaskSync(); TaskGrid.Configure(); } if (Input.GetKeyUp(KeyCode.S)) { if (TaskGrid.IsConfigured) { TaskGrid.SetCompleted(); } } if (Input.GetKeyUp(KeyCode.Space)) { if (TaskGrid.IsConfigured) { TaskGrid.SetCompleted(); } StateController.NextState(); OnActivateTaskSync(); TaskGrid.Configure(); } if (Input.GetKeyUp(KeyCode.Z)) { SetTaskGridModeSync(TaskGrid.InteractionMode.Zoom); } if (Input.GetKeyUp(KeyCode.X)) { SetTaskGridModeSync(TaskGrid.InteractionMode.Pan); } if (Input.GetKeyUp(KeyCode.C)) { SetTaskGridModeSync(TaskGrid.InteractionMode.Select); } if (Input.GetKeyUp(KeyCode.V)) { SetTaskGridModeSync(TaskGrid.InteractionMode.Zoom | TaskGrid.InteractionMode.Pan | TaskGrid.InteractionMode.Select); } }
public void TaskGrid_AddValidGridItem_ReturnsSuccessTrue() { // Arrange var taskGrid = new TaskGrid(); // Act var result = taskGrid.AddGridItem <Robot>(gridItemTestName); // Assert Assert.IsTrue(result.Success); }
public void TaskGrid_AddGridItem_NullGridItem_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); // Act var result = taskGrid.AddGridItem <Robot>(null); // Assert Assert.IsFalse(result.Success); }
// Methods protected virtual void Awake() { deviceController.FingerCursorsInput.Updated += CursorsInput_Updated; taskGrid = deviceController.TaskGrid; taskGrid.Configured += TaskGrid_Configured; SetVisible(false); SetActive(true); IsOnGrid = false; }
public void TaskGrid_RunCommand_NoGridItemNoCommand_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); // Act var result = taskGrid.RunCommand("", ""); // Assert Assert.IsFalse(result.Success); }
public void TaskGrid_RunCommand_NoGridItemWithNameValidCommand_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); // Act var result = taskGrid.RunCommand(gridItemTestName, "Place 1,1,North"); // Assert Assert.IsFalse(result.Success); }
protected virtual void TaskGrid_ItemSelectSync(Item item) { var container = TaskGrid.GetContainer(item); containerPosition = TaskGrid.GetPosition(container); itemIndex = container.Elements.IndexOf(item); gridEvent = GridEvent.ItemSelected; SendToServer(); TaskGrid.SetItemSelected(item, container); }
public void RunCommand_InValidCommandFirst_ReturnsSuccessFalse(string command) { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); // Act var result = taskGrid.RunCommand(gridItemTestName, command); // Assert Assert.IsFalse(result.Success); }
// Constructors and destructor public TaskGridSyncEventsMessage(TaskGrid taskGrid, Action sendToServer) { TaskGrid = taskGrid; SendToServer = sendToServer; TaskGrid.CompleteSync += TaskGrid_CompleteSync; TaskGrid.SetDraggingSync += TaskGrid_SetDraggingSync; TaskGrid.SetZoomingSync += TaskGrid_SetZoomingSync; TaskGrid.ItemSelectSync += TaskGrid_ItemSelectSync; TaskGrid.ItemMoveSync += TaskGrid_ItemMoveSync; }
public void RunCommand_InValidPlaceWithMissingParamsCommand_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); // Act var result = taskGrid.RunCommand(gridItemTestName, "Place 1,NORTH"); // Assert Assert.IsFalse(result.Success); }
public void RunCommand_ValidPlaceCommand_ReturnsSuccessTrue() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); // Act var result = taskGrid.RunCommand(gridItemTestName, "Place 1,1,EAST"); // Assert Assert.IsTrue(result.Success); }
public void TaskGrid_PlaceItemOutsideGridBoundsX_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); // Act var result = taskGrid.RunCommand(gridItemTestName, "Place 5,1,North"); // Assert Assert.IsFalse(result.Success); }
public void RunCommand_MoveOffBoard_ReturnsSuccessFalse() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); taskGrid.RunCommand(gridItemTestName, "Place 1,1,WEST"); taskGrid.RunCommand(gridItemTestName, "Move"); // Act var result = taskGrid.RunCommand(gridItemTestName, "Move"); // Assert Assert.IsFalse(result.Success); }
public void RunCommand_ValidPlaceThenReportCommand_ReturnsCorrectOutput() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); taskGrid.RunCommand(gridItemTestName, "Place 1,1,EAST"); // Act var result = taskGrid.RunCommand(gridItemTestName, "Report"); // Assert Assert.AreEqual(result.Output, "1,1,EAST"); }
public void RunCommand_ValidMoveInDirectionCommand_ReturnsCorrectCoordinates(string direction, string correctResult) { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); taskGrid.RunCommand(gridItemTestName, $"Place 1,1,{direction}"); taskGrid.RunCommand(gridItemTestName, "Move"); // Act var result = taskGrid.RunCommand(gridItemTestName, "Report"); // Assert Assert.IsTrue(result.Output.StartsWith(correctResult)); }
public void RunCommand_ValidRightThenReportCommand_ReturnsCorrectDirection() { // Arrange var taskGrid = new TaskGrid(); taskGrid.AddGridItem <Robot>(gridItemTestName); taskGrid.RunCommand(gridItemTestName, "Place 1,1,EAST"); taskGrid.RunCommand(gridItemTestName, "Right"); // Act var result = taskGrid.RunCommand(gridItemTestName, "Report"); // Assert Assert.IsTrue(result.Output.EndsWith("SOUTH", StringComparison.InvariantCultureIgnoreCase)); }
// TODO: remove, for debug testing only protected virtual IEnumerator StartTaskDebug() { yield return(null); OnConfigureExperimentSync(); StateController.BeginExperiment(); yield return(null); StateController.NextState(); yield return(null); OnActivateTaskSync(); TaskGrid.Configure(); }
// Methods public void ConfigureGrid(TaskGrid taskGrid) { var containers = new GridGenerator.Container[rowsNumber, columnsNumber]; IterateContainers(rowsNumber, columnsNumber, itemsPerContainer, (row, col, itemIndex, valueIndex) => { if (itemIndex == 0) { containers[row, col].items = new int[itemsPerContainer]; } containers[row, col].items[itemIndex] = itemValues[valueIndex]; }); var gridGenerator = new GridGenerator(containers, incorrectContainersNumber); taskGrid.SetConfiguration(gridGenerator); }
public void Primary(TaskGrid taskGrid){ this.bg.mainTexture = Resources.Load<Texture>(taskGrid.bg); this.title.text = taskGrid.title; this.content.text = taskGrid.content; this.index = taskGrid.index; }