Browse Source

大配料站界面更新

master
taoye 2 years ago
parent
commit
0ab25e8903
4 changed files with 400 additions and 12 deletions
  1. +2
    -1
      BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs
  2. +176
    -10
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
  3. +220
    -1
      BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs
  4. +2
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs

+ 2
- 1
BPASmartClient.JXJFoodBigStation/Model/DeviceCurrentStatus.cs View File

@@ -21,7 +21,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;


public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }
private int _mDeviceNum;

}
}

+ 176
- 10
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml View File

@@ -15,7 +15,59 @@
<UserControl.DataContext>
<vm:HardwareStatusViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<PathGeometry x:Key="move" Figures="M 0,0 L 0,20"/>
<Storyboard x:Key="Open" >
<DoubleAnimationUsingPath Duration="0:0:1" PathGeometry="{StaticResource move}" RepeatBehavior="Forever" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[1].(Y)" Source="Y"></DoubleAnimationUsingPath>
</Storyboard>
<SolidColorBrush x:Key="ListBox.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Static.Border" Color="#FFABADB3"/>
<SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9"/>
<Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
<Setter Property="Background" Value="{StaticResource ListBox.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBox.Static.Border}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" SnapsToDevicePixels="true">
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<!--<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
</Trigger>-->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<!--<UserControl.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource Open}"></BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>-->
<!--<Grid>

<ListView
@@ -308,7 +360,8 @@

<!--#region 顶部料仓-->
<Grid Name="TopGrid">
<ListView
<ListView Style="{DynamicResource ListViewStyle1}"
x:Name="FListView"
Height="{Binding ElementName=TopGrid, Path=ActualHeight}"
VerticalAlignment="Center"
Background="Transparent"
@@ -331,8 +384,9 @@
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="0.45*"/>
<RowDefinition Height="0.45*"/>
<RowDefinition Height="0.1*"/>
</Grid.RowDefinitions>

<TextBlock
@@ -342,6 +396,23 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />
<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path" Tag="{Binding DeviceName}" Visibility="Collapsed" Fill="LightGreen" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</StackPanel>



<StackPanel
Grid.Row="1"
@@ -357,8 +428,9 @@
FontSize="20"
Foreground="#FF0084FF"
Text=" kg" />
</StackPanel>

<StackPanel
Grid.Row="1"
@@ -369,7 +441,6 @@
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding DeviceNum}" />

<TextBlock
FontSize="20"
Foreground="#FF0084FF"
@@ -381,6 +452,45 @@
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeCode}"
Tag="{Binding DeviceName}"
Click="IcoButton_Click"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeCode}"
Tag="{Binding DeviceName}"
Click="IcoButton_Click_1"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>

</Grid>
</Border>
</DataTemplate>
@@ -396,7 +506,7 @@
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="10,0,30,0"
ConveyorBeltWidth="70"
Direction="1"
Direction="2"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="#00BEFA"
@@ -406,6 +516,8 @@
<!--#region 底部料仓-->
<Grid Grid.Row="2">
<ListView
Style="{DynamicResource ListViewStyle1}"
x:Name="buttonListView"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
@@ -426,8 +538,9 @@
<Border Margin="5" Background="Transparent">
<Grid Height="220">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="0.45*"/>
<RowDefinition Height="0.45*"/>
<RowDefinition Height="0.1*"/>
</Grid.RowDefinitions>

<TextBlock
@@ -437,7 +550,21 @@
FontSize="25"
Foreground="#ffccd61f"
Text="{Binding DeviceName}" />

<StackPanel
Grid.RowSpan="2"
Panel.ZIndex="1"
Margin="55,100,0,0"
HorizontalAlignment="Center">

<Path x:Name="path1" Tag="{Binding DeviceName}" Visibility="Collapsed" Fill="LightGreen" Data="M -15,8 L 17,17 C 17,17 19,18 17,19 L 17,19 L -15,28 C -15,28 -17,28.2 -16,26 L -16,26 L -5,18 L -16,10 C -16,10 -17,8.5 -15,8 Z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="90"/>
<TranslateTransform Y="0"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</StackPanel>
<StackPanel
Grid.Row="1"
Margin="0,25,0,0"
@@ -475,6 +602,45 @@
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"
Stretch="Fill" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2">
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="5,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeCode}"
Tag="{Binding DeviceName}"
Click="IcoButton_Click_2"
Content="启动"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}"
/>
<pry:IcoButton
Width="80"
Height="{Binding ElementName=gr, Path=ActualHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.StopCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeCode}"
Tag="{Binding DeviceName}"
Click="IcoButton_Click_3"
Content="停止"
EnterBackground="#22F53F62"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />
</StackPanel>


</Grid>
</Border>


+ 220
- 1
BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml.cs View File

@@ -1,4 +1,6 @@
using System;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,6 +11,7 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
@@ -20,11 +23,227 @@ namespace BPASmartClient.JXJFoodBigStation.View
/// </summary>
public partial class HardwareStatusView : UserControl
{
Storyboard storyboard;
public HardwareStatusView()
{
InitializeComponent();
storyboard = Resources["Open"] as Storyboard;
ActionManage.GetInstance.Register(new Action<string>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}),"StartTopDevice" );

ActionManage.GetInstance.Register(new Action<string>((deviceName) => {
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName)

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopTopDevice");

ActionManage.GetInstance.Register(new Action<string>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}

}), "StartBottonDevice");

ActionManage.GetInstance.Register(new Action<string>((deviceName) => {
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag.ToString() == deviceName)

pt.Visibility = Visibility.Collapsed;
}
}

}), "StopBottonDevice");

}
//顶部启动下料动画
private void IcoButton_Click(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag&&storyboard!=null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}
}
}
}

//顶部停止下料动画
private void IcoButton_Click_1(object sender, RoutedEventArgs e)
{
foreach (var item in this.FListView.Items)
{
var myListBoxItem = (ListViewItem)FListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}
//底部启动下料动画
private void IcoButton_Click_2(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag && storyboard != null)
{
pt.Visibility = Visibility.Visible;
pt.BeginStoryboard(storyboard);
}

}
}
}
//底部停止下料动画
private void IcoButton_Click_3(object sender, RoutedEventArgs e)
{
foreach (var item in this.buttonListView.Items)
{
var myListBoxItem = (ListViewItem)buttonListView.ItemContainerGenerator.ContainerFromItem(item);

// Getting the ContentPresenter of myListBoxItem
var myContentPresenter = FindVisualChild<ContentPresenter>(myListBoxItem);

// Finding textBlock from the DataTemplate that is set on that ContentPresenter
DataTemplate myDataTemplate = myContentPresenter.ContentTemplate;

var obj = myDataTemplate.FindName("path1", myContentPresenter);
Path pt = obj as Path;
if (pt != null)
{
if (pt.Tag == (sender as IcoButton).Tag)

pt.Visibility = Visibility.Collapsed;
}
}
}

private childItem FindVisualChild<childItem>(DependencyObject obj)
where childItem : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
return (childItem)child;
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}
}
}

+ 2
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs View File

@@ -22,6 +22,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum=i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});
@@ -31,6 +32,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus()
{
DeviceName = i.ToString(),
DeviceNum = i,
RunStatus = false,
Weight = new Random().Next(0, 100)
});


Loading…
Cancel
Save