73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
|
using ModpackUpdater.Apps.Manager.LangRes;
|
|
using ModpackUpdater.Apps.Manager.Ui;
|
|
using ModpackUpdater.Manager;
|
|
using Pilz.Plugins.Advanced;
|
|
using Telerik.WinControls.UI;
|
|
|
|
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
|
|
|
internal class CheckAllActionsHealthyFeature : PluginFunction, IPluginFeatureProvider<CheckAllActionsHealthyFeature>
|
|
{
|
|
public static CheckAllActionsHealthyFeature Instance { get; } = new();
|
|
|
|
public CheckAllActionsHealthyFeature() : base(FeatureTypes.Tools, "origin.checkallactionshearlthy", FeatureNamesLangRes.CheckAllActionsHealthy)
|
|
{
|
|
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.heart_with_pulse, Pilz.UI.Symbols.SymbolSize.Small);
|
|
}
|
|
|
|
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
|
{
|
|
if (@params is not MainApiParameters p
|
|
|| p.Api.MainWindow is not MainForm mainForm
|
|
|| mainForm.Controls.Find("radGridView_Actions", true).FirstOrDefault() is not RadGridView gridView
|
|
|| mainForm.Controls.Find("radWaitingBar_Actions", true).FirstOrDefault() is not RadWaitingBar rwb)
|
|
return null;
|
|
|
|
rwb.StartWaiting();
|
|
rwb.ShowText = true;
|
|
var rowsCount = gridView.Rows.Count;
|
|
rwb.Text = "0 / " + rowsCount;
|
|
gridView.BeginUpdate();
|
|
|
|
var rows = new Dictionary<GridViewRowInfo, InstallAction>();
|
|
for (var i = 0; i < gridView.Rows.Count; i++)
|
|
{
|
|
var row = gridView.Rows[i];
|
|
var failed = false;
|
|
|
|
if (row.Tag is InstallAction action)
|
|
{
|
|
Task.Run(async () =>
|
|
{
|
|
try
|
|
{
|
|
var factory = new ModpackFactory();
|
|
var result = await factory.ResolveSourceUrl(action);
|
|
failed = string.IsNullOrWhiteSpace(result);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}).Wait();
|
|
}
|
|
|
|
foreach (var c in row.Cells)
|
|
{
|
|
c.Style.CustomizeFill = true;
|
|
c.Style.BackColor = failed ? Color.IndianRed : Color.ForestGreen;
|
|
}
|
|
|
|
rwb.Text = $"{i} / {rowsCount}";
|
|
|
|
Application.DoEvents();
|
|
}
|
|
|
|
gridView.EndUpdate();
|
|
rwb.ShowText = false;
|
|
rwb.StopWaiting();
|
|
|
|
return null;
|
|
}
|
|
}
|