Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightAggregationTerminal
This commit is contained in:
commit
ee00cfd25f
6 files changed
+209
-36
No files matched your search
+60
-10
@@ -1,11 +1,15 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using SunlightAggregationTerminal.Class;
|
||||
using SunlightAggregationTerminal.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
using static SunlightAggregationTerminal.QueryPage;
|
||||
|
||||
namespace SunlightAggregationTerminal;
|
||||
|
||||
public partial class QueryPage : ContentPage
|
||||
{
|
||||
// 定义一个静态的回调动作
|
||||
public static Action<string>? OnScanQuery;
|
||||
public static ObservableCollection<DyelotItem> DyelotItems { get; set; } = new();
|
||||
|
||||
public QueryPage()
|
||||
{
|
||||
@@ -22,17 +26,63 @@ public partial class QueryPage : ContentPage
|
||||
await Navigation.PushAsync(new ScanPage(0));
|
||||
}
|
||||
|
||||
// 处理“回车/完成”按钮点击
|
||||
/* private void OnEntryCompleted()
|
||||
private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
string inputText = ResultEntry.Text;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(inputText))
|
||||
}
|
||||
|
||||
//信息回复
|
||||
public static void Query_data(string dat)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 在这里处理用户手动输入的内容
|
||||
// 例如:验证格式、跳转页面、或者搜索商品
|
||||
//DisplayAlert("提示", $"你输入了: {inputText}", "确定");
|
||||
var data = JsonSerializer.Deserialize<List<DyelotItem>>(dat);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
foreach (var item in data)
|
||||
{
|
||||
DyelotItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
public async void Query_Command(string dat)
|
||||
{
|
||||
LoadingIndicator.IsVisible = true;
|
||||
DyelotItems.Clear();
|
||||
|
||||
TcpServer.TcpTransmit(dat);
|
||||
|
||||
// 创建一个 15 秒的延时任务
|
||||
Task delayTask = Task.Delay(15000);
|
||||
// 创建一个监测任务,不断检查变量
|
||||
Task monitorTask = Task.Run(async () =>
|
||||
{
|
||||
while (DyelotItems.Count==0)
|
||||
{
|
||||
// 每隔 100 毫秒检查一次,避免 CPU 占用过高
|
||||
await Task.Delay(100);
|
||||
}
|
||||
});
|
||||
// 使用 Task.WhenAny 等待任意一个任务完成
|
||||
await Task.WhenAny(delayTask, monitorTask);
|
||||
|
||||
LoadingIndicator.IsVisible = false;
|
||||
}
|
||||
// 处理“回车/完成”按钮点击
|
||||
/* private void OnEntryCompleted()
|
||||
{
|
||||
string inputText = ResultEntry.Text;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(inputText))
|
||||
{
|
||||
// 在这里处理用户手动输入的内容
|
||||
// 例如:验证格式、跳转页面、或者搜索商品
|
||||
//DisplayAlert("提示", $"你输入了: {inputText}", "确定");
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user