Browse Source

料仓界面更新

master
taoye 2 years ago
parent
commit
d842615991
11 changed files with 617 additions and 14 deletions
  1. +7
    -0
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +18
    -0
      BPASmartClient.JXJFoodBigStation/Model/DeviceInfo.cs
  3. +117
    -0
      BPASmartClient.JXJFoodBigStation/View/ChangeDeviceNameView.xaml
  4. +31
    -0
      BPASmartClient.JXJFoodBigStation/View/ChangeDeviceNameView.xaml.cs
  5. +133
    -0
      BPASmartClient.JXJFoodBigStation/View/DeviceManageView.xaml
  6. +28
    -0
      BPASmartClient.JXJFoodBigStation/View/DeviceManageView.xaml.cs
  7. +187
    -13
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
  8. +2
    -0
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs
  9. +48
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/ChangeDeviceNameViewModel.cs
  10. +36
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/DeviceManageViewModel.cs
  11. +10
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs

+ 7
- 0
BPASmartClient.JXJFoodBigStation/App.xaml.cs View File

@@ -123,6 +123,13 @@ namespace BPASmartClient.JXJFoodBigStation
#region 硬件设备监控
ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "料仓管理",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.DeviceManageView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },


+ 18
- 0
BPASmartClient.JXJFoodBigStation/Model/DeviceInfo.cs View File

@@ -0,0 +1,18 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model
{
internal class DeviceInfo:ObservableObject
{
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
private string _mIpAddress;

public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;
}
}

+ 117
- 0
BPASmartClient.JXJFoodBigStation/View/ChangeDeviceNameView.xaml View File

@@ -0,0 +1,117 @@
<Window x:Class="BPASmartClient.JXJFoodBigStation.View.ChangeDeviceNameView"
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:BPASmartClient.JXJFoodBigStation.View"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
mc:Ignorable="d"
Title="ChangeDeviceNameView" Width="400"
Height="200"
AllowsTransparency="True"
Background="{x:Null}"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowStyle="None">
<Window.DataContext>
<vm:ChangeDeviceNameViewModel/>
</Window.DataContext>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />

<ResourceDictionary>
<!--#region ListBox样式-->
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="border" CornerRadius="8">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>

<Border
Name="br"
Background="#FF0B2F5F"
BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="0.5*" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="10,0,0,0"
Background="Transparent"
FontSize="20"
Foreground="#FF2AB2E7"
Text="请输入新设备名称:" />

<TextBox
Grid.Column="1"
Width="200"
Height="30"
Margin="0,0,7,0"
FontSize="16"
Text="{Binding DeviceName}" />

</StackPanel>

<TextBlock
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
FontSize="16"
Foreground="Red"
Text="{Binding ErrorInfo}" />

<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Button
Grid.Column="1"
Width="148"
Height="30"
Margin="0,0,7,0"
Command="{Binding ConfirmCommand}"
Content="确认" />

<Button
Name="btClose"
Width="148"
Height="30"
Command="{Binding CancleCommand}"
Content="取消" />

</Grid>

</Grid>
</Border>
</Window>

+ 31
- 0
BPASmartClient.JXJFoodBigStation/View/ChangeDeviceNameView.xaml.cs View File

@@ -0,0 +1,31 @@
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
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 BPASmartClient.JXJFoodBigStation.View
{
/// <summary>
/// ChangeDeviceNameView.xaml 的交互逻辑
/// </summary>
public partial class ChangeDeviceNameView : Window
{
public ChangeDeviceNameView()
{
InitializeComponent();
ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose");
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose");
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
}
}
}

+ 133
- 0
BPASmartClient.JXJFoodBigStation/View/DeviceManageView.xaml View File

@@ -0,0 +1,133 @@
<UserControl x:Class="BPASmartClient.JXJFoodBigStation.View.DeviceManageView"
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:BPASmartClient.JXJFoodBigStation.View"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:DeviceManageViewModel/>
</UserControl.DataContext>
<Grid Margin="-5,0,5,0">

<Grid>
<ListView
Grid.Column="1"
Margin="10"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding Devices}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border
Name="ShadowElement"
Width="180"
Height="150"
Margin="10"
VerticalAlignment="Top"
BorderBrush="#00BEFA"
BorderThickness="0"
ClipToBounds="True"
CornerRadius="0">
<Border.Background>
<ImageBrush Stretch="Fill" ImageSource="/BPASmartClient.CustomResource;component/Image/蓝色背景.png" />
</Border.Background>

<Grid Margin="20 0">

<!--<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>-->

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Grid.ColumnSpan="2"
Margin="0,10,0,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="#00BEFA"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="#aa00BEFA"
Text="设备IP:" />
<TextBlock
Grid.Row="1"
FontSize="14"
Foreground="#aa00BEFA"
Text="{Binding IpAddress}" />
</StackPanel>

