add - 设备信息
parent
9b89759cc9
commit
96da10c07b
@ -0,0 +1,166 @@
|
||||
<Window x:Class="Sln.Wcs.UI.Controls.CustomMessageBox"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Title="提示"
|
||||
Height="200" Width="350"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<!-- 关闭按钮样式 -->
|
||||
<Style x:Key="CloseBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Width" Value="30"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 确定按钮样式 -->
|
||||
<Style x:Key="OkBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="24,8"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 是/否按钮样式 -->
|
||||
<Style x:Key="YesBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="20,8"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="NoBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3A3A4A"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="20,8"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Border Background="#1A1A2E" CornerRadius="8" Margin="10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="20" ShadowDepth="3" Opacity="0.5"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Grid Grid.Row="0" Background="#252540" Margin="-1,-1,-1,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="TxtTitle" Grid.Column="0" Text="提示" Foreground="#ECF0F1" FontSize="14" FontWeight="SemiBold"
|
||||
VerticalAlignment="Center" Margin="16,12"/>
|
||||
<Button Grid.Column="1" Content="✕" Style="{StaticResource CloseBtnStyle}" Click="BtnClose_Click" Margin="0,0,8,0"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<StackPanel Grid.Row="1" Margin="24,16" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock x:Name="TxtIcon" Text="✓" FontSize="32" Margin="0,0,16,0" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="TxtMessage" Text="" Foreground="#E0E0E0" FontSize="14" TextWrapping="Wrap" MaxWidth="220" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<StackPanel x:Name="PanelOneButton" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="24,0,24,20" Visibility="Collapsed">
|
||||
<Button Content="确定" Style="{StaticResource OkBtnStyle}" Click="BtnOk_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel x:Name="PanelTwoButtons" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="24,0,24,20" Visibility="Collapsed">
|
||||
<Button x:Name="BtnYes" Content="是" Style="{StaticResource YesBtnStyle}" Click="BtnYes_Click" Margin="0,0,12,0"/>
|
||||
<Button x:Name="BtnNo" Content="否" Style="{StaticResource NoBtnStyle}" Click="BtnNo_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@ -0,0 +1,109 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Sln.Wcs.UI.Controls
|
||||
{
|
||||
public partial class CustomMessageBox : Window
|
||||
{
|
||||
public MessageBoxResult Result { get; private set; } = MessageBoxResult.None;
|
||||
|
||||
public CustomMessageBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message, string title = "提示", MessageBoxButton button = MessageBoxButton.OK)
|
||||
{
|
||||
var window = new CustomMessageBox
|
||||
{
|
||||
TxtMessage = { Text = message },
|
||||
Title = title,
|
||||
TxtTitle = { Text = title }
|
||||
};
|
||||
|
||||
if (button == MessageBoxButton.OK)
|
||||
{
|
||||
window.PanelOneButton.Visibility = Visibility.Visible;
|
||||
window.PanelTwoButtons.Visibility = Visibility.Collapsed;
|
||||
window.TxtIcon.Text = "✓";
|
||||
window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4CAF50"));
|
||||
}
|
||||
else if (button == MessageBoxButton.YesNo)
|
||||
{
|
||||
window.PanelOneButton.Visibility = Visibility.Collapsed;
|
||||
window.PanelTwoButtons.Visibility = Visibility.Visible;
|
||||
window.TxtIcon.Text = "?";
|
||||
window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFC107"));
|
||||
}
|
||||
|
||||
window.ShowDialog();
|
||||
return window.Result;
|
||||
}
|
||||
|
||||
public static void ShowSuccess(string message, Window owner = null)
|
||||
{
|
||||
var window = new CustomMessageBox
|
||||
{
|
||||
TxtMessage = { Text = message },
|
||||
Title = "提示",
|
||||
TxtTitle = { Text = "提示" },
|
||||
PanelOneButton = { Visibility = Visibility.Visible },
|
||||
PanelTwoButtons = { Visibility = Visibility.Collapsed }
|
||||
};
|
||||
window.TxtIcon.Text = "✓";
|
||||
window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#4CAF50"));
|
||||
|
||||
if (owner != null)
|
||||
{
|
||||
window.Owner = owner;
|
||||
}
|
||||
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
public static MessageBoxResult ShowConfirm(string message, Window owner = null)
|
||||
{
|
||||
var window = new CustomMessageBox
|
||||
{
|
||||
TxtMessage = { Text = message },
|
||||
Title = "确认",
|
||||
TxtTitle = { Text = "确认" },
|
||||
PanelOneButton = { Visibility = Visibility.Collapsed },
|
||||
PanelTwoButtons = { Visibility = Visibility.Visible }
|
||||
};
|
||||
window.TxtIcon.Text = "?";
|
||||
window.TxtIcon.Foreground = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFC107"));
|
||||
|
||||
if (owner != null)
|
||||
{
|
||||
window.Owner = owner;
|
||||
}
|
||||
|
||||
window.ShowDialog();
|
||||
return window.Result;
|
||||
}
|
||||
|
||||
private void BtnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BtnYes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.Yes;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BtnNo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.No;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BtnClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="Sln.Wcs.UI.Page.BasicInfo.BasicInfoPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="1000">
|
||||
<Grid>
|
||||
<TextBlock Text="基础信息"
|
||||
FontSize="48"
|
||||
Foreground="#ECF0F1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.BasicInfo
|
||||
{
|
||||
public partial class BasicInfoPage : UserControl
|
||||
{
|
||||
public BasicInfoPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,349 @@
|
||||
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.DeviceInfo.DeviceAddWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Title="添加设备"
|
||||
Height="500" Width="520"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Window.Resources>
|
||||
<!-- 标题样式 -->
|
||||
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Margin" Value="0,0,0,20"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<!-- 标签样式(左侧标题) -->
|
||||
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
</Style>
|
||||
|
||||
<!-- 输入框样式 -->
|
||||
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#0D0D18"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 下拉框样式 -->
|
||||
<Style x:Key="FormComboBoxStyle" TargetType="ComboBox">
|
||||
<Setter Property="Background" Value="#0D0D18"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBox">
|
||||
<Grid>
|
||||
<Border x:Name="Border" Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter Grid.Column="0" x:Name="ContentSite"
|
||||
Margin="10,0,30,0"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
<ToggleButton Grid.ColumnSpan="2" x:Name="ToggleButton" ClickMode="Press" Focusable="False"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Background="Transparent" BorderThickness="0">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="Transparent"/>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
</ToggleButton>
|
||||
<Path Grid.Column="1" x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Data="M 0 0 L 6 6 L 12 0 Z" Fill="#B0B0B0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Popup x:Name="Popup" AllowsTransparency="True" IsOpen="{TemplateBinding IsDropDownOpen}" PopupAnimation="Slide"
|
||||
Placement="Bottom" Focusable="False">
|
||||
<Border x:Name="DropDown" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
Background="#1A1A2E" BorderBrush="#3A3A4A" BorderThickness="1" CornerRadius="4" Margin="0,2,0,0">
|
||||
<ScrollViewer Margin="4">
|
||||
<StackPanel IsItemsHost="True"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsDropDownOpen" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||
<Setter TargetName="Arrow" Property="Data" Value="M 0 6 L 6 0 L 12 6 Z"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 下拉项样式 -->
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBoxItem">
|
||||
<Border x:Name="Border" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="2">
|
||||
<ContentPresenter/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="#252540"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 确认按钮样式 -->
|
||||
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="28,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 取消按钮样式 -->
|
||||
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3A3A4A"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="28,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 关闭按钮样式 -->
|
||||
<Style x:Key="CloseBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Width" Value="30"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Border Background="#1A1A2E" CornerRadius="8" Margin="10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="20" ShadowDepth="3" Opacity="0.5"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Grid Grid.Row="0" Background="#252540" Margin="-1,-1,-1,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="添加设备" Foreground="#ECF0F1" FontSize="16" FontWeight="SemiBold"
|
||||
VerticalAlignment="Center" Margin="16,12"/>
|
||||
<Button Grid.Column="1" Content="✕" Style="{StaticResource CloseBtnStyle}" Click="BtnClose_Click" Margin="0,0,8,0"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单内容 -->
|
||||
<StackPanel Grid.Row="1" Margin="24,16,24,24" Width="450" HorizontalAlignment="Center">
|
||||
|
||||
<!-- 第一行:设备编号 + 设备名称 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="设备编号" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="2" x:Name="TxtDeviceCode" Style="{StaticResource FormTextBoxStyle}"/>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="设备名称" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="6" x:Name="TxtDeviceName" Style="{StaticResource FormTextBoxStyle}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 第二行:设备类型 + 设备状态 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="设备类型" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="2" x:Name="CmbDeviceType" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="输送线" Tag="0"/>
|
||||
<ComboBoxItem Content="AGV" Tag="1"/>
|
||||
<ComboBoxItem Content="提升机" Tag="2"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="设备状态" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="6" x:Name="CmbDeviceStatus" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="正常" Tag="0"/>
|
||||
<ComboBoxItem Content="在忙" Tag="1"/>
|
||||
<ComboBoxItem Content="异常" Tag="2"/>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
<!-- 第三行:是否标识 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="是否标识" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="2" x:Name="CmbIsFlag" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="是" Tag="1"/>
|
||||
<ComboBoxItem Content="否" Tag="0"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="" Style="{StaticResource LabelStyle}" Visibility="Hidden"/>
|
||||
<TextBox Grid.Column="6" Style="{StaticResource FormTextBoxStyle}" Visibility="Hidden"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 第四行:备注 -->
|
||||
<Grid Margin="0,0,0,24">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="备注" Style="{StaticResource LabelStyle}" VerticalAlignment="Top" Margin="0,8,0,0"/>
|
||||
<TextBox Grid.Column="2" x:Name="TxtRemark" Style="{StaticResource FormTextBoxStyle}" Height="60" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="取消" Style="{StaticResource CancelBtnStyle}" Click="BtnCancel_Click" Margin="0,0,12,0"/>
|
||||
<Button Content="确认" Style="{StaticResource ConfirmBtnStyle}" Click="BtnConfirm_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@ -0,0 +1,91 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sln.Wcs.Model.Domain;
|
||||
using Sln.Wcs.Repository.service;
|
||||
using Sln.Wcs.UI.Controls;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.BasicInfo.DeviceInfo
|
||||
{
|
||||
public partial class DeviceAddWindow : Window
|
||||
{
|
||||
private readonly IBaseDeviceInfoService _deviceInfoService;
|
||||
private readonly DeviceInfoPage _parentPage;
|
||||
|
||||
public DeviceAddWindow(DeviceInfoPage parentPage)
|
||||
{
|
||||
InitializeComponent();
|
||||
_deviceInfoService = App.ServiceProvider.GetService<IBaseDeviceInfoService>();
|
||||
_parentPage = parentPage;
|
||||
}
|
||||
|
||||
private void BtnConfirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(TxtDeviceCode.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入设备编号", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(TxtDeviceName.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入设备名称", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
var deviceTypeItem = CmbDeviceType.SelectedItem as ComboBoxItem;
|
||||
var deviceStatusItem = CmbDeviceStatus.SelectedItem as ComboBoxItem;
|
||||
var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
|
||||
|
||||
var device = new BaseDeviceInfo
|
||||
{
|
||||
deviceCode = TxtDeviceCode.Text.Trim(),
|
||||
deviceName = TxtDeviceName.Text.Trim(),
|
||||
deviceType = deviceTypeItem?.Tag != null ? int.Parse(deviceTypeItem.Tag.ToString()) : null,
|
||||
deviceStatus = deviceStatusItem?.Tag != null ? int.Parse(deviceStatusItem.Tag.ToString()) : null,
|
||||
isFlag = isFlagItem?.Tag != null ? int.Parse(isFlagItem.Tag.ToString()) : null,
|
||||
remark = TxtRemark.Text?.Trim(),
|
||||
createdTime = DateTime.Now
|
||||
};
|
||||
|
||||
var success = _deviceInfoService.Insert(device);
|
||||
if (success)
|
||||
{
|
||||
CustomMessageBox.Show("添加成功", "提示", MessageBoxButton.OK);
|
||||
CloseAndRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show("添加失败", "错误", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CloseAndRefresh();
|
||||
}
|
||||
|
||||
private void BtnClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CloseAndRefresh();
|
||||
}
|
||||
|
||||
private void CloseAndRefresh()
|
||||
{
|
||||
ClearForm();
|
||||
_parentPage.LoadData();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ClearForm()
|
||||
{
|
||||
TxtDeviceCode.Text = "";
|
||||
TxtDeviceName.Text = "";
|
||||
TxtRemark.Text = "";
|
||||
CmbDeviceType.SelectedIndex = 0;
|
||||
CmbDeviceStatus.SelectedIndex = 0;
|
||||
CmbIsFlag.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,349 @@
|
||||
<Window x:Class="Sln.Wcs.UI.Page.BasicInfo.DeviceInfo.DeviceEditWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Title="编辑设备"
|
||||
Height="500" Width="520"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Window.Resources>
|
||||
<!-- 标题样式 -->
|
||||
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||
<Setter Property="FontSize" Value="20"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Margin" Value="0,0,0,20"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<!-- 标签样式(左侧标题) -->
|
||||
<Style x:Key="LabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="MinWidth" Value="70"/>
|
||||
</Style>
|
||||
|
||||
<!-- 输入框样式 -->
|
||||
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#0D0D18"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 下拉框样式 -->
|
||||
<Style x:Key="FormComboBoxStyle" TargetType="ComboBox">
|
||||
<Setter Property="Background" Value="#0D0D18"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBox">
|
||||
<Grid>
|
||||
<Border x:Name="Border" Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter Grid.Column="0" x:Name="ContentSite"
|
||||
Margin="10,0,30,0"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
<ToggleButton Grid.ColumnSpan="2" x:Name="ToggleButton" ClickMode="Press" Focusable="False"
|
||||
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Background="Transparent" BorderThickness="0">
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="Transparent"/>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
</ToggleButton>
|
||||
<Path Grid.Column="1" x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Data="M 0 0 L 6 6 L 12 0 Z" Fill="#B0B0B0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Popup x:Name="Popup" AllowsTransparency="True" IsOpen="{TemplateBinding IsDropDownOpen}" PopupAnimation="Slide"
|
||||
Placement="Bottom" Focusable="False">
|
||||
<Border x:Name="DropDown" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
Background="#1A1A2E" BorderBrush="#3A3A4A" BorderThickness="1" CornerRadius="4" Margin="0,2,0,0">
|
||||
<ScrollViewer Margin="4">
|
||||
<StackPanel IsItemsHost="True"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsDropDownOpen" Value="True">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="#2196F3"/>
|
||||
<Setter TargetName="Arrow" Property="Data" Value="M 0 6 L 6 0 L 12 6 Z"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 下拉项样式 -->
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBoxItem">
|
||||
<Border x:Name="Border" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="2">
|
||||
<ContentPresenter/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="#252540"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="Border" Property="Background" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 确认按钮样式 -->
|
||||
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="28,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 取消按钮样式 -->
|
||||
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3A3A4A"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="28,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 关闭按钮样式 -->
|
||||
<Style x:Key="CloseBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
<Setter Property="Width" Value="30"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Border Background="#1A1A2E" CornerRadius="8" Margin="10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="20" ShadowDepth="3" Opacity="0.5"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<Grid Grid.Row="0" Background="#252540" Margin="-1,-1,-1,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="编辑设备" Foreground="#ECF0F1" FontSize="16" FontWeight="SemiBold"
|
||||
VerticalAlignment="Center" Margin="16,12"/>
|
||||
<Button Grid.Column="1" Content="✕" Style="{StaticResource CloseBtnStyle}" Click="BtnClose_Click" Margin="0,0,8,0"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单内容 -->
|
||||
<StackPanel Grid.Row="1" Margin="24,16,24,24" Width="450" HorizontalAlignment="Center">
|
||||
|
||||
<!-- 第一行:设备编号 + 设备名称 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="设备编号" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="2" x:Name="TxtDeviceCode" Style="{StaticResource FormTextBoxStyle}" IsEnabled="False"/>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="设备名称" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBox Grid.Column="6" x:Name="TxtDeviceName" Style="{StaticResource FormTextBoxStyle}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 第二行:设备类型 + 设备状态 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="设备类型" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="2" x:Name="CmbDeviceType" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="输送线" Tag="0"/>
|
||||
<ComboBoxItem Content="AGV" Tag="1"/>
|
||||
<ComboBoxItem Content="提升机" Tag="2"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="设备状态" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="6" x:Name="CmbDeviceStatus" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="正常" Tag="0"/>
|
||||
<ComboBoxItem Content="在忙" Tag="1"/>
|
||||
<ComboBoxItem Content="异常" Tag="2"/>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
<!-- 第三行:是否标识 -->
|
||||
<Grid Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="24"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="是否标识" Style="{StaticResource LabelStyle}"/>
|
||||
<ComboBox Grid.Column="2" x:Name="CmbIsFlag" Style="{StaticResource FormComboBoxStyle}">
|
||||
<ComboBoxItem Content="请选择" IsSelected="True"/>
|
||||
<ComboBoxItem Content="是" Tag="1"/>
|
||||
<ComboBoxItem Content="否" Tag="0"/>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Column="4" Text="" Style="{StaticResource LabelStyle}" Visibility="Hidden"/>
|
||||
<TextBox Grid.Column="6" Style="{StaticResource FormTextBoxStyle}" Visibility="Hidden"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 第四行:备注 -->
|
||||
<Grid Margin="0,0,0,24">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="备注" Style="{StaticResource LabelStyle}" VerticalAlignment="Top" Margin="0,8,0,0"/>
|
||||
<TextBox Grid.Column="2" x:Name="TxtRemark" Style="{StaticResource FormTextBoxStyle}" Height="60" TextWrapping="Wrap" AcceptsReturn="True" VerticalContentAlignment="Top"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 按钮区域 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="取消" Style="{StaticResource CancelBtnStyle}" Click="BtnCancel_Click" Margin="0,0,12,0"/>
|
||||
<Button Content="确认" Style="{StaticResource ConfirmBtnStyle}" Click="BtnConfirm_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@ -0,0 +1,107 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sln.Wcs.Model.Domain;
|
||||
using Sln.Wcs.Repository.service;
|
||||
using Sln.Wcs.UI.Controls;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.BasicInfo.DeviceInfo
|
||||
{
|
||||
public partial class DeviceEditWindow : Window
|
||||
{
|
||||
private readonly IBaseDeviceInfoService _deviceInfoService;
|
||||
private readonly DeviceInfoPage _parentPage;
|
||||
private readonly BaseDeviceInfo _device;
|
||||
|
||||
public DeviceEditWindow(DeviceInfoPage parentPage, BaseDeviceInfo device)
|
||||
{
|
||||
InitializeComponent();
|
||||
_deviceInfoService = App.ServiceProvider.GetService<IBaseDeviceInfoService>();
|
||||
_parentPage = parentPage;
|
||||
_device = device;
|
||||
LoadDeviceData();
|
||||
}
|
||||
|
||||
private void LoadDeviceData()
|
||||
{
|
||||
TxtDeviceCode.Text = _device.deviceCode;
|
||||
TxtDeviceName.Text = _device.deviceName;
|
||||
TxtRemark.Text = _device.remark;
|
||||
|
||||
if (_device.deviceType.HasValue)
|
||||
{
|
||||
SelectComboBoxItem(CmbDeviceType, _device.deviceType.Value);
|
||||
}
|
||||
|
||||
if (_device.deviceStatus.HasValue)
|
||||
{
|
||||
SelectComboBoxItem(CmbDeviceStatus, _device.deviceStatus.Value);
|
||||
}
|
||||
|
||||
if (_device.isFlag.HasValue)
|
||||
{
|
||||
SelectComboBoxItem(CmbIsFlag, _device.isFlag.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectComboBoxItem(ComboBox comboBox, int value)
|
||||
{
|
||||
foreach (ComboBoxItem item in comboBox.Items)
|
||||
{
|
||||
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int tagValue) && tagValue == value)
|
||||
{
|
||||
comboBox.SelectedItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnConfirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(TxtDeviceName.Text))
|
||||
{
|
||||
CustomMessageBox.Show("请输入设备名称", "提示", MessageBoxButton.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
var deviceTypeItem = CmbDeviceType.SelectedItem as ComboBoxItem;
|
||||
var deviceStatusItem = CmbDeviceStatus.SelectedItem as ComboBoxItem;
|
||||
var isFlagItem = CmbIsFlag.SelectedItem as ComboBoxItem;
|
||||
|
||||
_device.deviceName = TxtDeviceName.Text.Trim();
|
||||
_device.deviceType = deviceTypeItem?.Tag != null ? int.Parse(deviceTypeItem.Tag.ToString()) : null;
|
||||
_device.deviceStatus = deviceStatusItem?.Tag != null ? int.Parse(deviceStatusItem.Tag.ToString()) : null;
|
||||
_device.isFlag = isFlagItem?.Tag != null ? int.Parse(isFlagItem.Tag.ToString()) : null;
|
||||
_device.remark = TxtRemark.Text?.Trim();
|
||||
_device.updatedTime = DateTime.Now;
|
||||
|
||||
var success = _deviceInfoService.Update(_device);
|
||||
if (success)
|
||||
{
|
||||
CustomMessageBox.Show("修改成功", "提示", MessageBoxButton.OK);
|
||||
CloseAndRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show("修改失败", "错误", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CloseAndRefresh();
|
||||
}
|
||||
|
||||
private void BtnClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CloseAndRefresh();
|
||||
}
|
||||
|
||||
private void CloseAndRefresh()
|
||||
{
|
||||
_parentPage.LoadData();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,384 @@
|
||||
<UserControl x:Class="Sln.Wcs.UI.Page.BasicInfo.DeviceInfo.DeviceInfoPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Sln.Wcs.UI.Page.BasicInfo.DeviceInfo"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="1000"
|
||||
Background="#0D0D18">
|
||||
<UserControl.Resources>
|
||||
<!-- 设备类型转换器 -->
|
||||
<local:DeviceTypeConverter x:Key="DeviceTypeConverter"/>
|
||||
<!-- 设备状态转换器 -->
|
||||
<local:DeviceStatusConverter x:Key="DeviceStatusConverter"/>
|
||||
|
||||
<!-- 表格样式 -->
|
||||
<Style x:Key="DataGridStyle" TargetType="DataGrid">
|
||||
<Setter Property="Background" Value="#1A1A2E"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="RowBackground" Value="#1A1A2E"/>
|
||||
<Setter Property="AlternatingRowBackground" Value="#16162A"/>
|
||||
<Setter Property="GridLinesVisibility" Value="Horizontal"/>
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="#2A2A35"/>
|
||||
<Setter Property="VerticalGridLinesBrush" Value="#2A2A35"/>
|
||||
<Setter Property="HeadersVisibility" Value="Column"/>
|
||||
<Setter Property="SelectionMode" Value="Single"/>
|
||||
<Setter Property="SelectionUnit" Value="FullRow"/>
|
||||
<Setter Property="CanUserAddRows" Value="False"/>
|
||||
<Setter Property="CanUserDeleteRows" Value="False"/>
|
||||
<Setter Property="AutoGenerateColumns" Value="False"/>
|
||||
<Setter Property="IsReadOnly" Value="True"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridColumnHeader">
|
||||
<Setter Property="Background" Value="#252540"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="Padding" Value="12,10"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,1,1"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="Padding" Value="12,8"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="DataGridCell">
|
||||
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||
<ContentPresenter VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#3D3D5C"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGridRow">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#2A2A45"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#3D3D5C"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- 操作按钮样式 -->
|
||||
<Style x:Key="OperateBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="FontSize" Value="12"/>
|
||||
<Setter Property="Padding" Value="10,5"/>
|
||||
<Setter Property="Margin" Value="0,0,6,0"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#3D3D5C"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="EditBtnStyle" TargetType="Button" BasedOn="{StaticResource OperateBtnStyle}">
|
||||
<Setter Property="Foreground" Value="#64B5F6"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="DeleteBtnStyle" TargetType="Button" BasedOn="{StaticResource OperateBtnStyle}">
|
||||
<Setter Property="Foreground" Value="#EF5350"/>
|
||||
</Style>
|
||||
|
||||
<!-- 标题样式 -->
|
||||
<Style x:Key="TitleStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#ECF0F1"/>
|
||||
<Setter Property="FontSize" Value="24"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Margin" Value="0,0,16,16"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<!-- 添加按钮样式 -->
|
||||
<Style x:Key="AddBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="16,6"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="+" FontSize="16" FontWeight="Bold" Margin="0,0,6,0" VerticalAlignment="Center"/>
|
||||
<ContentPresenter VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 查询按钮样式 -->
|
||||
<Style x:Key="QueryBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3A3A4A"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="16,6"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="🔍" FontSize="12" Margin="0,0,6,0" VerticalAlignment="Center"/>
|
||||
<ContentPresenter VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 表单标签样式 -->
|
||||
<Style x:Key="FormLabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<!-- 表单输入框样式 -->
|
||||
<Style x:Key="FormTextBoxStyle" TargetType="TextBox">
|
||||
<Setter Property="Background" Value="#252540"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
<Setter Property="BorderBrush" Value="#3A3A4A"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="10,8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" Value="#2196F3"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 确认按钮样式 -->
|
||||
<Style x:Key="ConfirmBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#2196F3"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="24,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#42A5F5"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#1976D2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- 取消按钮样式 -->
|
||||
<Style x:Key="CancelBtnStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="#3A3A4A"/>
|
||||
<Setter Property="Foreground" Value="#B0B0B0"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||
<Setter Property="Padding" Value="24,10"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#4A4A5A"/>
|
||||
<Setter Property="Foreground" Value="#E0E0E0"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#2A2A3A"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="24">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- 页面标题栏 -->
|
||||
<Grid Grid.Row="0" Margin="0,0,0,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="16"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="设备信息" Style="{StaticResource TitleStyle}" Margin="0"/>
|
||||
|
||||
<TextBlock Grid.Column="2" Text="设备编号" Style="{StaticResource FormLabelStyle}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Column="4" x:Name="TxtQueryCode" Style="{StaticResource FormTextBoxStyle}" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBlock Grid.Column="6" Text="设备名称" Style="{StaticResource FormLabelStyle}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Column="8" x:Name="TxtQueryName" Style="{StaticResource FormTextBoxStyle}" VerticalAlignment="Center"/>
|
||||
|
||||
<Button Grid.Column="10" Content="查询" Style="{StaticResource QueryBtnStyle}" Click="BtnQuery_Click" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="12" Content="添加设备" Style="{StaticResource AddBtnStyle}" Click="BtnAdd_Click" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<DataGrid x:Name="DeviceGrid" Grid.Row="1" Style="{StaticResource DataGridStyle}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="设备编号" Binding="{Binding deviceCode}" Width="120">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="设备名称" Binding="{Binding deviceName}" Width="*">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="设备类型" Binding="{Binding deviceType, Converter={StaticResource DeviceTypeConverter}}" Width="100">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="设备状态" Binding="{Binding deviceStatus, Converter={StaticResource DeviceStatusConverter}}" Width="100">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="备注" Binding="{Binding remark}" Width="*">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<DataGridTextColumn Header="更新时间" Binding="{Binding updatedTime, StringFormat='{}{0:yyyy-MM-dd HH:mm}'}" Width="150">
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<DataGridTemplateColumn Header="操作" Width="140">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button Content="编辑" Style="{StaticResource EditBtnStyle}" Click="BtnEdit_Click"/>
|
||||
<Button Content="删除" Style="{StaticResource DeleteBtnStyle}" Click="BtnDelete_Click"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,117 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Sln.Wcs.Model.Domain;
|
||||
using Sln.Wcs.Repository.service;
|
||||
using Sln.Wcs.UI.Controls;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.BasicInfo.DeviceInfo
|
||||
{
|
||||
public partial class DeviceInfoPage : UserControl
|
||||
{
|
||||
private readonly IBaseDeviceInfoService _deviceInfoService;
|
||||
|
||||
public DeviceInfoPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_deviceInfoService = App.ServiceProvider.GetService<IBaseDeviceInfoService>();
|
||||
LoadData();
|
||||
}
|
||||
|
||||
public void LoadData()
|
||||
{
|
||||
var list = _deviceInfoService.Query();
|
||||
DeviceGrid.ItemsSource = list;
|
||||
}
|
||||
|
||||
private void BtnQuery_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var code = TxtQueryCode.Text?.Trim();
|
||||
var name = TxtQueryName.Text?.Trim();
|
||||
var list = _deviceInfoService.Query()
|
||||
.Where(d => string.IsNullOrEmpty(code) || d.deviceCode.Contains(code))
|
||||
.Where(d => string.IsNullOrEmpty(name) || (d.deviceName != null && d.deviceName.Contains(name)))
|
||||
.ToList();
|
||||
DeviceGrid.ItemsSource = list;
|
||||
}
|
||||
|
||||
private void BtnAdd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var window = new DeviceAddWindow(this);
|
||||
window.Owner = Window.GetWindow(this);
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
private void BtnEdit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DeviceGrid.SelectedItem is BaseDeviceInfo device)
|
||||
{
|
||||
var window = new DeviceEditWindow(this, device);
|
||||
window.Owner = Window.GetWindow(this);
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnDelete_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DeviceGrid.SelectedItem is BaseDeviceInfo device)
|
||||
{
|
||||
var result = CustomMessageBox.Show($"确认删除设备: {device.deviceName}?", "删除确认", MessageBoxButton.YesNo);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var success = _deviceInfoService.Delete(device);
|
||||
if (success)
|
||||
{
|
||||
CustomMessageBox.Show("删除成功", "提示", MessageBoxButton.OK);
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomMessageBox.Show("删除失败", "错误", MessageBoxButton.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DeviceTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
0 => "输送线",
|
||||
1 => "AGV",
|
||||
2 => "提升机",
|
||||
_ => "未知"
|
||||
};
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class DeviceStatusConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
0 => "正常",
|
||||
1 => "在忙",
|
||||
2 => "异常",
|
||||
_ => "未知"
|
||||
};
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="Sln.Wcs.UI.Page.Home.HomePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="1000">
|
||||
<Grid>
|
||||
<TextBlock Text="首页"
|
||||
FontSize="48"
|
||||
Foreground="#ECF0F1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,12 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sln.Wcs.UI.Page.Home
|
||||
{
|
||||
public partial class HomePage : UserControl
|
||||
{
|
||||
public HomePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue