添加了标识更新
但是只有界面没有功能
This commit is contained in:
@@ -1,54 +1,48 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using BITFactory;
|
||||
using BITKit;
|
||||
|
||||
namespace BITFactory;
|
||||
public partial class IDIS_UpdateService : Node
|
||||
{
|
||||
[ExportCategory("Services")]
|
||||
[ExportCategory("Service")]
|
||||
[Export] private IDIS_Service service;
|
||||
|
||||
[Export] private IDIS_TemplateService templateService;
|
||||
|
||||
[ExportCategory("UI 绑定")]
|
||||
[Export] private Button submitButton;
|
||||
[Export] private NodeBuilder indexBuilder;
|
||||
[Export] private NodeBuilder templateBuilder;
|
||||
[Export] private LineEdit handleEdit;
|
||||
[Export] private LineEdit temperatureEdit;
|
||||
[Export] private LineEdit humidityEdit;
|
||||
[Export] private RichTextLabel hintsLabel;
|
||||
|
||||
private ButtonGroup _buttonGroup;
|
||||
public override void _Ready()
|
||||
{
|
||||
submitButton.Pressed += Submit;
|
||||
_buttonGroup = new ButtonGroup();
|
||||
Refresh();
|
||||
}
|
||||
private void Submit()
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
switch (handleEdit.Text, temperatureEdit.Text, humidityEdit.Text)
|
||||
templateBuilder.Clear();
|
||||
indexBuilder.Clear();
|
||||
foreach (var x in templateService.templates)
|
||||
{
|
||||
case ("", _, _):
|
||||
hintsLabel.Text = "请输入标识码";
|
||||
return;
|
||||
case (_, "", _):
|
||||
hintsLabel.Text = "请输入温度";
|
||||
return;
|
||||
case (_, _, ""):
|
||||
hintsLabel.Text = "请输入湿度";
|
||||
return;
|
||||
var container = indexBuilder.Build<UXContainer>();
|
||||
container.button.Text = x.TemplateName;
|
||||
container.button.ButtonPressed = true;
|
||||
container.button.ButtonGroup = _buttonGroup;
|
||||
container.button.Pressed +=()=> Entry(x);
|
||||
}
|
||||
try
|
||||
}
|
||||
private void Entry(IDIS_Template template)
|
||||
{
|
||||
templateBuilder.Clear();
|
||||
foreach (var x in template.Formats)
|
||||
{
|
||||
if (service.Update(handleEdit.Text, "温度", humidityEdit.Text) is false)
|
||||
{
|
||||
hintsLabel.Text = "温度更新失败: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return;
|
||||
}
|
||||
if (service.Update(handleEdit.Text, "湿度", temperatureEdit.Text) is false)
|
||||
{
|
||||
hintsLabel.Text = "湿度更新失败: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
return;
|
||||
}
|
||||
hintsLabel.Text = "更新成功: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
hintsLabel.Text = e.Message;
|
||||
throw;
|
||||
var container = templateBuilder.Build<UXContainer>();
|
||||
container.Text = x.format;
|
||||
container.lineEdit.PlaceholderText = x.hint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user