38 lines
1.7 KiB
C#
38 lines
1.7 KiB
C#
using ModpackUpdater.Apps.Manager.Api.Model;
|
|
using ModpackUpdater.Apps.Manager.Api.Plugins.Features;
|
|
using ModpackUpdater.Apps.Manager.LangRes;
|
|
using Pilz.Features;
|
|
using Pilz.UI.AvaloniaUI.Dialogs;
|
|
using Pilz.UI.Symbols;
|
|
|
|
namespace ModpackUpdater.Apps.Manager.Features.Workspaces.LocalFolder;
|
|
|
|
internal class LocalFolderWorkspaceFeature() : WorkspaceFeature("origin.localfolder", FeatureNamesLangRes.LocalFolderWorkspace), IPluginFeatureProvider<LocalFolderWorkspaceFeature>
|
|
{
|
|
public static LocalFolderWorkspaceFeature Instance { get; } = new();
|
|
|
|
public override object? Icon => AppGlobals.Symbols.GetImage(AppSymbols.opened_folder, SymbolSize.Small);
|
|
|
|
protected override async Task OnConfigure(WorkspaceContext context)
|
|
{
|
|
var settings = context.Workspace?.Config as LocalFolderWorkspaceConfig ?? new();
|
|
|
|
if ((await AvaloniaFlyoutBase.Show(
|
|
new LocalFolderWorkspaceConfigEditorView((LocalFolderWorkspaceConfig)settings.Clone()),
|
|
context.MainApi.MainWindow,
|
|
TitlesLangRes.LocalFolderWorkspaceEditor,
|
|
AppGlobals.Symbols.GetImageSource(AppSymbols.gitlab)))
|
|
.Result is LocalFolderWorkspaceConfig settingsNew)
|
|
context.Workspace = new LocalFolderWorkspace(settingsNew);
|
|
else
|
|
context.Canceled = true;
|
|
}
|
|
|
|
protected override void OnCreate(out IWorkspace workspace, WorkspaceConfig config)
|
|
{
|
|
if (config is not LocalFolderWorkspaceConfig gitlabConfig)
|
|
throw new NotSupportedException($"Only configs of type {nameof(LocalFolderWorkspaceConfig)} are allowed.");
|
|
workspace = new LocalFolderWorkspace(gitlabConfig);
|
|
}
|
|
}
|