/// <summary> /// Select the first task in the group before the current group and focus the control /// </summary> public void SelectPreviousGroupWithFocus() { if (FCurrentTaskList != null) { bool foundThisGroup = false; for (int i = 0; i < FCurrentTaskList.Controls.Count; i++) { TUcoTaskGroup group = (TUcoTaskGroup)FCurrentTaskList.Controls[i]; if (group.Name == FCurrentTaskList.CurrentGroupName) { foundThisGroup = true; } else if (foundThisGroup) { for (int k = 0; k < group.Controls[0].Controls.Count; k++) { TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k]; if (task.Enabled) { task.FocusTask(); return; } } } } } }
/// <summary> /// Select the next enabled task in the group in the direction specified. Returns true if a task could be selected. /// Returns false if there is no task or if there is a task but it is disabled. Disabled tasks are skipped if there is an enabled task beyond. /// </summary> /// <param name="ADirection"></param> /// <returns></returns> public bool SelectNextTask(Keys ADirection) { if (FCurrentTask == null) { return(false); } // Start by discovering the row and column of the current task in the group int currentRow, currentColumn; GetTaskLocation(out currentRow, out currentColumn); TUcoSingleTask nextTask = null; bool keepLooking = true; while (keepLooking) { // Find the next task at a specific location switch (ADirection) { case Keys.Right: nextTask = FindTaskAtLocation(currentRow, ++currentColumn); break; case Keys.Left: nextTask = FindTaskAtLocation(currentRow, --currentColumn); break; case Keys.Up: nextTask = FindTaskAtLocation(--currentRow, currentColumn); break; case Keys.Down: nextTask = FindTaskAtLocation(++currentRow, currentColumn); break; } if ((nextTask != null) && nextTask.Enabled) { // we found one and it is enabled nextTask.FocusTask(); return(true); } // if we found a task that was disabled we can go round again keepLooking = (nextTask != null); } return(false); }
/// <summary> /// Select the next enabled task in the group in the direction specified and starting with the task in a specific row and column. /// Returns true if a task could be selected. /// Returns false if there is no task or if there is a task but it is disabled. Disabled tasks are skipped if there is an enabled task beyond. /// </summary> /// <param name="ARow"></param> /// <param name="AColumn"></param> /// <param name="ADirection"></param> /// <returns></returns> public bool SelectNextTask(int ARow, int AColumn, Keys ADirection) { TUcoSingleTask nextTask = null; bool keepLooking = true; while (keepLooking) { // get the task at the location nextTask = FindTaskAtLocation(ARow, AColumn); if (nextTask != null) { if (nextTask.Enabled) { // we found one and it is enabled nextTask.FocusTask(); return(true); } // we found one but it was disabled - so try again in the specified direction switch (ADirection) { case Keys.Up: ARow--; break; case Keys.Down: ARow++; break; case Keys.Left: AColumn--; break; case Keys.Right: AColumn++; break; } } keepLooking = (nextTask != null); } return(false); }
/// <summary> /// Select the last task in the specified task list and set focus to the control /// </summary> private void SelectLastTaskWithFocus(TLstTasks ATaskList) { for (int i = 0; i < ATaskList.Controls.Count; i++) { TUcoTaskGroup group = (TUcoTaskGroup)ATaskList.Controls[i]; for (int k = group.Controls[0].Controls.Count - 1; k >= 0; k--) { TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k]; if (task.Enabled) { task.FocusTask(); return; } } } }
/// <summary> /// Select the first task in the specified task list and set focus to the control /// </summary> private void SelectFirstTaskWithFocus(TLstTasks ATaskList) { if (ATaskList == null) { return; } for (int i = ATaskList.Controls.Count - 1; i >= 0; i--) { TUcoTaskGroup group = (TUcoTaskGroup)ATaskList.Controls[i]; for (int k = 0; k < group.Controls[0].Controls.Count; k++) { TUcoSingleTask task = (TUcoSingleTask)group.Controls[0].Controls[k]; if (task.Enabled) { task.FocusTask(); return; } } } }