添加信息播报页面

This commit is contained in:
sc committed 2025-07-25 00:49:50 +08:00
commit 8d5631a651
6 files changed
+159 -3

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.UserInformation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
mc:Ignorable="d"
Title="UserInformation" Height="450" Width="800">
<Grid>
<DataGrid x:Name="Griddata" AlternationCount="2" IsReadOnly="True"
d:ItemsSource="{d:SampleData ItemCount=30}" AutoGenerateColumns="False" MinColumnWidth="30"
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="25" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFFFF" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="20"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFC0C0C0"/>
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Background" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" Value="#FFFFFFFF"/>
<Setter Property="Foreground" Value="#000000"/>
</Style>
<DataTemplate x:Key="btnCell">
<!--注意此处的设置方式-->
<Button Content="{x:Static lang:Resources.Confirm}" Click="Button_Click" Tag="{Binding}"/>
</DataTemplate>
</DataGrid.Resources>
<DataGrid.Columns>
<!--列信息绑定-->
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Machine}" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding Code}" MaxWidth="0" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding ID}" MaxWidth="0" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Information}" Binding="{Binding inf}" Width="*" IsReadOnly="True"/>
<DataGridTemplateColumn Width="100" CellTemplate="{StaticResource btnCell}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
+57
View File
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// UserInformation.xaml 的交互逻辑
/// </summary>
public partial class UserInformation : Window
{
DataTable dataTable = new DataTable();
public UserInformation()
{
InitializeComponent();
//DataTable dataTable = new DataTable();
dataTable.Columns.Add("Machine",Type.GetType("System.String"));
dataTable.Columns.Add("Information", Type.GetType("System.String"));
dataTable.Columns.Add("Code", Type.GetType("System.String"));
dataTable.Columns.Add("ID", Type.GetType("System.Int32"));
dataTable.Rows.Add(new object[] { "1", "a","423","12"});
dataTable.Rows.Add(new object[] { "2", "b" ,"345","122"});
dataTable.Rows.Add(new object[] { "3", "c" ,"345","32"});
dataTable.Rows.Add(new object[] { "1", "a", "423", "1232" });
dataTable.Rows.Add(new object[] { "2", "b", "345", "1222" });
dataTable.Rows.Add(new object[] { "3", "c", "345", "325" });
Griddata.ItemsSource = dataTable.DefaultView;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
DataRowView datarow = (DataRowView)button.Tag;
var y= datarow.Row.Field<int>("ID");
DataRow erwqer = dataTable.Select("ID='" + y + "'").First();
erwqer.Delete();
Griddata.ItemsSource = dataTable.DefaultView;
if (dataTable.Rows.Count == 0) { this.Close(); }
}
}
}