private void OnDoneButtonClick(object sender, EventArgs e) { bool current = this.task.hasCompleted; this.task.UpdateHomeworkStatus(!current); MessageBox.Show("Updated!"); int currentTabIndex = tabController.SelectedIndex; tabController.UpdateTabs(disposeCurrentTabs: true); // The current tabs are incorrect, but the data is the same tabController.SelectedIndex = currentTabIndex; // Ensures the program stays on the same tab }
async private void OnRefreshButtonClick(object sender, EventArgs e) { refreshButton.Enabled = false; // Disable refresh button and show loading loadingLabel.Show(); loadingLabel.Text = "Loading your homework, please wait..."; progressBar.Show(); label3.Show(); tabController.Hide(); Homework[] tasks = await APIHandler.GetHomework(student : user, groupHardRefresh : true); tabController.UpdateTabs(disposeCurrentTabs: true, newTasks: tasks); // Provide new data to the tab controller this.user = await APIHandler.GetStudent(id : this.user.id); // Update student DecorateForm(); // Update the form accordingly (e.g. new ALPs grade, username) // TODO: Show error to re-sign-in if a teacher changes username whilst student using the program refreshButton.Enabled = true; loadingLabel.Hide(); progressBar.Hide(); label3.Hide(); tabController.Show(); }