Skip to content

Commit

Permalink
Fix wrong percentage assignment + check for thread access
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jan 1, 2025
1 parent 2d4efba commit 4091f81
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
28 changes: 22 additions & 6 deletions CollapseLauncher/XAMLs/MainApp/Pages/CachesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,38 @@ private void RemoveEvent()

private void _cacheTool_StatusChanged(object sender, TotalPerFileStatus e)
{
DispatcherQueue?.TryEnqueue(() =>
if (!DispatcherQueue.HasThreadAccess)
{
DispatcherQueue?.TryEnqueue(Update);
return;
}

Update();
return;
void Update()
{
CachesDataTableGrid.Visibility = e.IsAssetEntryPanelShow ? Visibility.Visible : Visibility.Collapsed;
CachesStatus.Text = e.ActivityStatus;
CachesStatus.Text = e.ActivityStatus;

CachesTotalStatus.Text = e.ActivityAll;
CachesTotalStatus.Text = e.ActivityAll;
CachesTotalProgressBar.IsIndeterminate = e.IsProgressAllIndetermined;
});
}
}

private void _cacheTool_ProgressChanged(object sender, TotalPerFileProgress e)
{
DispatcherQueue?.TryEnqueue(() =>
if (!DispatcherQueue.HasThreadAccess)
{
DispatcherQueue?.TryEnqueue(Update);
return;
}

Update();
return;
void Update()
{
CachesTotalProgressBar.Value = e.ProgressAllPercentage;
});
}
}

private void ResetStatusAndButtonState()
Expand Down
26 changes: 21 additions & 5 deletions CollapseLauncher/XAMLs/MainApp/Pages/RepairPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,15 @@ private void RemoveEvent()

private void _repairTool_StatusChanged(object sender, TotalPerFileStatus e)
{
DispatcherQueue?.TryEnqueue(() =>
if (!DispatcherQueue.HasThreadAccess)
{
DispatcherQueue?.TryEnqueue(Update);
return;
}

Update();
return;
void Update()
{
RepairDataTableGrid.Visibility = e.IsAssetEntryPanelShow ? Visibility.Visible : Visibility.Collapsed;
RepairStatus.Text = e.ActivityStatus;
Expand All @@ -191,16 +199,24 @@ private void _repairTool_StatusChanged(object sender, TotalPerFileStatus e)
RepairTotalStatus.Text = e.ActivityAll;
RepairTotalProgressBar.IsIndeterminate = e.IsProgressAllIndetermined;
RepairPerFileProgressBar.IsIndeterminate = e.IsProgressPerFileIndetermined;
});
};

Check warning on line 202 in CollapseLauncher/XAMLs/MainApp/Pages/RepairPage.xaml.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Empty statement is redundant

Empty statement is redundant

Check warning

Code scanning / QDNET

Empty statement is redundant Warning

Empty statement is redundant
}

private void _repairTool_ProgressChanged(object sender, TotalPerFileProgress e)
{
DispatcherQueue?.TryEnqueue(() =>
if (!DispatcherQueue.HasThreadAccess)
{
DispatcherQueue?.TryEnqueue(Update);
return;
}

Update();
return;
void Update()
{
RepairPerFileProgressBar.Value = Math.Min(e.ProgressPerFilePercentage, 100);
RepairTotalProgressBar.Value = Math.Min(e.ProgressPerFilePercentage, 100);
});
RepairTotalProgressBar.Value = Math.Min(e.ProgressAllPercentage, 100);
};

Check warning on line 219 in CollapseLauncher/XAMLs/MainApp/Pages/RepairPage.xaml.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Empty statement is redundant

Empty statement is redundant

Check warning

Code scanning / QDNET

Empty statement is redundant Warning

Empty statement is redundant
}

private void ResetStatusAndButtonState()
Expand Down

0 comments on commit 4091f81

Please sign in to comment.