<Button
Grid.Row="2"
Width="130"
Height="30"
Margin="0,0,0,0"
VerticalAlignment="Top"
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding IpAddress}"
Content="修改原料名称"
FontSize="16"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource ImageButtonStyle}" />

<!--<Button
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Foreground="#00BEFA"
Width="130"
Height="30"
Margin="0,0,0,10"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding IpAddress}"
Content="修改原料名称"
IsEnabled="{Binding IsEnable}">
<Button.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/系统名称.png" />
</Button.Background>
</Button>-->


</Grid>
</Border>

</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.JXJFoodBigStation/View/DeviceManageView.xaml.cs View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
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.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.JXJFoodBigStation.View
{
/// <summary>
/// DeviceManageView.xaml 的交互逻辑
/// </summary>
public partial class DeviceManageView : UserControl
{
public DeviceManageView()
{
InitializeComponent();
}
}
}

+ 187
- 13
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml View File

@@ -16,11 +16,8 @@
<vm:HardwareStatusViewModel />
</UserControl.DataContext>

<Grid>


<!--<Grid>

<!--#region 测试-->
<ListView
Height="150"
VerticalAlignment="Center"
@@ -57,15 +54,6 @@
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--#endregion-->








<UniformGrid Columns="10" Visibility="Collapsed">

<pry:MotorBottle
@@ -310,5 +298,191 @@
<RowDefinition />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
</Grid>-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>

<!--#region 顶部料仓-->
<Grid Name="TopGrid">
<ListView
Height="{Binding ElementName=TopGrid, Path=ActualHeight}"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding TopDeviceCurrentStatuses}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<!--<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>-->
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8"
Rows="1" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="0,0,0,35"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding Weight}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" kg" />
</StackPanel>


<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>

<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!--#endregion-->

<Grid x:Name="gr" Grid.Row="1" Margin="0,50,0,0">
<pry:ConveyorBelt
Grid.Row="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,30,0"
ConveyorBeltWidth="70"
Direction="1"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="#00BEFA"
StrokeThickness="2" />
</Grid>

<!--#region 底部料仓-->
<Grid Grid.Row="2">
<ListView
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding BottomDeviceCurrentStatuses}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="8"
Rows="1" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock
Margin="0,0,0,35"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding Weight}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" kg" />
</StackPanel>


<StackPanel
Grid.Row="1"
Margin="0,70,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
Text=" 号仓" />
</StackPanel>

<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!--#endregion-->

</Grid>
</UserControl>

+ 2
- 0
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs View File

@@ -24,5 +24,7 @@ namespace BPASmartClient.JXJFoodBigStation.View
{
InitializeComponent();
}

}
}

+ 48
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/ChangeDeviceNameViewModel.cs View File

@@ -0,0 +1,48 @@
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
internal class ChangeDeviceNameViewModel:ObservableObject
{
private static string IpAddress = string.Empty;

public RelayCommand ConfirmCommand { get; set; }

public RelayCommand CancleCommand { get; set; }


public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
private string _mErrorInfo;


public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;

public ChangeDeviceNameViewModel()
{
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null && o is string str) IpAddress = str;
}), "ChangeDeviceNameViewOpen");

CancleCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); });
ConfirmCommand = new RelayCommand(() =>
{
if (string.IsNullOrEmpty(DeviceName))
{
ErrorInfo = "设备名称不能为空";
return;
}
ActionManage.GetInstance.Send("ChangeDeviceNameViewClose");
});
}
}
}

+ 36
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/DeviceManageViewModel.cs View File

@@ -0,0 +1,36 @@
using BPA.Models.SqlEntity.BPA_Kitchen;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.JXJFoodBigStation.View;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
internal class DeviceManageViewModel:ObservableObject
{

public ObservableCollection<DeviceInfo> Devices { get; set; }=new ObservableCollection<DeviceInfo>() { new DeviceInfo {DeviceName="123",IpAddress="123.213.123.213." } };

public RelayCommand<object> ChangeNameCommand { get; set; }

public DeviceManageViewModel()
{
ChangeNameCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is string str)
{
ChangeDeviceNameView cdn = new ChangeDeviceNameView();
ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
cdn.ShowDialog();
}
});
}
}
}

+ 10
- 1
BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs View File

@@ -17,7 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public HardwareStatusViewModel()
{
for (int i = 0; i < 8; i++)
for (int i = 0; i <8; i++)
{
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
@@ -26,6 +26,15 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Weight = new Random().Next(0, 100)
});
}
for (int i = 8; i < 16; i++)
{
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
RunStatus = false,
Weight = new Random().Next(0, 100)
});
}
}

public ObservableCollection<DeviceCurrentStatus> TopDeviceCurrentStatuses { get; set; } = new ObservableCollection<DeviceCurrentStatus>();


Loading…
Cancel
Save