温湿度传感器更新
现在可以手动更新温湿度了
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BITKit;
|
||||
@@ -14,10 +15,25 @@ public partial class IDIS_SearchService : Node
|
||||
[Export] private LineEdit searchEdit;
|
||||
[Export] private Control searchCandidateContainer;
|
||||
[Export] private StringResource searchButtonVariation;
|
||||
[Export] private Control searchEditPadding;
|
||||
|
||||
[ExportCategory("Query 绑定")]
|
||||
[Export] private Label handleLabel;
|
||||
[Export] private Label nameLabel;
|
||||
[Export] private Label createTimeLabel;
|
||||
[Export] private Label updateTimeLabel;
|
||||
[Export] private Control valueContainer;
|
||||
[Export] private Control referenceContainer;
|
||||
|
||||
[ExportCategory("Template")]
|
||||
[Export] private PackedScene valueTemplate;
|
||||
[Export] private PackedScene referenceTemplate;
|
||||
[Export] private PackedScene categoryTemplate;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
MathNode.RemoveAllChild(searchCandidateContainer);
|
||||
MathNode.RemoveAllChild(valueContainer);
|
||||
|
||||
searchEdit.TextChanged += Search;
|
||||
//searchEdit.FocusExited += Clear;
|
||||
@@ -25,7 +41,7 @@ public partial class IDIS_SearchService : Node
|
||||
private void Search(string word)
|
||||
{
|
||||
MathNode.RemoveAllChild(searchCandidateContainer);
|
||||
if (service.TrySearch(word, out var queries) is false) return;
|
||||
if (service.Query(word, out IDIS_Query[] queries) is false) return;
|
||||
if(queries.Length is 1 && queries.First().Handle == word)return;
|
||||
foreach (var query in queries)
|
||||
{
|
||||
@@ -45,6 +61,7 @@ public partial class IDIS_SearchService : Node
|
||||
{
|
||||
searchEdit.Text = query.Handle;
|
||||
Search(query.Handle);
|
||||
QueryIDIS(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +70,51 @@ public partial class IDIS_SearchService : Node
|
||||
await Task.Delay(100);
|
||||
MathNode.RemoveAllChild(searchCandidateContainer);
|
||||
}
|
||||
private void QueryIDIS(IDIS_Query query)
|
||||
{
|
||||
searchEditPadding.Hide();
|
||||
|
||||
handleLabel.Text = query.Handle;
|
||||
|
||||
createTimeLabel.Text = query.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
createTimeLabel.Text = query.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
MathNode.RemoveAllChild(valueContainer);
|
||||
MathNode.RemoveAllChild(referenceContainer);
|
||||
|
||||
foreach (var categoryGroup in query.Datas.GroupBy(x=>x.Category))
|
||||
{
|
||||
var categoryContainer = categoryTemplate.Instantiate<UXContainer>();
|
||||
categoryContainer.Text = categoryGroup.First().Category;
|
||||
foreach (var x in categoryGroup)
|
||||
{
|
||||
var container = valueTemplate.Instantiate<UXContainer>();
|
||||
|
||||
container.labels[0].Text = x.Format;
|
||||
container.labels[1].Text = x.Value;
|
||||
container.labels[2].Text = x.UpdateTime.ToString(CultureInfo.InvariantCulture);
|
||||
container.labels[3].Text = x.CreateTime.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
categoryContainer.contextContainer.AddChild(container);
|
||||
}
|
||||
valueContainer.AddChild(categoryContainer);
|
||||
}
|
||||
|
||||
foreach (var x in query.References)
|
||||
{
|
||||
var container = referenceTemplate.Instantiate<UXContainer>();
|
||||
|
||||
container.Text = x.RelatedHandle;
|
||||
|
||||
container.button.Pressed += () =>
|
||||
{
|
||||
service.Query(x.RelatedHandle,out IDIS_Query _query);
|
||||
QueryIDIS(_query);
|
||||
};
|
||||
|
||||
referenceContainer.AddChild(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user