add generate modlist feature
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
||||
using ModpackUpdater.Apps.Manager.LangRes;
|
||||
using OfficeOpenXml;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
||||
internal class GenerateModlistFeature : PluginFunction, IPluginFeatureProvider<GenerateModlistFeature>
|
||||
{
|
||||
public static GenerateModlistFeature Instance { get; } = new();
|
||||
|
||||
public GenerateModlistFeature() : base(FeatureTypes.Tools, "origin.genmodlist", FeatureNamesLangRes.GenerateModlistFeature)
|
||||
{
|
||||
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.list_view, Pilz.UI.Symbols.SymbolSize.Small);
|
||||
}
|
||||
|
||||
protected override object? ExecuteFunction(PluginFunctionParameter? @params)
|
||||
{
|
||||
if (@params is not MainApiParameters p || p.Api.CurWorkspace?.InstallInfos is null || p.Api.CurWorkspace?.InstallInfos is null)
|
||||
return null;
|
||||
|
||||
using var pkg = SharedFunctions.GenerateModlist(p.Api.CurWorkspace.InstallInfos);
|
||||
if (pkg is null)
|
||||
return null;
|
||||
|
||||
using var sfd = new RadSaveFileDialog
|
||||
{
|
||||
Filter = "*.xlsx|*.xlsx|*|*"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog(p.Api.MainWindow) == DialogResult.OK)
|
||||
{
|
||||
pkg.SaveAs(sfd.FileName);
|
||||
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes., MsgBoxLangRes., MessageBoxButtons.OK, RadMessageIcon.Info);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user