Browse Source

添加细节信息页面

master
Administrator 3 months ago
parent
commit
954d1458d3
  1. 147
      InfoDetail.xaml
  2. 44
      InfoDetail.xaml.cs
  3. 3
      InfoPage.xaml
  4. 3
      InfoPage.xaml.cs

147
InfoDetail.xaml

@ -2,11 +2,148 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SunlightAggregationTerminal.InfoDetail" x:Class="SunlightAggregationTerminal.InfoDetail"
Title="InfoDetail"> xmlns:converters="clr-namespace:SunlightAggregationTerminal.Converters"
Title="细节信息">
<ContentPage.Resources>
<ResourceDictionary>
<converters:StringToImageConverter x:Key="StringToImageConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<VerticalStackLayout> <VerticalStackLayout>
<Label <Grid>
Text="Welcome to .NET MAUI!" <Grid>
VerticalOptions="Center" <VerticalStackLayout>
HorizontalOptions="Center" /> <Grid BackgroundColor="#CCCCCC" Padding="10">
<HorizontalStackLayout>
<!-- 图片 -->
<Image WidthRequest="150" HeightRequest="150"
Source="{Binding Path=Model, Converter={StaticResource StringToImageConverter}}"/>
<!-- 设备状态 -->
<VerticalStackLayout>
<Label Text="{Binding Name}" FontAttributes="Bold"
FontSize="24" TextColor="Black" Padding="5"/>
<HorizontalStackLayout>
<Label Text="状态: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
</HorizontalStackLayout>
<HorizontalStackLayout>
<Label Text="机台: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding Machine}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</HorizontalStackLayout>
</Grid>
<BoxView HeightRequest="3" Color="#CCCCCC" />
<HorizontalStackLayout BackgroundColor="#F0F0F0" HeightRequest="50">
<Button Text="实时信息" Clicked="Button_real" BackgroundColor="Transparent" TextColor="Black"/>
<Button Text="设备信息" Clicked="Button_machine" BackgroundColor="Transparent" TextColor="Black"/>
<Button Text="执行历史" Clicked="Button_history" BackgroundColor="Transparent" TextColor="Black"/>
<Button Text="远程控制" Clicked="Button_control" BackgroundColor="Transparent" TextColor="Black"/>
</HorizontalStackLayout>
<Grid x:Name="_real" >
<!-- 设备信息 -->
<Label Text="{Binding ModelA}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelA, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding ModelB}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelB, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding ModelC}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelC, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding ModelD}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelD, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding ModelE}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelE, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding ModelF}" FontAttributes="Bold" FontSize="22" TextColor="Black"
IsVisible="{Binding Path=ModelF, Converter={StaticResource StringToBoolConverter}}"/>
<Label Text="{Binding Information}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
</Grid>
<!-- 设备内容 -->
<Grid x:Name="_machine" IsVisible="False">
<CollectionView x:Name="CardCollectionView_machine"
RemainingItemsThreshold="5">
<CollectionView.ItemTemplate>
<DataTemplate>
<Border BackgroundColor="White" Stroke="#CCCCCC"
StrokeThickness="2" Margin="10,0,10,10"
StrokeShape="RoundRectangle 10">
<VerticalStackLayout VerticalOptions="Center">
<HorizontalStackLayout>
<Label Text="名称: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="代码: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="状态: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="信息: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<!-- 历史 -->
<Grid x:Name="_history" IsVisible="False">
<CollectionView x:Name="CardCollectionView_history"
RemainingItemsThreshold="5">
<CollectionView.ItemTemplate>
<DataTemplate>
<Border BackgroundColor="White" Stroke="#CCCCCC"
StrokeThickness="2" Margin="10,0,10,10"
StrokeShape="RoundRectangle 10">
<VerticalStackLayout VerticalOptions="Center">
<HorizontalStackLayout>
<Label Text="工单: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="染机: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="时间: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="信息: " FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
<Label Text="{Binding State}" FontAttributes="Bold"
FontSize="22" TextColor="Black"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</Border>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<!-- 远程 -->
<Grid x:Name="_control" IsVisible="False">
</Grid>
</VerticalStackLayout>
</Grid>
</Grid>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

44
InfoDetail.xaml.cs

@ -1,9 +1,49 @@
using CommunityToolkit.Mvvm.ComponentModel;
using SunlightAggregationTerminal.Models;
using System.Reflection.PortableExecutable;
namespace SunlightAggregationTerminal; namespace SunlightAggregationTerminal;
public partial class InfoDetail : ContentPage public partial class InfoDetail : ContentPage
{ {
public InfoDetail() public InfoDetail(InfoItem item)
{ {
InitializeComponent(); InitializeComponent();
} this.BindingContext = item;
}
private void Button_real(object sender, EventArgs e)
{
_real.IsVisible = true;
_machine.IsVisible = false;
_history.IsVisible = false;
_control.IsVisible = false;
}
private void Button_machine(object sender, EventArgs e)
{
_real.IsVisible = false;
_machine.IsVisible = true;
_history.IsVisible = false;
_control.IsVisible = false;
}
private void Button_history(object sender, EventArgs e)
{
_real.IsVisible = false;
_machine.IsVisible = false;
_history.IsVisible = true;
_control.IsVisible = false;
}
private async void Button_control(object sender, EventArgs e)
{
_real.IsVisible = false;
_machine.IsVisible = false;
_history.IsVisible = false;
_control.IsVisible = true;
await DisplayAlertAsync("限制", "当前功能暂不可用", "是");
}
} }

3
InfoPage.xaml

@ -28,8 +28,7 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0" BackgroundColor="#CCCCCC"> <Grid Grid.Row="0" BackgroundColor="#CCCCCC">
<Label Text="{Binding Name}" FontAttributes="Bold" <Label Text="{Binding Name}" FontAttributes="Bold"
FontSize="24" TextColor="Black" FontSize="24" TextColor="Black" Padding="5"/>
Padding="5"/>
</Grid> </Grid>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<VerticalStackLayout> <VerticalStackLayout>

3
InfoPage.xaml.cs

@ -14,7 +14,6 @@ public partial class InfoPage : ContentPage
public static string? _Name, _State, _MachineName, _Machine, _Information, _Model, public static string? _Name, _State, _MachineName, _Machine, _Information, _Model,
_Type, _ModelA, _ModelB, _ModelC, _ModelD, _ModelE, _ModelF; _Type, _ModelA, _ModelB, _ModelC, _ModelD, _ModelE, _ModelF;
public InfoPage() public InfoPage()
{ {
InitializeComponent(); InitializeComponent();
@ -99,7 +98,7 @@ public partial class InfoPage : ContentPage
{ {
// DisplayAlert("提示", $"你点击了工单: {item.MachineName}", "确定"); // DisplayAlert("提示", $"你点击了工单: {item.MachineName}", "确定");
await Navigation.PushAsync(new InfoDetail()); await Navigation.PushAsync(new InfoDetail(item));
} }
} }
} }

Loading…
Cancel
Save