allow edit
This commit is contained in:
11
ModpackUpdater.Apps.Manager/Extensions.cs
Normal file
11
ModpackUpdater.Apps.Manager/Extensions.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace ModpackUpdater.Apps.Manager;
|
||||
|
||||
internal static class Extensions
|
||||
{
|
||||
public static string? Nullify(this string? @this)
|
||||
{
|
||||
if (string.IsNullOrEmpty(@this))
|
||||
return null;
|
||||
return @this;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ namespace ModpackUpdater.Apps.Manager.Features.Workspaces.GitLabRepo;
|
||||
|
||||
internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspace
|
||||
{
|
||||
private string? rawInstallInfos = null;
|
||||
private string? rawUpdateInfos = null;
|
||||
|
||||
public WorkspaceConfig Config => ConfigX;
|
||||
|
||||
public GitLabRepoWorkspaceConfig ConfigX { get; } = config;
|
||||
@@ -19,19 +22,38 @@ internal class GitLabRepoWorkspace(GitLabRepoWorkspaceConfig config) : IWorkspac
|
||||
|
||||
public async Task<bool> Load()
|
||||
{
|
||||
InstallInfos = InstallInfos.Parse(await GetContent(ConfigX.FileLocationInstallJson));
|
||||
UpdateInfos = UpdateInfos.Parse(await GetContent(ConfigX.FileLocationUpdateJson));
|
||||
rawInstallInfos = await GetContent(ConfigX.FileLocationInstallJson);
|
||||
InstallInfos = InstallInfos.Parse(rawInstallInfos);
|
||||
|
||||
rawUpdateInfos = await GetContent(ConfigX.FileLocationUpdateJson);
|
||||
UpdateInfos = UpdateInfos.Parse(rawUpdateInfos);
|
||||
|
||||
ConfigX.RepoName = (await Gitlab.Projects.GetByIdAsync((int)ConfigX.RepoId, new())).Name;
|
||||
|
||||
return InstallInfos != null && UpdateInfos != null;
|
||||
}
|
||||
|
||||
public async Task<bool> Save()
|
||||
{
|
||||
if (InstallInfos != null)
|
||||
await SaveContent(ConfigX.FileLocationInstallJson, InstallInfos.ToString());
|
||||
{
|
||||
var newInstallInfos = InstallInfos.ToString();
|
||||
if (newInstallInfos != rawInstallInfos)
|
||||
{
|
||||
await SaveContent(ConfigX.FileLocationInstallJson, newInstallInfos);
|
||||
rawInstallInfos = newInstallInfos;
|
||||
}
|
||||
}
|
||||
|
||||
if (UpdateInfos != null)
|
||||
await SaveContent(ConfigX.FileLocationUpdateJson, UpdateInfos.ToString());
|
||||
{
|
||||
var newUpdateInfos = UpdateInfos.ToString();
|
||||
if (newUpdateInfos != rawUpdateInfos)
|
||||
{
|
||||
await SaveContent(ConfigX.FileLocationUpdateJson, newUpdateInfos);
|
||||
rawUpdateInfos = newUpdateInfos;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
1
ModpackUpdater.Apps.Manager/Form1.Designer.cs
generated
1
ModpackUpdater.Apps.Manager/Form1.Designer.cs
generated
@@ -169,6 +169,7 @@ partial class Form1
|
||||
radGridView_Actions.Size = new Size(590, 416);
|
||||
radGridView_Actions.TabIndex = 0;
|
||||
radGridView_Actions.CellFormatting += RadGridView_Actions_CellFormatting;
|
||||
radGridView_Actions.CellValueChanged += RadGridView_Actions_CellValueChanged;
|
||||
//
|
||||
// radMenuItem_Workspace
|
||||
//
|
||||
|
||||
@@ -6,6 +6,7 @@ using ModpackUpdater.Apps.Manager.Settings;
|
||||
using Pilz.Plugins.Advanced;
|
||||
using Pilz.Plugins.Advanced.UI.Telerik;
|
||||
using Pilz.UI.Symbols;
|
||||
using Pilz.UI.Telerik.Extensions;
|
||||
using Telerik.WinControls;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
@@ -138,11 +139,20 @@ public partial class Form1 : RadForm, IMainApi
|
||||
|
||||
// Add columns
|
||||
radGridView_Actions.Columns.AddRange([
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
Name = "id",
|
||||
HeaderText = ActionsListLangRes.Col_Id,
|
||||
Width = 150,
|
||||
IsVisible = infos is not UpdateInfo,
|
||||
IsPinned = true,
|
||||
},
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
Name = "name",
|
||||
HeaderText = ActionsListLangRes.Col_Name,
|
||||
Width = 150,
|
||||
IsVisible = infos is not UpdateInfo,
|
||||
},
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
@@ -150,6 +160,7 @@ public partial class Form1 : RadForm, IMainApi
|
||||
HeaderText = ActionsListLangRes.Col_InheritFrom,
|
||||
Width = 150,
|
||||
IsVisible = infos is UpdateInfo,
|
||||
IsPinned = true,
|
||||
},
|
||||
new GridViewComboBoxColumn
|
||||
{
|
||||
@@ -159,6 +170,19 @@ public partial class Form1 : RadForm, IMainApi
|
||||
DataSource = Enum.GetValues<UpdateActionType>(),
|
||||
IsVisible = infos is UpdateInfo,
|
||||
},
|
||||
new GridViewComboBoxColumn
|
||||
{
|
||||
Name = "side",
|
||||
HeaderText = ActionsListLangRes.Col_Side,
|
||||
Width = 150,
|
||||
DataSource = Enum.GetValues<Side>(),
|
||||
},
|
||||
new GridViewCheckBoxColumn
|
||||
{
|
||||
Name = "isextra",
|
||||
HeaderText = ActionsListLangRes.Col_IsExtra,
|
||||
Width = 50,
|
||||
},
|
||||
new GridViewCheckBoxColumn
|
||||
{
|
||||
Name = "iszip",
|
||||
@@ -191,18 +215,12 @@ public partial class Form1 : RadForm, IMainApi
|
||||
HeaderText = ActionsListLangRes.Col_DestPath,
|
||||
Width = 250,
|
||||
},
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
Name = "srcurl",
|
||||
HeaderText = ActionsListLangRes.Col_SrcUrl,
|
||||
Width = 350,
|
||||
},
|
||||
new GridViewComboBoxColumn
|
||||
{
|
||||
Name = "srctype",
|
||||
HeaderText = ActionsListLangRes.Col_SrcType,
|
||||
DataSource = Enum.GetValues<SourceType>(),
|
||||
Width = 150,
|
||||
DataSource = Enum.GetValues<SourceType>(),
|
||||
},
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
@@ -228,18 +246,17 @@ public partial class Form1 : RadForm, IMainApi
|
||||
HeaderText = ActionsListLangRes.Col_SrcTag,
|
||||
Width = 150,
|
||||
},
|
||||
new GridViewComboBoxColumn
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
Name = "side",
|
||||
HeaderText = ActionsListLangRes.Col_Side,
|
||||
DataSource = Enum.GetValues<Side>(),
|
||||
Width = 150,
|
||||
Name = "srcurl",
|
||||
HeaderText = ActionsListLangRes.Col_SrcUrl,
|
||||
Width = 350,
|
||||
},
|
||||
new GridViewCheckBoxColumn
|
||||
new GridViewTextBoxColumn
|
||||
{
|
||||
Name = "isextra",
|
||||
HeaderText = ActionsListLangRes.Col_IsExtra,
|
||||
Width = 50,
|
||||
Name = "website",
|
||||
HeaderText = ActionsListLangRes.Col_Website,
|
||||
Width = 350,
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -248,6 +265,7 @@ public partial class Form1 : RadForm, IMainApi
|
||||
{
|
||||
var row = radGridView_Actions.Rows.AddNew();
|
||||
row.Tag = action;
|
||||
row.Cells["id"].Value = action.Id;
|
||||
row.Cells["name"].Value = action.Name;
|
||||
row.Cells["iszip"].Value = action.IsZip;
|
||||
row.Cells["zippath"].Value = action.ZipPath;
|
||||
@@ -327,4 +345,84 @@ public partial class Form1 : RadForm, IMainApi
|
||||
// cellElement.ResetValue(LightVisualElement.ImageAlignmentProperty, ValueResetFlags.Local);
|
||||
//}
|
||||
}
|
||||
|
||||
private void RadGridView_Actions_CellValueChanged(object sender, GridViewCellEventArgs e)
|
||||
{
|
||||
if (e.Row?.Tag is not InstallAction action)
|
||||
return;
|
||||
|
||||
var uaction = action as UpdateAction;
|
||||
var newValue = e.Row.Cells[e.Column.Name].Value;
|
||||
var colName = e.Column.Name;
|
||||
|
||||
if (newValue is string valueStr)
|
||||
{
|
||||
var valueNullStr = valueStr.Nullify();
|
||||
|
||||
switch (colName)
|
||||
{
|
||||
case "id":
|
||||
action.Id = valueNullStr;
|
||||
break;
|
||||
case "name":
|
||||
action.Name = valueNullStr;
|
||||
break;
|
||||
case "zippath":
|
||||
action.ZipPath = valueNullStr;
|
||||
break;
|
||||
case "destpath":
|
||||
action.DestPath = valueNullStr;
|
||||
break;
|
||||
case "srcurl":
|
||||
action.SourceUrl = valueNullStr;
|
||||
break;
|
||||
case "srctype":
|
||||
action.SourceType = Enum.Parse<SourceType>(valueStr);
|
||||
break;
|
||||
case "srcowner":
|
||||
action.SourceOwner = valueNullStr;
|
||||
break;
|
||||
case "srcname":
|
||||
action.SourceName = valueNullStr;
|
||||
break;
|
||||
case "srcregex":
|
||||
action.SourceTag = valueNullStr;
|
||||
break;
|
||||
case "srctag":
|
||||
action.SourceTag = valueNullStr;
|
||||
break;
|
||||
case "side":
|
||||
action.Side = Enum.Parse<Side>(valueStr);
|
||||
break;
|
||||
case "inherit":
|
||||
if (uaction is not null)
|
||||
uaction.InheritFrom = valueNullStr;
|
||||
break;
|
||||
case "utype":
|
||||
if (uaction is not null)
|
||||
uaction.Type = Enum.Parse<UpdateActionType>(valueStr);
|
||||
break;
|
||||
case "srcpath":
|
||||
if (uaction is not null)
|
||||
uaction.SrcPath = valueNullStr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (newValue is bool valueBool)
|
||||
{
|
||||
switch (colName)
|
||||
{
|
||||
case "iszip":
|
||||
action.IsZip = valueBool;
|
||||
break;
|
||||
case "isextra":
|
||||
action.IsExtra = valueBool;
|
||||
break;
|
||||
case "isdir":
|
||||
if (uaction is not null)
|
||||
uaction.IsDirectory = valueBool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Id ähnelt.
|
||||
/// </summary>
|
||||
internal static string Col_Id {
|
||||
get {
|
||||
return ResourceManager.GetString("Col_Id", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Inherit from ähnelt.
|
||||
/// </summary>
|
||||
@@ -195,6 +204,15 @@ namespace ModpackUpdater.Apps.Manager.LangRes {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Website ähnelt.
|
||||
/// </summary>
|
||||
internal static string Col_Website {
|
||||
get {
|
||||
return ResourceManager.GetString("Col_Website", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die ZIP archive path ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -120,6 +120,9 @@
|
||||
<data name="Col_DestPath" xml:space="preserve">
|
||||
<value>Destination path</value>
|
||||
</data>
|
||||
<data name="Col_Id" xml:space="preserve">
|
||||
<value>Id</value>
|
||||
</data>
|
||||
<data name="Col_InheritFrom" xml:space="preserve">
|
||||
<value>Inherit from</value>
|
||||
</data>
|
||||
@@ -162,6 +165,9 @@
|
||||
<data name="Col_UpdateType" xml:space="preserve">
|
||||
<value>Update type</value>
|
||||
</data>
|
||||
<data name="Col_Website" xml:space="preserve">
|
||||
<value>Website</value>
|
||||
</data>
|
||||
<data name="Col_ZipPath" xml:space="preserve">
|
||||
<value>ZIP archive path</value>
|
||||
</data>
|
||||
|
||||
@@ -5,9 +5,15 @@ namespace ModpackUpdater;
|
||||
|
||||
public class InstallAction
|
||||
{
|
||||
[DefaultValue(null)]
|
||||
public string Id { get; set; }
|
||||
|
||||
[DefaultValue(null)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DefaultValue(null)]
|
||||
public string Website { get; set; }
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool IsZip { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user