From 9bfd83ee4a8cda2d9e23985e2794c7d4b23d9556 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Fri, 6 Sep 2024 15:16:19 +0200 Subject: [PATCH] some background code for manager workspaces --- .../Api/Model/IMainApi.cs | 6 + .../Api/Model/IWorkspace.cs | 14 +- .../Api/Model/WorkspaceConfig.cs | 8 ++ .../Api/Plugins/Features/WorkspaceFeature.cs | 26 ++++ .../Api/Plugins/Params/MainApiParameters.cs | 9 ++ .../Plugins/Params/WorkspaceInitParameters.cs | 7 - ModpackUpdater.Apps.Manager/FeatureTypes.cs | 1 + .../GitLabRepo/GitLabRepoWorkspace.cs | 62 ++++++++- .../GitLabRepo/GitLabRepoWorkspaceConfig.cs | 12 ++ .../GitLabRepoWorkspaceConfigEditor.cs | 18 +-- .../GitLabRepo/GitLabRepoWorkspaceFeature.cs | 24 ++-- .../GitLabRepo/GitLabRepoWorkspaceSettings.cs | 5 - ModpackUpdater.Apps.Manager/Form1.Designer.cs | 50 +++++-- ModpackUpdater.Apps.Manager/Form1.cs | 32 ++++- .../LangRes/TitlesLangRes.Designer.cs | 72 ++++++++++ .../LangRes/TitlesLangRes.resx | 123 ++++++++++++++++++ .../ModpackUpdater.Apps.Manager.csproj | 17 +++ ModpackUpdater.Apps.Manager/Program.cs | 26 +++- .../Settings/WorkspaceSettings.cs | 16 +++ ModpackUpdater.Apps/AppSymbols.cs | 1 + ModpackUpdater.Apps/Symbols/gitlab.svg | 10 ++ ModpackUpdater/InstallInfos.cs | 5 + ModpackUpdater/UpdateInfos.cs | 5 + 23 files changed, 497 insertions(+), 52 deletions(-) create mode 100644 ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs create mode 100644 ModpackUpdater.Apps.Manager/Api/Model/WorkspaceConfig.cs create mode 100644 ModpackUpdater.Apps.Manager/Api/Plugins/Features/WorkspaceFeature.cs create mode 100644 ModpackUpdater.Apps.Manager/Api/Plugins/Params/MainApiParameters.cs delete mode 100644 ModpackUpdater.Apps.Manager/Api/Plugins/Params/WorkspaceInitParameters.cs create mode 100644 ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfig.cs delete mode 100644 ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceSettings.cs create mode 100644 ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.Designer.cs create mode 100644 ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.resx create mode 100644 ModpackUpdater.Apps.Manager/Settings/WorkspaceSettings.cs create mode 100644 ModpackUpdater.Apps/Symbols/gitlab.svg diff --git a/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs b/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs new file mode 100644 index 0000000..73fb9a9 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Api/Model/IMainApi.cs @@ -0,0 +1,6 @@ +namespace ModpackUpdater.Apps.Manager.Api.Model; + +public interface IMainApi +{ + public IWorkspace? Workspace { get; } +} diff --git a/ModpackUpdater.Apps.Manager/Api/Model/IWorkspace.cs b/ModpackUpdater.Apps.Manager/Api/Model/IWorkspace.cs index adc258b..77a81f6 100644 --- a/ModpackUpdater.Apps.Manager/Api/Model/IWorkspace.cs +++ b/ModpackUpdater.Apps.Manager/Api/Model/IWorkspace.cs @@ -1,5 +1,17 @@ -namespace ModpackUpdater.Apps.Manager.Api.Model; +using System.Diagnostics.CodeAnalysis; + +namespace ModpackUpdater.Apps.Manager.Api.Model; public interface IWorkspace { + WorkspaceConfig Config { get; } + + InstallInfos? InstallInfos { get; } + + UpdateInfos? UpdateInfos { get; } + + [MemberNotNullWhen(true, nameof(InstallInfos), nameof(UpdateInfos))] + Task Load(); + + Task Save(); } diff --git a/ModpackUpdater.Apps.Manager/Api/Model/WorkspaceConfig.cs b/ModpackUpdater.Apps.Manager/Api/Model/WorkspaceConfig.cs new file mode 100644 index 0000000..5db78d9 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Api/Model/WorkspaceConfig.cs @@ -0,0 +1,8 @@ +namespace ModpackUpdater.Apps.Manager.Api.Model; + +public class WorkspaceConfig +{ + public string ProviderId { get; internal set; } = "origin.unknown"; + public string FileLocationInstallJson { get; set; } = "install.json"; + public string FileLocationUpdateJson { get; set; } = "update.json"; +} diff --git a/ModpackUpdater.Apps.Manager/Api/Plugins/Features/WorkspaceFeature.cs b/ModpackUpdater.Apps.Manager/Api/Plugins/Features/WorkspaceFeature.cs new file mode 100644 index 0000000..e84c36a --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Api/Plugins/Features/WorkspaceFeature.cs @@ -0,0 +1,26 @@ +using ModpackUpdater.Apps.Manager.Api.Model; +using Pilz.Plugins.Advanced; + +namespace ModpackUpdater.Apps.Manager.Api.Plugins.Features; + +public abstract class WorkspaceFeature(string identifier, string name) : PluginFeature(FeatureTypes.Workspace, identifier, name) +{ + public virtual bool CanConfigure(IWorkspace workspace) + { + return workspace?.Config == null || workspace.Config.ProviderId == Identifier; + } + + public virtual bool Configure(ref IWorkspace workspace) + { + OnConfigure(ref workspace); + + if (workspace?.Config == null) + return false; + + workspace.Config.ProviderId = Identifier; + + return true; + } + + protected abstract bool OnConfigure(ref IWorkspace workspace); +} diff --git a/ModpackUpdater.Apps.Manager/Api/Plugins/Params/MainApiParameters.cs b/ModpackUpdater.Apps.Manager/Api/Plugins/Params/MainApiParameters.cs new file mode 100644 index 0000000..96ab798 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Api/Plugins/Params/MainApiParameters.cs @@ -0,0 +1,9 @@ +using ModpackUpdater.Apps.Manager.Api.Model; +using Pilz.Plugins.Advanced; + +namespace ModpackUpdater.Apps.Manager.Api.Plugins.Params; + +public class MainApiParameters(IMainApi api) : PluginFunctionParameter +{ + public IMainApi Api { get; } = api; +} diff --git a/ModpackUpdater.Apps.Manager/Api/Plugins/Params/WorkspaceInitParameters.cs b/ModpackUpdater.Apps.Manager/Api/Plugins/Params/WorkspaceInitParameters.cs deleted file mode 100644 index 1497f1a..0000000 --- a/ModpackUpdater.Apps.Manager/Api/Plugins/Params/WorkspaceInitParameters.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Pilz.Plugins.Advanced; - -namespace ModpackUpdater.Apps.Manager.Api.Plugins.Params; - -public class WorkspaceInitParameters : PluginFunctionParameter -{ -} diff --git a/ModpackUpdater.Apps.Manager/FeatureTypes.cs b/ModpackUpdater.Apps.Manager/FeatureTypes.cs index bf857ce..b0340eb 100644 --- a/ModpackUpdater.Apps.Manager/FeatureTypes.cs +++ b/ModpackUpdater.Apps.Manager/FeatureTypes.cs @@ -3,4 +3,5 @@ public static class FeatureTypes { public static string Workspace => "workspace"; + public static string Tools => "tools"; } diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs index 522963c..e3c8642 100644 --- a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs +++ b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspace.cs @@ -1,7 +1,67 @@ using ModpackUpdater.Apps.Manager.Api.Model; +using NGitLab; +using NGitLab.Models; +using System.Text.Encodings.Web; namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; -internal class GitLabRepoWorkspace : IWorkspace +internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspace { + public WorkspaceConfig Config => ConfigX; + + public GitLabRepoWorkspaceConfig ConfigX { get; } = config; + + public IGitLabClient Gitlab { get; } = new GitLabClient(config.InstanceUrl, config.ApiToken); + + public InstallInfos? InstallInfos { get; private set; } + + public UpdateInfos? UpdateInfos { get; private set; } + + public async Task Load() + { + InstallInfos = InstallInfos.Parse(await GetContent(ConfigX.FileLocationInstallJson)); + UpdateInfos = UpdateInfos.Parse(await GetContent(ConfigX.FileLocationUpdateJson)); + return InstallInfos != null && UpdateInfos != null; + } + + public async Task Save() + { + if (InstallInfos != null) + await SaveContent(ConfigX.FileLocationInstallJson, InstallInfos.ToString()); + + if (UpdateInfos != null) + await SaveContent(ConfigX.FileLocationUpdateJson, UpdateInfos.ToString()); + + return true; + } + + private async Task GetContent(string path) + { + var pathUrl = UrlEncoder.Default.Encode(path); + var repoId = new ProjectId(ConfigX.RepoId); + var repo = Gitlab.GetRepository(repoId); + var data = await repo.Files.GetAsync(pathUrl, ConfigX.RepoBranche); + return data.DecodedContent; + } + + private Task SaveContent(string path, string content) + { + var pathUrl = UrlEncoder.Default.Encode(path); + var repoId = new ProjectId(ConfigX.RepoId); + var repo = Gitlab.GetRepository(repoId); + var update = new FileUpsert + { + Branch = ConfigX.RepoBranche, + CommitMessage = "update " + Path.GetFileName(pathUrl), + RawContent = content, + Path = pathUrl, + }; + + if (repo.Files.FileExists(pathUrl, ConfigX.RepoBranche)) + repo.Files.Update(update); + else + repo.Files.Create(update); + + return Task.FromResult(true); + } } diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfig.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfig.cs new file mode 100644 index 0000000..fe15f2f --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfig.cs @@ -0,0 +1,12 @@ +using ModpackUpdater.Apps.Manager.Api.Model; +using Pilz.Configuration; + +namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; + +internal class GitLabRepoWorkspaceConfig : WorkspaceConfig +{ + public string InstanceUrl { get; set; } = "https://gitlab.com"; + public string? ApiToken { get; set; } + public long RepoId { get; set; } = -1L; + public string RepoBranche { get; set; } = "master"; +} diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfigEditor.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfigEditor.cs index 039a2d8..268f6ec 100644 --- a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfigEditor.cs +++ b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceConfigEditor.cs @@ -1,18 +1,14 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using Pilz.UI.Telerik.Dialogs; namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; -public partial class GitLabRepoWorkspaceConfigEditor : UserControl + +internal partial class GitLabRepoWorkspaceConfigEditor : RadFlyoutBase { - public GitLabRepoWorkspaceConfigEditor() + private readonly GitLabRepoWorkspaceConfig settings; + + public GitLabRepoWorkspaceConfigEditor(GitLabRepoWorkspaceConfig settings) { + this.settings = settings; InitializeComponent(); } } diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceFeature.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceFeature.cs index 47f2818..ffc25af 100644 --- a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceFeature.cs +++ b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceFeature.cs @@ -1,26 +1,30 @@ using ModpackUpdater.Apps.Manager.Api.Model; -using ModpackUpdater.Apps.Manager.Api.Plugins.Params; +using ModpackUpdater.Apps.Manager.Api.Plugins.Features; +using ModpackUpdater.Apps.Manager.LangRes; using Pilz.Plugins.Advanced; +using Pilz.UI.Extensions; +using Pilz.UI.Symbols; +using Pilz.UI.Telerik.Dialogs; namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; -internal class GitLabRepoWorkspaceFeature : PluginFunction, IPluginFeatureProvider +internal class GitLabRepoWorkspaceFeature : WorkspaceFeature, IPluginFeatureProvider { public static GitLabRepoWorkspaceFeature Instance { get; } = new(); - public GitLabRepoWorkspaceFeature() : base(FeatureTypes.Workspace, "origin.gitlab", "GitLab repository") + public GitLabRepoWorkspaceFeature() : base("origin.gitlab", "GitLab repository") { - Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.github, Pilz.UI.Symbols.SymbolSize.Small); + Icon = AppGlobals.Symbols.GetSvgImage(AppSymbols.gitlab, SymbolSize.Small); } - protected override object? ExecuteFunction(PluginFunctionParameter? @params) + protected override bool OnConfigure(ref IWorkspace workspace) { - if (@params is not WorkspaceInitParameters p) - return null; + var settings = workspace?.Config as GitLabRepoWorkspaceConfig ?? new(); - /// Open config UI - /// ... + if (RadDialogBase.ShowDialog(new GitLabRepoWorkspaceConfigEditor(settings), TitlesLangRes.GitLabRepoWorkspaceEditor, AppGlobals.Symbols.GetSvgImage(AppSymbols.gitlab, SymbolSize.Small)).Result.IsNotOk()) + return false; - return new GitLabRepoWorkspace(); + workspace = new GitLabRepoWorkspace(settings); + return true; } } diff --git a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceSettings.cs b/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceSettings.cs deleted file mode 100644 index 2a1b518..0000000 --- a/ModpackUpdater.Apps.Manager/Features/Workspaces/GitLabRepo/GitLabRepoWorkspaceSettings.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo; - -internal class GitLabRepoWorkspaceSettings -{ -} diff --git a/ModpackUpdater.Apps.Manager/Form1.Designer.cs b/ModpackUpdater.Apps.Manager/Form1.Designer.cs index 295f55b..aa0bab8 100644 --- a/ModpackUpdater.Apps.Manager/Form1.Designer.cs +++ b/ModpackUpdater.Apps.Manager/Form1.Designer.cs @@ -28,7 +28,7 @@ partial class Form1 /// private void InitializeComponent() { - var tableViewDefinition2 = new Telerik.WinControls.UI.TableViewDefinition(); + var tableViewDefinition1 = new Telerik.WinControls.UI.TableViewDefinition(); radSplitContainer1 = new Telerik.WinControls.UI.RadSplitContainer(); splitPanel1 = new Telerik.WinControls.UI.SplitPanel(); tableLayoutPanel2 = new TableLayoutPanel(); @@ -36,10 +36,13 @@ partial class Form1 splitPanel2 = new Telerik.WinControls.UI.SplitPanel(); tableLayoutPanel1 = new TableLayoutPanel(); radGridView_Actions = new Telerik.WinControls.UI.RadGridView(); - radMenuItem1 = new Telerik.WinControls.UI.RadMenuItem(); - radMenuItem_OpenWorkspace = new Telerik.WinControls.UI.RadMenuItem(); + radMenuItem_Workspace = new Telerik.WinControls.UI.RadMenuItem(); + radMenuItem_WorkspacePreferences = new Telerik.WinControls.UI.RadMenuItem(); radMenuItem2 = new Telerik.WinControls.UI.RadMenuItem(); radMenu1 = new Telerik.WinControls.UI.RadMenu(); + radMenuSeparatorItem1 = new Telerik.WinControls.UI.RadMenuSeparatorItem(); + radMenuItem_OpenNewWorkspace = new Telerik.WinControls.UI.RadMenuItem(); + radMenuItem_RecentWorkspaces = new Telerik.WinControls.UI.RadMenuItem(); ((System.ComponentModel.ISupportInitialize)radSplitContainer1).BeginInit(); radSplitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)splitPanel1).BeginInit(); @@ -144,21 +147,21 @@ partial class Form1 // // // - radGridView_Actions.MasterTemplate.ViewDefinition = tableViewDefinition2; + radGridView_Actions.MasterTemplate.ViewDefinition = tableViewDefinition1; radGridView_Actions.Name = "radGridView_Actions"; radGridView_Actions.Size = new Size(544, 416); radGridView_Actions.TabIndex = 0; // - // radMenuItem1 + // radMenuItem_Workspace // - radMenuItem1.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem_OpenWorkspace }); - radMenuItem1.Name = "radMenuItem1"; - radMenuItem1.Text = "File"; + radMenuItem_Workspace.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem_WorkspacePreferences, radMenuSeparatorItem1, radMenuItem_OpenNewWorkspace, radMenuItem_RecentWorkspaces }); + radMenuItem_Workspace.Name = "radMenuItem_Workspace"; + radMenuItem_Workspace.Text = "Workspace"; // - // radMenuItem_OpenWorkspace + // radMenuItem_WorkspacePreferences // - radMenuItem_OpenWorkspace.Name = "radMenuItem_OpenWorkspace"; - radMenuItem_OpenWorkspace.Text = "Open workspace"; + radMenuItem_WorkspacePreferences.Name = "radMenuItem_WorkspacePreferences"; + radMenuItem_WorkspacePreferences.Text = "Preferences"; // // radMenuItem2 // @@ -167,12 +170,28 @@ partial class Form1 // // radMenu1 // - radMenu1.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem1, radMenuItem2 }); + radMenu1.Items.AddRange(new Telerik.WinControls.RadItem[] { radMenuItem_Workspace, radMenuItem2 }); radMenu1.Location = new Point(0, 0); radMenu1.Name = "radMenu1"; radMenu1.Size = new Size(800, 28); radMenu1.TabIndex = 1; // + // radMenuSeparatorItem1 + // + radMenuSeparatorItem1.Name = "radMenuSeparatorItem1"; + radMenuSeparatorItem1.Text = "radMenuSeparatorItem1"; + radMenuSeparatorItem1.TextAlignment = ContentAlignment.MiddleLeft; + // + // radMenuItem_OpenNewWorkspace + // + radMenuItem_OpenNewWorkspace.Name = "radMenuItem_OpenNewWorkspace"; + radMenuItem_OpenNewWorkspace.Text = "Open new workspace"; + // + // radMenuItem_RecentWorkspaces + // + radMenuItem_RecentWorkspaces.Name = "radMenuItem_RecentWorkspaces"; + radMenuItem_RecentWorkspaces.Text = "Recent workspaces"; + // // Form1 // AutoScaleBaseSize = new Size(7, 15); @@ -208,10 +227,13 @@ partial class Form1 private Telerik.WinControls.UI.SplitPanel splitPanel2; private Telerik.WinControls.UI.RadTreeView radTreeView_Updates; private Telerik.WinControls.UI.RadMenu radMenu1; - private Telerik.WinControls.UI.RadMenuItem radMenuItem1; - private Telerik.WinControls.UI.RadMenuItem radMenuItem_OpenWorkspace; + private Telerik.WinControls.UI.RadMenuItem radMenuItem_Workspace; + private Telerik.WinControls.UI.RadMenuItem radMenuItem_WorkspacePreferences; private Telerik.WinControls.UI.RadMenuItem radMenuItem2; private TableLayoutPanel tableLayoutPanel2; private TableLayoutPanel tableLayoutPanel1; private Telerik.WinControls.UI.RadGridView radGridView_Actions; + private Telerik.WinControls.UI.RadMenuSeparatorItem radMenuSeparatorItem1; + private Telerik.WinControls.UI.RadMenuItem radMenuItem_OpenNewWorkspace; + private Telerik.WinControls.UI.RadMenuItem radMenuItem_RecentWorkspaces; } diff --git a/ModpackUpdater.Apps.Manager/Form1.cs b/ModpackUpdater.Apps.Manager/Form1.cs index 5b37f43..27231df 100644 --- a/ModpackUpdater.Apps.Manager/Form1.cs +++ b/ModpackUpdater.Apps.Manager/Form1.cs @@ -1,11 +1,41 @@ +using ModpackUpdater.Apps.Manager.Api.Model; +using ModpackUpdater.Apps.Manager.Api.Plugins.Params; +using Pilz.Plugins.Advanced; +using Pilz.Plugins.Advanced.UI.Telerik; using Telerik.WinControls.UI; namespace ModpackUpdater.Apps.Manager; -public partial class Form1 : RadForm +public partial class Form1 : RadForm, IMainApi { + public IWorkspace? Workspace { get; set; } + public Form1() { InitializeComponent(); + + PluginFeatureController.Instance.Functions.Get(FeatureTypes.Workspace).InsertItemsTo(radMenuItem_OpenNewWorkspace.Items, customClickHandler: RadMenuItem_OpenNewWorkspace_Click); + PluginFeatureController.Instance.Functions.Get(FeatureTypes.Tools).InsertItemsTo(radMenuItem_OpenNewWorkspace.Items, customClickHandler: RadMenuItem_ToolsItem_Click); + } + + private void LoadRecentWorkspaces() + { + // ... + } + + private void RadMenuItem_OpenNewWorkspace_Click(object? sender, EventArgs e) + { + // ... + } + + private void RadMenuItem_OpenRecentWorkspace_Click(object? sender, EventArgs e) + { + // ... + } + + private void RadMenuItem_ToolsItem_Click(object? sender, EventArgs e) + { + if (sender is RadMenuItem item && item.Tag is PluginFunction func) + func.Execute(new MainApiParameters(this)); } } diff --git a/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.Designer.cs b/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.Designer.cs new file mode 100644 index 0000000..0069e7c --- /dev/null +++ b/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace ModpackUpdater.Apps.Manager.LangRes { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class TitlesLangRes { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TitlesLangRes() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModpackUpdater.Apps.Manager.LangRes.TitlesLangRes", typeof(TitlesLangRes).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Setup GitLab workspace ähnelt. + /// + internal static string GitLabRepoWorkspaceEditor { + get { + return ResourceManager.GetString("GitLabRepoWorkspaceEditor", resourceCulture); + } + } + } +} diff --git a/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.resx b/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.resx new file mode 100644 index 0000000..4f8caa2 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/LangRes/TitlesLangRes.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Setup GitLab workspace + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj index b536b3a..1e5517b 100644 --- a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj +++ b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj @@ -9,6 +9,8 @@ + + @@ -23,4 +25,19 @@ + + + True + True + TitlesLangRes.resx + + + + + + ResXFileCodeGenerator + TitlesLangRes.Designer.cs + + + \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Program.cs b/ModpackUpdater.Apps.Manager/Program.cs index 762a38f..5096b32 100644 --- a/ModpackUpdater.Apps.Manager/Program.cs +++ b/ModpackUpdater.Apps.Manager/Program.cs @@ -1,14 +1,24 @@ +using Pilz.Configuration; using Pilz.Plugins.Advanced; namespace ModpackUpdater.Apps.Manager; -internal static class Program +public static class Program { + private static readonly SettingsManager settingsManager; + + public static ISettings Settings => settingsManager.Instance; + + static Program() + { + settingsManager = new(GetSettingsPath(), true); + } + /// /// The main entry point for the application. /// [STAThread] - static void Main() + internal static void Main() { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. @@ -17,4 +27,16 @@ internal static class Program PluginFeatureController.Instance.RegisterAllOwn(); Application.Run(new Form1()); } + + private static string GetSettingsPath() + { + const string AppDataDirectoryName = "MinecraftModpackUpdateManager"; + var SettingsFileName = $"Settings.json"; + + var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName); + Directory.CreateDirectory(settingsPath); + settingsPath = Path.Combine(settingsPath, SettingsFileName); + + return settingsPath; + } } \ No newline at end of file diff --git a/ModpackUpdater.Apps.Manager/Settings/WorkspaceSettings.cs b/ModpackUpdater.Apps.Manager/Settings/WorkspaceSettings.cs new file mode 100644 index 0000000..ad3dd16 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/Settings/WorkspaceSettings.cs @@ -0,0 +1,16 @@ +using ModpackUpdater.Apps.Manager.Api.Model; +using Pilz.Configuration; + +namespace ModpackUpdater.Apps.Manager.Settings; + +internal class WorkspaceSettings : IChildSettings, ISettingsIdentifier +{ + public static string Identifier => "origin.workspaces"; + + public List Workspaces { get; } = []; + + public void Reset() + { + Workspaces.Clear(); + } +} diff --git a/ModpackUpdater.Apps/AppSymbols.cs b/ModpackUpdater.Apps/AppSymbols.cs index 0084720..69db31e 100644 --- a/ModpackUpdater.Apps/AppSymbols.cs +++ b/ModpackUpdater.Apps/AppSymbols.cs @@ -18,4 +18,5 @@ public enum AppSymbols update_done, wrench, github, + gitlab, } diff --git a/ModpackUpdater.Apps/Symbols/gitlab.svg b/ModpackUpdater.Apps/Symbols/gitlab.svg new file mode 100644 index 0000000..e6ea70e --- /dev/null +++ b/ModpackUpdater.Apps/Symbols/gitlab.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/ModpackUpdater/InstallInfos.cs b/ModpackUpdater/InstallInfos.cs index 625920f..e8c362c 100644 --- a/ModpackUpdater/InstallInfos.cs +++ b/ModpackUpdater/InstallInfos.cs @@ -13,4 +13,9 @@ public class InstallInfos { return JsonConvert.DeserializeObject(content); } + + public override string ToString() + { + return JsonConvert.SerializeObject(this); + } } \ No newline at end of file diff --git a/ModpackUpdater/UpdateInfos.cs b/ModpackUpdater/UpdateInfos.cs index 6cea55f..7859120 100644 --- a/ModpackUpdater/UpdateInfos.cs +++ b/ModpackUpdater/UpdateInfos.cs @@ -10,4 +10,9 @@ public class UpdateInfos { return JsonConvert.DeserializeObject(content); } + + public override string ToString() + { + return JsonConvert.SerializeObject(this); + } } \ No newline at end of file