Before update to NET 7
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITKit;
|
||||
|
||||
namespace BITFactory;
|
||||
@@ -7,18 +9,26 @@ public partial class IDIS_UpdateService : Node
|
||||
{
|
||||
[ExportCategory("Service")]
|
||||
[Export] private IDIS_Service service;
|
||||
|
||||
[Export] private IDIS_TemplateService templateService;
|
||||
|
||||
[ExportCategory("UI 绑定")]
|
||||
[Export] private NodeBuilder indexBuilder;
|
||||
[Export] private NodeBuilder templateBuilder;
|
||||
[Export] private LineEdit handleEdit;
|
||||
[Export] private Button submitButton;
|
||||
[Export] private RichTextLabel hintsLabel;
|
||||
|
||||
private ButtonGroup _buttonGroup;
|
||||
|
||||
private readonly Dictionary<string,LineEdit> dataEdits = new();
|
||||
public override void _Ready()
|
||||
{
|
||||
_buttonGroup = new ButtonGroup();
|
||||
|
||||
submitButton.Pressed += Submit;
|
||||
|
||||
submitButton.Disabled = true;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -38,11 +48,36 @@ public partial class IDIS_UpdateService : Node
|
||||
private void Entry(IDIS_Template template)
|
||||
{
|
||||
templateBuilder.Clear();
|
||||
dataEdits.Clear();
|
||||
foreach (var x in template.Formats)
|
||||
{
|
||||
var container = templateBuilder.Build<UXContainer>();
|
||||
container.Text = x.format;
|
||||
container.lineEdit.PlaceholderText = x.hint;
|
||||
|
||||
dataEdits.TryAdd(x.format, container.lineEdit);
|
||||
}
|
||||
|
||||
submitButton.Disabled = false;
|
||||
}
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
if (string.IsNullOrEmpty(handleEdit.Text))
|
||||
{
|
||||
hintsLabel.Text="请填写标识码";
|
||||
return;
|
||||
}
|
||||
var handle = handleEdit.Text;
|
||||
var values = new Dictionary<string, string>(
|
||||
dataEdits
|
||||
.Where(x=>string.IsNullOrEmpty(x.Value.Text) is false)
|
||||
.Select(x => new KeyValuePair<string, string>(x.Key, x.Value.Text))
|
||||
);
|
||||
foreach (var x in values)
|
||||
{
|
||||
service.Update(handle, x.Key, x.Value);
|
||||
}
|
||||
hintsLabel.Text=$"更新成功,已更新{values.Count}个值"+DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user