@@ -15,10 +15,6 @@ | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
BorderThickness="{TemplateBinding BorderThickness}" /> | |||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal"> | |||
<!--<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions>--> | |||
<TextBlock | |||
Name="PART_icoText" | |||
Margin="0,0,10,0" | |||
@@ -37,6 +33,13 @@ | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</StackPanel> | |||
</Grid> | |||
<!--<ControlTemplate.Triggers> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="PART_br" Property="BorderBrush" Value="{TemplateBinding EnableColor}" /> | |||
<Setter TargetName="PART_icoText" Property="Foreground" Value="red" /> | |||
<Setter TargetName="PART_content" Property="Foreground" Value="red" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers>--> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
@@ -72,6 +72,28 @@ namespace BPASmartClient.CustomResource.UserControls | |||
DependencyProperty.Register("Command", typeof(Action), typeof(IcoButton), | |||
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); | |||
public Action<object> CommandObj | |||
{ | |||
get { return (Action<object>)GetValue(CommandObjProperty); } | |||
set { SetValue(CommandObjProperty, value); } | |||
} | |||
public static readonly DependencyProperty CommandObjProperty = | |||
DependencyProperty.Register("CommandObj", typeof(Action<object>), typeof(IcoButton), | |||
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); | |||
//public object CommandPar | |||
//{ | |||
// get { return (object)GetValue(CommandParProperty); } | |||
// set { SetValue(CommandParProperty, value); } | |||
//} | |||
//public static readonly DependencyProperty CommandParProperty = | |||
// DependencyProperty.Register("CommandPar", typeof(object), typeof(IcoButton), | |||
// new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); | |||
public string Content | |||
{ | |||
get { return (string)GetValue(ContentProperty); } | |||
@@ -110,13 +132,29 @@ namespace BPASmartClient.CustomResource.UserControls | |||
new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(OnPropertyChanged))); | |||
public Brush EnableColor | |||
{ | |||
get { return (Brush)GetValue(EnableColorProperty); } | |||
set { SetValue(EnableColorProperty, value); } | |||
} | |||
public static readonly DependencyProperty EnableColorProperty = | |||
DependencyProperty.Register("EnableColor", typeof(Brush), typeof(IcoButton), | |||
new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(OnPropertyChanged))); | |||
public override void OnApplyTemplate() | |||
{ | |||
base.OnApplyTemplate(); | |||
var icon = base.GetTemplateChild("PART_icoText") as TextBlock; | |||
var content = base.GetTemplateChild("PART_content") as TextBlock; | |||
var gr = base.GetTemplateChild("PART_gr") as Grid; | |||
//if (!this.IsEnabled) | |||
//{ | |||
// this.Foreground = EnableColor; | |||
// this.BorderBrush = EnableColor; | |||
//} | |||
//this.IsEnabledChanged += IcoButton_IsEnabledChanged; | |||
if (icon != null) | |||
{ | |||
Binding binding = new Binding("IcoText"); | |||
@@ -141,6 +179,15 @@ namespace BPASmartClient.CustomResource.UserControls | |||
} | |||
} | |||
private void IcoButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) | |||
{ | |||
//if (!this.IsEnabled) | |||
//{ | |||
// this.Foreground = EnableColor; | |||
// this.BorderBrush = EnableColor; | |||
//} | |||
} | |||
/// <summary> | |||
/// 鼠标离开颜色 | |||
/// </summary> | |||
@@ -116,7 +116,7 @@ | |||
<MenuItem | |||
Click="Debug_Click" | |||
FontSize="12" | |||
Header="调试" | |||
Header="AGV控制" | |||
Tag="DebugView" /> | |||
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
namespace DosingSystem.Model | |||
{ | |||
public class LocaPar | |||
{ | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } = new ObservableCollection<RecipeModel>(); | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using DosingSystem.ViewModel; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace DosingSystem.Model | |||
{ | |||
public class RecipeModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 序号 | |||
/// </summary> | |||
public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } | |||
private int _mSerialNum; | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
/// <summary> | |||
/// 配方编码 | |||
/// </summary> | |||
public string RecipCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } | |||
private string _mRecipCode; | |||
public ObservableCollection<RawMaterial> RawMaterials { get; set; } = new ObservableCollection<RawMaterial>(); | |||
} | |||
} |
@@ -13,7 +13,7 @@ | |||
Height="800" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
Topmost="False" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
@@ -235,38 +235,6 @@ | |||
Foreground="#feffff" | |||
Text="{Binding WindowTitleName}" /> | |||
<!--<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<Button | |||
Grid.Row="0" | |||
Width="70" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Command="{Binding Login}" | |||
Content="账号修改" | |||
Cursor="Hand" /> | |||
<Button | |||
Name="login" | |||
Grid.Row="0" | |||
Width="45" | |||
Margin="5,0,5,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Command="{Binding Login}" | |||
Content="登录" | |||
Cursor="Hand" /> | |||
<Button | |||
Name="logout" | |||
Grid.Row="0" | |||
Width="45" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Top" | |||
Click="Button_LogOut" | |||
Command="{Binding LogoutCommand}" | |||
Content="注销" | |||
Cursor="Hand" /> | |||
</StackPanel>--> | |||
</Grid> | |||
<!--#region 底部窗体栏--> | |||
@@ -280,154 +248,4 @@ | |||
</Grid> | |||
</Border> | |||
<!--<Grid> | |||
--> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="pack://application:,,,/BPASmartClient.CustomResource;component/Image/界面2.png" /> | |||
</Grid.Background>--> | |||
<!-- | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
--> | |||
<!--#region 标题栏设置--> | |||
<!--<Border | |||
x:Name="MoveBorder" | |||
Height="50" | |||
VerticalAlignment="Top" | |||
BorderBrush="#55ffffff" | |||
BorderThickness="0,0,0,0"> | |||
<StackPanel Orientation="Horizontal"> | |||
<Image Margin="25 5 0 0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<TextBlock | |||
Name="tbTitle" | |||
Margin="20,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="配料控制系统" /> | |||
</StackPanel> | |||
</Border>--> | |||
<!-- | |||
<Border | |||
x:Name="MoveBorder" | |||
Height="50" | |||
VerticalAlignment="Top" | |||
Background="#0C2349" | |||
BorderBrush="#55ffffff" | |||
BorderThickness="0,0,0,1"> | |||
<StackPanel Orientation="Horizontal"> | |||
<Image Margin="25,5,0,0" Source="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||
<TextBlock | |||
Name="tbTitle" | |||
Margin="20,0" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="配料控制系统" /> | |||
</StackPanel> | |||
</Border> | |||
<UniformGrid | |||
Width="150" | |||
Height="50" | |||
HorizontalAlignment="Right" | |||
Columns="3"> | |||
<pry:IcoButton | |||
Name="ButMin" | |||
Content="" | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
<pry:IcoButton | |||
Name="ButMax" | |||
Content="" | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
<pry:IcoButton | |||
Name="ButClose" | |||
Content="" | |||
Style="{StaticResource IcoTitleBarStyle}" /> | |||
</UniformGrid> | |||
--> | |||
<!--#endregion--> | |||
<!--#region 内容区域--> | |||
<!-- | |||
<Grid Grid.Row="1"> | |||
--> | |||
<!--<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" /> | |||
</Grid.Background>--> | |||
<!-- | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.15*" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" /> | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition Height="0.1*"/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<RadioButton Grid.Row="0" Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="1" Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="2" Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="3" Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Grid.Row="4" Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
</Grid> | |||
--> | |||
<!--<StackPanel> | |||
<StackPanel.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/leftback.png" Opacity="0.8" /> | |||
</StackPanel.Background> | |||
<RadioButton Content="配方设置" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="设备列表" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="硬件状态" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="报警记录" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<RadioButton Content="配方控制" Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
</StackPanel>--> | |||
<!-- | |||
<Grid Grid.Column="1"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/WindowImages.png" /> | |||
</Grid.Background> | |||
<TextBlock | |||
Margin="0,10,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#1A8ADE" | |||
Text="配方设置" /> | |||
</Grid> | |||
</Grid> | |||
--> | |||
<!--#endregion--> | |||
<!-- | |||
</Grid>--> | |||
</Window> |
@@ -0,0 +1,203 @@ | |||
<Window | |||
x:Class="DosingSystem.View.NewRecipeView" | |||
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:local="clr-namespace:DosingSystem.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:vm="clr-namespace:DosingSystem.ViewModel" | |||
Title="NewRecipeView" | |||
Width="550" | |||
Height="450" | |||
AllowsTransparency="True" | |||
Background="{x:Null}" | |||
Topmost="True" | |||
WindowStartupLocation="CenterScreen" | |||
WindowStyle="None" | |||
mc:Ignorable="d"> | |||
<Window.DataContext> | |||
<vm:NewRecipeViewModel /> | |||
</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" BorderThickness="1"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/bg.png" /> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Button | |||
Name="btClose" | |||
Margin="0,0,5,0" | |||
Padding="10,5" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
Content="X" | |||
FontSize="18" | |||
Foreground="White" /> | |||
<Grid Grid.Row="1"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
Background="Transparent" | |||
FontSize="20" | |||
Foreground="#ddd" | |||
Text="请输入配方名称:" /> | |||
<TextBlock | |||
Margin="0,0,10,0" | |||
HorizontalAlignment="Right" | |||
Background="Transparent" | |||
FontSize="16" | |||
Foreground="Red" | |||
Text="{Binding ErrorInfo}" /> | |||
<StackPanel | |||
Grid.Row="1" | |||
Margin="10,0,0,0" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Name="tbTitle" | |||
Grid.Column="1" | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
FontSize="16" | |||
Text="{Binding RecipeName}" /> | |||
<Button | |||
Width="148" | |||
Height="30" | |||
Margin="0,0,7,0" | |||
Command="{Binding AddCommand}" | |||
Content="添加原料" /> | |||
<Button | |||
Width="148" | |||
Height="30" | |||
Command="{Binding SaveCommand}" | |||
Content="保存配方" /> | |||
</StackPanel> | |||
<ScrollViewer Grid.Row="2" Margin="5"> | |||
<ItemsControl ItemsSource="{Binding RawMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="40"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
BorderBrush="#FF074B92" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="#FF2AB2E7" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.RawMaterialNames, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedIndex="0" | |||
Style="{StaticResource ComboBoxStyle}" | |||
Text="{Binding RawMaterialName}" /> | |||
<StackPanel | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Name="tb" | |||
Grid.Column="1" | |||
Width="150" | |||
Height="29" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="{Binding RawMaterialWeight}" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Margin="0,0,8,4" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Text="mg" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Column="2" | |||
Margin="10,0,10,0" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RawMaterialId}" | |||
Content="删除" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</Window> |
@@ -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 DosingSystem.View | |||
{ | |||
/// <summary> | |||
/// NewRecipeView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class NewRecipeView : Window | |||
{ | |||
public NewRecipeView() | |||
{ | |||
InitializeComponent(); | |||
this.btClose.Click += (o, e) => { this.Close(); }; | |||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | |||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseNewRecipeView"); | |||
} | |||
} | |||
} |
@@ -12,16 +12,244 @@ | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />--> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
<Style x:Key="buttonStyle" TargetType="Button"> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="FontSize" Value="16" /> | |||
<Setter Property="Foreground" Value="Aqua" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:RecipeSettingsViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="40" | |||
Foreground="Wheat" | |||
Text="配方设置" /> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50" /> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 操作按钮--> | |||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding NewRecipe}" | |||
Content="新建配方" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
IcoText="" | |||
Style="{StaticResource NewButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="3" | |||
Width="140" | |||
Margin="10" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SaveRecipe}" | |||
Content="保存配方" | |||
EnableColor="#FFB7B7B7" | |||
FontSize="17" | |||
Foreground="Aqua" | |||
IcoText="" | |||
IsEnabled="True" | |||
Style="{StaticResource NewButtonStyle}" /> | |||
</StackPanel> | |||
<!--#endregion--> | |||
<!--#region 表格标题栏设置--> | |||
<!--<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="序号" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="配方名称" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="编码" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="结束时间" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Grid Grid.Column="5"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="制作状态" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="6" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="完成时间" /> | |||
</Grid>--> | |||
<!--#endregion--> | |||
<!--#region 表格数据显示--> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding Recipes}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton Background="Transparent" GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding SerialNum}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Left" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipeName}" /> | |||
<!--<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />--> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipCode}" /> | |||
<Grid Grid.Column="3"> | |||
<Button | |||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="编辑" | |||
Style="{StaticResource buttonStyle}" /> | |||
<!--<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" />--> | |||
</Grid> | |||
<Grid Grid.Column="5"> | |||
<Button | |||
Command="{Binding DataContext.LookCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="查看" | |||
Style="{StaticResource buttonStyle}" /> | |||
<!--<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />--> | |||
</Grid> | |||
<Grid Grid.Column="6"> | |||
<Button | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="删除" | |||
Style="{StaticResource buttonStyle}" /> | |||
<!--<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="0,0,1,0" />--> | |||
</Grid> | |||
<!--<Border | |||
Grid.ColumnSpan="8" | |||
BorderBrush="{StaticResource BorderSolid}" | |||
BorderThickness="1,1,1,1" />--> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -53,9 +53,10 @@ namespace DosingSystem.ViewModel | |||
Config.GetInstance.Init(); | |||
LoginRegister(); | |||
MenuInit(); | |||
permission = Permission.观察员; | |||
permission = Permission.管理员; | |||
if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); | |||
} | |||
private void LoginRegister() | |||
@@ -0,0 +1,111 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.Helper; | |||
using DosingSystem.Model; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class NewRecipeViewModel : ObservableObject | |||
{ | |||
public NewRecipeViewModel() | |||
{ | |||
RawMaterialNames.Clear(); | |||
for (int i = 0; i < 10; i++) | |||
{ | |||
RawMaterialNames.Add($"原料{i}"); | |||
} | |||
AddCommand = new RelayCommand(() => | |||
{ | |||
p: | |||
string guid = Guid.NewGuid().ToString(); | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | |||
{ | |||
RawMaterials.Add(new RawMaterial() | |||
{ | |||
RawMaterialId = guid | |||
}); | |||
} | |||
else goto p; | |||
}); | |||
RemoveCommand = new RelayCommand<object>((obj) => | |||
{ | |||
if (obj is string rm) | |||
{ | |||
var res = RawMaterials.FirstOrDefault(p => p.RawMaterialId == rm); | |||
if (res != null) RawMaterials.Remove(res); | |||
} | |||
}); | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
var res = Array.FindIndex(Json<LocaPar>.Data.Recipes.ToArray(), p => p.RecipeName == RecipeName); | |||
if (res >= 0 && res < Json<LocaPar>.Data.Recipes.Count) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(res).RecipeName = RecipeName; | |||
Json<LocaPar>.Data.Recipes.ElementAt(res).RawMaterials = RawMaterials; | |||
} | |||
else | |||
{ | |||
string date = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); | |||
var dates = date.Split("-").ToList(); | |||
StringBuilder sb = new StringBuilder(); | |||
dates?.ForEach((item) => { sb.Append(item); }); | |||
Json<LocaPar>.Data.Recipes.Add(new RecipeModel() | |||
{ | |||
SerialNum = Json<LocaPar>.Data.Recipes.Count + 1, | |||
RawMaterials = RawMaterials, | |||
RecipCode = sb.ToString(), | |||
RecipeName = RecipeName | |||
}); | |||
} | |||
ActionManage.GetInstance.Send("CloseNewRecipeView"); | |||
}); | |||
} | |||
public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } | |||
private string _mRecipeName; | |||
public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||
private string _mErrorInfo; | |||
public RelayCommand AddCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
public RelayCommand SaveCommand { get; set; } | |||
public ObservableCollection<RawMaterial> RawMaterials { get; set; } = new ObservableCollection<RawMaterial>(); | |||
public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | |||
} | |||
public class RawMaterial : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
/// <summary> | |||
/// 原料重量 | |||
/// </summary> | |||
public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } | |||
private float _mRawMaterialWeight; | |||
/// <summary> | |||
/// 原料ID | |||
/// </summary> | |||
public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialId; | |||
} | |||
} |
@@ -9,9 +9,31 @@ using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using DosingSystem.Model; | |||
using DosingSystem.View; | |||
namespace DosingSystem.ViewModel | |||
{ | |||
public class RecipeSettingsViewModel : ObservableObject | |||
{ | |||
public RecipeSettingsViewModel() | |||
{ | |||
Json<LocaPar>.Read(); | |||
Recipes = Json<LocaPar>.Data.Recipes; | |||
NewRecipe = new Action(() => | |||
{ | |||
NewRecipeView nrv = new NewRecipeView(); | |||
nrv.ShowDialog(); | |||
}); | |||
SaveRecipe = new Action(() => { Json<LocaPar>.Save(); }); | |||
} | |||
public Action NewRecipe { get; set; } | |||
public Action SaveRecipe { get; set; } | |||
public RelayCommand<object> EditCommand { get; set; } | |||
public RelayCommand<object> LookCommand { get; set; } | |||
public RelayCommand<object> RemoveCommand { get; set; } | |||
public ObservableCollection<RecipeModel> Recipes { get; set; } | |||
} | |||
} |