// WARNING: is not thread safe. private void UpdateStoryListRowStatus(DataGridViewRow row, StorySyncWorkerStoryStatus status) { // Update the status var statusCell = row.Cells[COL_NAME_STATUS]; var newValue = ""; var newTooltip = ""; // Update the status switch (status.State) { case StorySyncWorkerStoryState.Error: newValue = "Error"; newTooltip = status.ErrorMessage; break; case StorySyncWorkerStoryState.WaitingItu: newValue = "Waiting"; newTooltip = $"Interactive temporarily unavailable. Last seen at {status.StateLastSet}"; break; case StorySyncWorkerStoryState.Working: newValue = "Syncing"; break; case StorySyncWorkerStoryState.Paused: newValue = "Paused"; break; } statusCell.Value = newValue; statusCell.ToolTipText = newTooltip; }
// WARNING: Is not thread safe. private void UpdateStoryListRowProgress(DataGridViewRow row, StorySyncWorkerStoryStatus status) { var newProgValue = DEFAULT_PROGRESS_VALUE; if (status.ProgressMax > 0) { newProgValue = $"{status.ProgressValue} / {status.ProgressMax}"; } var progCell = row.Cells[COL_NAME_PROGRESS]; progCell.Value = newProgValue; }
private void UpdateStoryStatus(string storyID, StorySyncWorkerStoryStatus status) { if (dgvStories.InvokeRequired) { this.Invoke(new UpdateStoryStatusDelegate(UpdateStoryStatus), storyID, status); } _log.Debug($"Updating story status '{storyID}'"); foreach (DataGridViewRow row in dgvStories.Rows) { // Find the story row if (row.Tag.ToString() == storyID) { UpdateStoryListRowStatus(row, status); UpdateStoryListRowProgress(row, status); return; // Go no further } } // Made it out here, didn't find the story _log.Debug($"Couldn't find a row for that story {storyID}. Something is wrong."); }
// Update a single list row with the sync status from the sync worker private void UpdateStoryListRow(DataGridViewRow row, StorySyncWorkerStoryStatus status) { // Update the status indicator UpdateStoryListRowStatus(row, status); UpdateStoryListRowProgress(row, status); }