32 lines
1.3 KiB
C#
32 lines
1.3 KiB
C#
using ModpackUpdater.Apps.Manager.Api.Plugins.Params;
|
|
using ModpackUpdater.Apps.Manager.LangRes;
|
|
using Pilz.Plugins.Advanced;
|
|
using Telerik.WinControls;
|
|
|
|
namespace ModpackUpdater.Apps.Manager.Features.Tools;
|
|
|
|
internal class GenerateChangelogFeature : PluginFunction, IPluginFeatureProvider<GenerateChangelogFeature>
|
|
{
|
|
public static GenerateChangelogFeature Instance { get; } = new();
|
|
|
|
public GenerateChangelogFeature() : base(FeatureTypes.Tools, "origin.genchangelog", FeatureNamesLangRes.GenerateChangelogFeature)
|
|
{
|
|
Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.time_machine, 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.CurActionSet is not UpdateInfo updateInfos)
|
|
return null;
|
|
|
|
var changelog = SharedFunctions.GenerateChangelog(p.Api.CurWorkspace.InstallInfos, updateInfos);
|
|
if (!string.IsNullOrWhiteSpace(changelog))
|
|
{
|
|
Clipboard.SetText(changelog);
|
|
RadMessageBox.Show(p.Api.MainWindow, MsgBoxLangRes.ChangelogCopiedToClipboard, MsgBoxLangRes.ChangelogCopiedToClipboard_Title, MessageBoxButtons.OK, RadMessageIcon.Info);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|