diff --git a/Converters/StringToImageConverter.cs b/Converters/StringToImageConverter.cs new file mode 100644 index 0000000..b595589 --- /dev/null +++ b/Converters/StringToImageConverter.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Globalization; +using Microsoft.Maui.Controls; + +namespace SunlightAggregationTerminal.Converters +{ + public class StringToImageConverter: IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value !=null) + { + // 根据字符串内容返回对应的图片路径 + // 确保你的 Resources/Raw 或 Resources/Images 目录下有这些图片 + if (value.ToString() == "252") return ImageSource.FromFile("sc252rb.png"); + else if (value.ToString() == "252-2T") return ImageSource.FromFile("sc2522t.png"); + else if (value.ToString() == "252RB") return ImageSource.FromFile("sc252rb.png"); + else if (value.ToString() == "252RDRM") return ImageSource.FromFile("sc252rdrm.png"); + else if (value.ToString() == "242W") return ImageSource.FromFile("sc242w.png"); + else if (value.ToString() == "302") return ImageSource.FromFile("sc302.png"); + else if (value.ToString() == "303") return ImageSource.FromFile("sc303.png"); + else if (value.ToString() == "303PDW") return ImageSource.FromFile("sc303pdw.png"); + else return ImageSource.FromFile("sunlightlogo.png"); + } + + // 如果值为空或类型不对,返回默认值或 null + return ImageSource.FromFile("sunlightlogo.png"); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + // 通常图片转回字符串在 UI 上很少用到,可以抛出异常或留空 + throw new NotImplementedException(); + } + } +} diff --git a/InfoPage.xaml b/InfoPage.xaml index 00e33b1..2b97231 100644 --- a/InfoPage.xaml +++ b/InfoPage.xaml @@ -1,9 +1,74 @@ - - - + x:Class="SunlightAggregationTerminal.InfoPage" + xmlns:converters="clr-namespace:SunlightAggregationTerminal.Converters" + Title="设备信息"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/InfoPage.xaml.cs b/InfoPage.xaml.cs index c74c0ce..fee4693 100644 --- a/InfoPage.xaml.cs +++ b/InfoPage.xaml.cs @@ -1,9 +1,26 @@ +using SunlightAggregationTerminal.Models; +using System.Collections.ObjectModel; + namespace SunlightAggregationTerminal; public partial class InfoPage : ContentPage { - public InfoPage() + public ObservableCollection InfoItems { get; set; } = new(); + public InfoPage() { InitializeComponent(); - } + + + InfoItems.Add(new InfoItem { Name="202",Model= "302", State="tz",Machine="123456",Information="etggsgt\n234423\ngsgsg\nstset" }); + InfoItems.Add(new InfoItem { Name = "pdw", Model = "252-2T", State = "tz", Machine = "123456", Information = "etggsgt\n234423\ngsgsg\nstset" }); + InfoItems.Add(new InfoItem { Name = "pdw", Model = "242W", State = "tz", Machine = "123456", Information = "etggsgt\n234423\ngsgsg\nstset" }); + + + CardCollectionView.ItemsSource = InfoItems; + } + + private void CardCollectionView_RemainingItemsThresholdReached(object sender, EventArgs e) + { + + } } \ No newline at end of file diff --git a/Models/DataSource.cs b/Models/DataSource.cs index 41705c5..8c92121 100644 --- a/Models/DataSource.cs +++ b/Models/DataSource.cs @@ -23,6 +23,22 @@ namespace SunlightAggregationTerminal.Models public DateTime Time { get; set; } public MsgType Type { get; set; } } + public class InfoItem + { + public string? Name { get; set; } + public string? State { get; set; } + public string? Machine { get; set; } + public string? Information { get; set; } + public string? Model { get; set; } + public string? Type { get; set; } + public string? A { get; set; } + public string? B { get; set; } + public string? C { get; set; } + public string? D { get; set; } + public string? E { get; set; } + public string? F { get; set; } + } + public class DyelotItem { public string? Dyelot { get; set; } diff --git a/Resources/Images/sc242w.png b/Resources/Images/sc242w.png new file mode 100644 index 0000000..766e0ce Binary files /dev/null and b/Resources/Images/sc242w.png differ diff --git a/Resources/Images/sc2522t.png b/Resources/Images/sc2522t.png new file mode 100644 index 0000000..bc35305 Binary files /dev/null and b/Resources/Images/sc2522t.png differ diff --git a/Resources/Images/sc252rb.png b/Resources/Images/sc252rb.png new file mode 100644 index 0000000..bb09d79 Binary files /dev/null and b/Resources/Images/sc252rb.png differ diff --git a/Resources/Images/sc252rmrd.png b/Resources/Images/sc252rmrd.png new file mode 100644 index 0000000..08830cb Binary files /dev/null and b/Resources/Images/sc252rmrd.png differ diff --git a/Resources/Images/sc302.png b/Resources/Images/sc302.png new file mode 100644 index 0000000..4742d3d Binary files /dev/null and b/Resources/Images/sc302.png differ diff --git a/Resources/Images/sc303.png b/Resources/Images/sc303.png new file mode 100644 index 0000000..e2cb8a6 Binary files /dev/null and b/Resources/Images/sc303.png differ diff --git a/Resources/Images/sc303pdw.png b/Resources/Images/sc303pdw.png new file mode 100644 index 0000000..e25ffd9 Binary files /dev/null and b/Resources/Images/sc303pdw.png differ diff --git a/Resources/Images/sunlight_logo.jpg b/Resources/Images/sunlight_logo.jpg new file mode 100644 index 0000000..1b98457 Binary files /dev/null and b/Resources/Images/sunlight_logo.jpg differ diff --git a/Resources/Images/sunlight_logotext.jpg b/Resources/Images/sunlight_logotext.jpg new file mode 100644 index 0000000..fee7f29 Binary files /dev/null and b/Resources/Images/sunlight_logotext.jpg differ diff --git a/Resources/Images/sunlight_sc.png b/Resources/Images/sunlight_sc.png new file mode 100644 index 0000000..5165ad8 Binary files /dev/null and b/Resources/Images/sunlight_sc.png differ diff --git a/Resources/Images/sunlightlogo.jpg b/Resources/Images/sunlightlogo.jpg new file mode 100644 index 0000000..dcaea1d Binary files /dev/null and b/Resources/Images/sunlightlogo.jpg differ