diff --git a/ModpackUpdater.Apps.Manager/Form1.Designer.cs b/ModpackUpdater.Apps.Manager/Form1.Designer.cs index 7bd6e4f..13f248b 100644 --- a/ModpackUpdater.Apps.Manager/Form1.Designer.cs +++ b/ModpackUpdater.Apps.Manager/Form1.Designer.cs @@ -119,6 +119,7 @@ partial class Form1 radTreeView_Updates.Name = "radTreeView_Updates"; radTreeView_Updates.Size = new Size(240, 416); radTreeView_Updates.TabIndex = 0; + radTreeView_Updates.SelectedNodeChanged += RadTreeView_Updates_SelectedNodeChanged; // // splitPanel2 // diff --git a/ModpackUpdater.Apps.Manager/Form1.cs b/ModpackUpdater.Apps.Manager/Form1.cs index 79fca83..bd18da6 100644 --- a/ModpackUpdater.Apps.Manager/Form1.cs +++ b/ModpackUpdater.Apps.Manager/Form1.cs @@ -14,7 +14,7 @@ namespace ModpackUpdater.Apps.Manager; public partial class Form1 : RadForm, IMainApi { private IWorkspace? workspace; - + public IWorkspace? Workspace => workspace; private record RecentFileItemTag(WorkspaceConfig Config, WorkspaceFeature Feature); @@ -71,7 +71,7 @@ public partial class Form1 : RadForm, IMainApi private void AddToRecentFiles(IWorkspace workspace) { var settings = Program.Settings.Get(); - + settings.Workspaces.Remove(workspace.Config); settings.Workspaces.Insert(0, workspace.Config); @@ -130,9 +130,143 @@ public partial class Form1 : RadForm, IMainApi radWaitingBar_Updates.StopWaiting(); } - private void LoadActionSet() + private void LoadActionSet(IActionSetInfos infos) { - // ... + radGridView_Actions.BeginUpdate(); + radGridView_Actions.Rows.Clear(); + radGridView_Actions.Columns.Clear(); + + // Add columns + radGridView_Actions.Columns.AddRange([ + new GridViewTextBoxColumn + { + Name = "name", + HeaderText = ActionsListLangRes.Col_Name, + Width = 150, + }, + new GridViewTextBoxColumn + { + Name = "inherit", + HeaderText = ActionsListLangRes.Col_InheritFrom, + Width = 150, + IsVisible = infos is UpdateInfo, + }, + new GridViewComboBoxColumn + { + Name = "utype", + HeaderText = ActionsListLangRes.Col_UpdateType, + Width = 150, + IsVisible = infos is UpdateInfo, + }, + new GridViewCheckBoxColumn + { + Name = "iszip", + HeaderText = ActionsListLangRes.Col_IsZip, + Width = 50, + }, + new GridViewTextBoxColumn + { + Name = "zippath", + HeaderText = ActionsListLangRes.Col_ZipPath, + Width = 250, + }, + new GridViewCheckBoxColumn + { + Name = "isdir", + HeaderText = ActionsListLangRes.Col_IsDir, + Width = 50, + IsVisible = infos is UpdateInfo, + }, + new GridViewTextBoxColumn + { + Name = "srcpath", + HeaderText = ActionsListLangRes.Col_SrcPath, + Width = 250, + IsVisible = infos is UpdateInfo, + }, + new GridViewTextBoxColumn + { + Name = "destpath", + HeaderText = ActionsListLangRes.Col_DestPath, + Width = 250, + }, + new GridViewTextBoxColumn + { + Name = "srcurl", + HeaderText = ActionsListLangRes.Col_SrcUrl, + Width = 250, + }, + new GridViewComboBoxColumn + { + Name = "srctype", + HeaderText = ActionsListLangRes.Col_SrcType, + Width = 150, + }, + new GridViewTextBoxColumn + { + Name = "srcowner", + HeaderText = ActionsListLangRes.Col_SrcOwner, + Width = 150, + }, + new GridViewTextBoxColumn + { + Name = "srcname", + HeaderText = ActionsListLangRes.Col_SrcName, + Width = 150, + }, + new GridViewTextBoxColumn + { + Name = "srcregex", + HeaderText = ActionsListLangRes.Col_SrcRegEx, + Width = 200, + }, + new GridViewTextBoxColumn + { + Name = "srctag", + HeaderText = ActionsListLangRes.Col_SrcTag, + Width = 150, + }, + new GridViewComboBoxColumn + { + Name = "side", + HeaderText = ActionsListLangRes.Col_Side, + Width = 150, + }, + new GridViewCheckBoxColumn + { + Name = "isextra", + HeaderText = ActionsListLangRes.Col_IsExtra, + Width = 50, + }, + ]); + + // Add rows + foreach (var action in infos.Actions) + { + var row = radGridView_Actions.Rows.AddNew(); + row.Tag = action; + row.Cells["name"].Value = action.Name; + row.Cells["iszip"].Value = action.IsZip; + row.Cells["zippath"].Value = action.ZipPath; + row.Cells["destpath"].Value = action.DestPath; + row.Cells["srcurl"].Value = action.SourceUrl; + row.Cells["srcowner"].Value = action.SourceOwner; + row.Cells["srcname"].Value = action.SourceName; + row.Cells["srcregex"].Value = action.SourceRegex; + row.Cells["srctag"].Value = action.SourceTag; + row.Cells["side"].Value = action.Side; + row.Cells["isextra"].Value = action.IsExtra; + + if (action is UpdateAction uaction) + { + row.Cells["inherit"].Value = uaction.InheritFrom; // TODO: Find inherit action and put it in here! + row.Cells["utype"].Value = uaction.Type; + row.Cells["srcpath"].Value = uaction.SrcPath; + row.Cells["isdir"].Value = uaction.IsDirectory; + } + } + + radGridView_Actions.EndUpdate(); } private void Form1_Load(object sender, EventArgs e) @@ -157,4 +291,10 @@ public partial class Form1 : RadForm, IMainApi if (sender is RadMenuItem item && item.Tag is PluginFunction func) func.Execute(new MainApiParameters(this)); } + + private void RadTreeView_Updates_SelectedNodeChanged(object sender, RadTreeViewEventArgs e) + { + if (e.Node?.Tag is IActionSetInfos infos) + LoadActionSet(infos); + } } diff --git a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs new file mode 100644 index 0000000..ec6473c --- /dev/null +++ b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.Designer.cs @@ -0,0 +1,207 @@ +//------------------------------------------------------------------------------ +// +// 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 ActionsListLangRes { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal ActionsListLangRes() { + } + + /// + /// 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.ActionsListLangRes", typeof(ActionsListLangRes).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 Destination path ähnelt. + /// + internal static string Col_DestPath { + get { + return ResourceManager.GetString("Col_DestPath", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Inherit from ähnelt. + /// + internal static string Col_InheritFrom { + get { + return ResourceManager.GetString("Col_InheritFrom", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Is directory ähnelt. + /// + internal static string Col_IsDir { + get { + return ResourceManager.GetString("Col_IsDir", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Is Extra ähnelt. + /// + internal static string Col_IsExtra { + get { + return ResourceManager.GetString("Col_IsExtra", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Is ZIP ähnelt. + /// + internal static string Col_IsZip { + get { + return ResourceManager.GetString("Col_IsZip", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Name ähnelt. + /// + internal static string Col_Name { + get { + return ResourceManager.GetString("Col_Name", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Side ähnelt. + /// + internal static string Col_Side { + get { + return ResourceManager.GetString("Col_Side", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source name ähnelt. + /// + internal static string Col_SrcName { + get { + return ResourceManager.GetString("Col_SrcName", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source owner ähnelt. + /// + internal static string Col_SrcOwner { + get { + return ResourceManager.GetString("Col_SrcOwner", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source path ähnelt. + /// + internal static string Col_SrcPath { + get { + return ResourceManager.GetString("Col_SrcPath", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source RegEx ähnelt. + /// + internal static string Col_SrcRegEx { + get { + return ResourceManager.GetString("Col_SrcRegEx", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source tag ähnelt. + /// + internal static string Col_SrcTag { + get { + return ResourceManager.GetString("Col_SrcTag", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source type ähnelt. + /// + internal static string Col_SrcType { + get { + return ResourceManager.GetString("Col_SrcType", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Source URL ähnelt. + /// + internal static string Col_SrcUrl { + get { + return ResourceManager.GetString("Col_SrcUrl", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Update type ähnelt. + /// + internal static string Col_UpdateType { + get { + return ResourceManager.GetString("Col_UpdateType", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die ZIP archive path ähnelt. + /// + internal static string Col_ZipPath { + get { + return ResourceManager.GetString("Col_ZipPath", resourceCulture); + } + } + } +} diff --git a/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx new file mode 100644 index 0000000..4b24ee5 --- /dev/null +++ b/ModpackUpdater.Apps.Manager/LangRes/ActionsListLangRes.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Destination path + + + Inherit from + + + Is directory + + + Is Extra + + + Is ZIP + + + Name + + + Side + + + Source name + + + Source owner + + + Source path + + + Source RegEx + + + Source tag + + + Source type + + + Source URL + + + Update type + + + ZIP archive path + + \ 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 c8d6ef0..e7ec4c7 100644 --- a/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj +++ b/ModpackUpdater.Apps.Manager/ModpackUpdater.Apps.Manager.csproj @@ -29,6 +29,11 @@ + + True + True + ActionsListLangRes.resx + True True @@ -42,6 +47,10 @@ + + ResXFileCodeGenerator + ActionsListLangRes.Designer.cs + ResXFileCodeGenerator GeneralLangRes.Designer.cs diff --git a/ModpackUpdater/IActionSetInfos.cs b/ModpackUpdater/IActionSetInfos.cs new file mode 100644 index 0000000..3e9c84a --- /dev/null +++ b/ModpackUpdater/IActionSetInfos.cs @@ -0,0 +1,8 @@ +namespace ModpackUpdater; + +public interface IActionSetInfos +{ + Version Version { get; } + + IEnumerable Actions { get; } +} diff --git a/ModpackUpdater/InstallAction.cs b/ModpackUpdater/InstallAction.cs index 0282ad8..9a31df6 100644 --- a/ModpackUpdater/InstallAction.cs +++ b/ModpackUpdater/InstallAction.cs @@ -1,33 +1,44 @@ using Newtonsoft.Json; +using System.ComponentModel; namespace ModpackUpdater; public class InstallAction { + [DefaultValue(null)] public string Name { get; set; } - public string InheritFrom { get; set; } - + [DefaultValue(false)] public bool IsZip { get; set; } + [DefaultValue(null)] public string ZipPath { get; set; } + [DefaultValue(null)] public string DestPath { get; set; } + [DefaultValue(null)] public string SourceUrl { get; set; } + [DefaultValue(SourceType.DirectLink)] public SourceType SourceType { get; set; } + [DefaultValue(null)] public string SourceOwner { get; set; } + [DefaultValue(null)] public string SourceName { get; set; } + [DefaultValue(null)] public string SourceRegex { get; set; } + [DefaultValue(null)] public string SourceTag { get; set; } + [DefaultValue(Side.Both)] public Side Side { get; set; } = Side.Both; + [DefaultValue(false)] public bool IsExtra { get; set; } [JsonProperty, Obsolete] diff --git a/ModpackUpdater/InstallInfos.cs b/ModpackUpdater/InstallInfos.cs index e8c362c..ba9b44a 100644 --- a/ModpackUpdater/InstallInfos.cs +++ b/ModpackUpdater/InstallInfos.cs @@ -3,12 +3,15 @@ using Newtonsoft.Json.Converters; namespace ModpackUpdater; -public class InstallInfos +public class InstallInfos : IActionSetInfos { [JsonConverter(typeof(VersionConverter))] public Version Version { get; set; } + public List Actions { get; } = []; + IEnumerable IActionSetInfos.Actions => Actions; + public static InstallInfos Parse(string content) { return JsonConvert.DeserializeObject(content); diff --git a/ModpackUpdater/UpdateAction.cs b/ModpackUpdater/UpdateAction.cs index ab3c958..3a05fbf 100644 --- a/ModpackUpdater/UpdateAction.cs +++ b/ModpackUpdater/UpdateAction.cs @@ -1,12 +1,21 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using System.ComponentModel; namespace ModpackUpdater; public class UpdateAction : InstallAction { [JsonConverter(typeof(StringEnumConverter))] + [DefaultValue(UpdateActionType.Update)] public UpdateActionType Type { get; set; } + + [DefaultValue(null)] public string SrcPath { get; set; } + + [DefaultValue(false)] public bool IsDirectory { get; set; } + + [DefaultValue(null)] + public string InheritFrom { get; set; } } \ No newline at end of file diff --git a/ModpackUpdater/UpdateInfo.cs b/ModpackUpdater/UpdateInfo.cs index 8c44f62..1b51a67 100644 --- a/ModpackUpdater/UpdateInfo.cs +++ b/ModpackUpdater/UpdateInfo.cs @@ -3,9 +3,12 @@ using Newtonsoft.Json.Converters; namespace ModpackUpdater; -public class UpdateInfo +public class UpdateInfo : IActionSetInfos { [JsonConverter(typeof(VersionConverter))] public Version Version { get; set; } - public List Actions { get; private set; } = []; + + public List Actions { get; } = []; + + IEnumerable IActionSetInfos.Actions => Actions.Cast(); } \ No newline at end of file