@@ -1,13 +1,16 @@ | |||
using System; | |||
| |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
{ | |||
public class LocalRecipes | |||
public class LocalRecipes | |||
{ | |||
public ObservableCollection<Recipes> locaRecipes { get; set; } = new ObservableCollection<Recipes>(); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
{ | |||
public class Order:ObservableObject | |||
{ | |||
/// <summary> | |||
/// 订单ID | |||
/// </summary> | |||
public string OrderId { get { return _orderId; } set { _orderId = value; OnPropertyChanged(); } } | |||
private string _orderId; | |||
/// <summary> | |||
/// 下单时间 | |||
/// </summary> | |||
public string OrderdateTime { get { return _orderDateTime; } set { _orderDateTime = value; OnPropertyChanged(); } } | |||
private string _orderDateTime; | |||
/// <summary> | |||
/// 订单完成时间 | |||
/// </summary> | |||
public string OrderCompeleteTime { get { return _orderCompeleteTime; } set { _orderCompeleteTime = value; OnPropertyChanged(); } } | |||
private string _orderCompeleteTime; | |||
/// <summary> | |||
/// 配方集合 | |||
/// </summary> | |||
public ObservableCollection<Recipes> Recipes { get; set; } = new ObservableCollection<Recipes>(); | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using System; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
@@ -7,8 +8,43 @@ using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
{ | |||
public class Recipes | |||
public class Recipes:ObservableObject | |||
{ | |||
public ObservableCollection<RecipeMaterials> Materials { get; set; } | |||
/// <summary> | |||
/// 配方ID | |||
/// </summary> | |||
public string ID { get { return _id; } set { _id = value; OnPropertyChanged(); } } | |||
private string _id; | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string Name { get { return _name; } set { _name = value; OnPropertyChanged(); } } | |||
public string _name; | |||
/// <summary> | |||
/// 配方状态 | |||
/// </summary> | |||
public RecipeStates RecipeState { get { return _recipeState; } set { _recipeState = value; OnPropertyChanged(); } } | |||
public RecipeStates _recipeState; | |||
/// <summary> | |||
/// 配方单数 | |||
/// </summary> | |||
public int RecipeCount { get { return _recipeCount; } set { _recipeCount = value; OnPropertyChanged(); } } | |||
private int _recipeCount; | |||
/// <summary> | |||
/// 配方原料集合 | |||
/// </summary> | |||
public ObservableCollection<RecipeMaterials> recipeMaterials { get; set; } | |||
} | |||
public enum RecipeStates | |||
{ | |||
等待制作 = 0, | |||
制作中 = 1, | |||
制作完成 = 2 | |||
} | |||
} | |||
@@ -4,6 +4,272 @@ | |||
xmlns:local="clr-namespace:BPASmart.RecipeManagement" | |||
StartupUri="MainWindow.xaml"> | |||
<Application.Resources> | |||
<Style TargetType="{x:Type ContextMenu}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ContextMenu}"> | |||
<Border x:Name="Border" CornerRadius="4" Background="#009ACD" BorderThickness="1" Margin="0"> | |||
<Border.BorderBrush> | |||
<SolidColorBrush Color="#104E8B" /> | |||
</Border.BorderBrush> | |||
<ItemsPresenter/> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsMouseOver" Value="True"/> | |||
</MultiTrigger.Conditions> | |||
<MultiTrigger.EnterActions> | |||
<BeginStoryboard> | |||
<Storyboard> | |||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Width)"> | |||
<SplineDoubleKeyFrame KeyTime="00:00:00.0020000" Value="0"/> | |||
<SplineDoubleKeyFrame KeyTime="00:00:00.20000" Value="110"/> | |||
</DoubleAnimationUsingKeyFrames> | |||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Height)"> | |||
<SplineDoubleKeyFrame KeyTime="00:00:00.0020000" Value="0"/> | |||
<SplineDoubleKeyFrame KeyTime="00:00:00.20000" Value="100"/> | |||
</DoubleAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</MultiTrigger.EnterActions> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style TargetType="{x:Type MenuItem}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type MenuItem}"> | |||
<Border Margin="0,5" MinWidth="80" CornerRadius="5"> | |||
<Border.Background> | |||
<SolidColorBrush x:Name="MyAnimatedBrushBackground" Color="Transparent" /> | |||
</Border.Background> | |||
<StackPanel Orientation="Horizontal"> | |||
<TextBlock Text=" "/> | |||
<ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
<TextBlock Text=" "/> | |||
<ContentPresenter ContentSource="Header" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsMouseOver" Value="True"/> | |||
</MultiTrigger.Conditions> | |||
<MultiTrigger.EnterActions> | |||
<BeginStoryboard> | |||
<Storyboard> | |||
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MyAnimatedBrushBackground" Storyboard.TargetProperty="Color"> | |||
<LinearColorKeyFrame Value="Transparent" KeyTime="00:00:00.0020000" /> | |||
<LinearColorKeyFrame Value="#B0E2FF" KeyTime="00:00:00.0320000" /> | |||
</ColorAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</MultiTrigger.EnterActions> | |||
<MultiTrigger.ExitActions> | |||
<BeginStoryboard> | |||
<Storyboard> | |||
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MyAnimatedBrushBackground" Storyboard.TargetProperty="Color"> | |||
<LinearColorKeyFrame Value="#7E9C9C9C" KeyTime="00:00:00.0020000" /> | |||
<LinearColorKeyFrame Value="Transparent" KeyTime="00:00:00.0320000" /> | |||
</ColorAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</MultiTrigger.ExitActions> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> | |||
<Grid Height="25" HorizontalAlignment="Stretch" Background="Transparent"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*" /> | |||
<ColumnDefinition Width="30" /> | |||
</Grid.ColumnDefinitions> | |||
<Border | |||
Grid.ColumnSpan="2" | |||
Background="White" | |||
Opacity="0" /> | |||
<Path | |||
x:Name="Arrow" | |||
Grid.Column="1" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Data="M 0 0 6 6 12 0 Z" | |||
Fill="Black" | |||
Stretch="None"> | |||
<Path.Effect> | |||
<DropShadowEffect | |||
BlurRadius="10" | |||
Direction="90" | |||
Opacity="1" | |||
RenderingBias="Quality" | |||
ShadowDepth="0" | |||
Color="Transparent" /> | |||
</Path.Effect> | |||
</Path> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="true"> | |||
<Setter TargetName="Arrow" Property="RenderTransform"> | |||
<Setter.Value> | |||
<RotateTransform Angle="180" CenterX="6" CenterY="3" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="Arrow" Property="Margin" Value="0,0,0,2" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
<Style TargetType="{x:Type ComboBox}"> | |||
<Setter Property="BorderThickness" Value="1" /> | |||
<Setter Property="Background" Value="White"/> | |||
<Setter Property="ItemContainerStyle"> | |||
<Setter.Value> | |||
<Style TargetType="ComboBoxItem"> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ComboBoxItem}"> | |||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> | |||
<Border x:Name="_borderbg" Background="White" /> | |||
<TextBlock | |||
x:Name="_txt" | |||
Margin="5,0,3,0" | |||
FontWeight="Black" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" /> | |||
<Border | |||
x:Name="_border" | |||
Background="White" | |||
Opacity="0" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsSelected" Value="false" /> | |||
<Condition Property="IsMouseOver" Value="true" /> | |||
</MultiTrigger.Conditions> | |||
<Setter TargetName="_borderbg" Property="Background" Value="#AFEEEE" /> | |||
<Setter TargetName="_txt" Property="Foreground" Value="black" /> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ComboBox}"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.3*" MaxWidth="30" /> | |||
</Grid.ColumnDefinitions> | |||
<Border | |||
x:Name="_prybr" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
BorderThickness="{TemplateBinding BorderThickness}" | |||
CornerRadius="0" /> | |||
<ContentPresenter | |||
x:Name="ContentSite" | |||
Margin="3,3,0,3" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding SelectionBoxItem}" | |||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" | |||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" | |||
IsHitTestVisible="False" /> | |||
<!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen --> | |||
<ToggleButton | |||
x:Name="ToggleButton" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
ClickMode="Press" | |||
Focusable="false" | |||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||
Template="{StaticResource ComboBoxToggleButton}" /> | |||
<!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 --> | |||
<TextBox | |||
x:Name="PART_EditableTextBox" | |||
Margin="2,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="White" | |||
BorderThickness="0" | |||
CaretBrush="{TemplateBinding Foreground}" | |||
Focusable="True" | |||
Foreground="{TemplateBinding Foreground}" | |||
IsReadOnly="{TemplateBinding IsReadOnly}" | |||
Visibility="Hidden" /> | |||
<!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen --> | |||
<Popup | |||
x:Name="Popup" | |||
AllowsTransparency="True" | |||
Focusable="False" | |||
IsOpen="{TemplateBinding IsDropDownOpen}" | |||
Placement="Bottom" | |||
PopupAnimation="Slide"> | |||
<Grid | |||
x:Name="DropDown" | |||
MinWidth="{TemplateBinding ActualWidth}" | |||
MaxHeight="150" | |||
SnapsToDevicePixels="True"> | |||
<Border | |||
x:Name="DropDownBorder" | |||
BorderBrush="Black" | |||
BorderThickness="0" /> | |||
<ScrollViewer | |||
Margin="1" | |||
CanContentScroll="True" | |||
HorizontalScrollBarVisibility="Auto" | |||
SnapsToDevicePixels="True" | |||
VerticalScrollBarVisibility="Auto"> | |||
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True --> | |||
<!-- 一下可以设置列表背景色 --> | |||
<StackPanel | |||
Background="White" | |||
IsItemsHost="True" | |||
KeyboardNavigation.DirectionalNavigation="Contained" /> | |||
</ScrollViewer> | |||
</Grid> | |||
</Popup> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsEditable" Value="true"> | |||
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="ContentSite" Property="Opacity" Value="0.6" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Application.Resources> | |||
</Application> |
@@ -15,9 +15,37 @@ | |||
<Page Remove="新文件夹1\**" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Remove="Image\AddGreen.png" /> | |||
<None Remove="Image\Delete.png" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Update="View\RecipesConfigure.xaml.cs"> | |||
<SubType>Code</SubType> | |||
</Compile> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Page Update="View\RecipesConfigure.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
<SubType>Designer</SubType> | |||
</Page> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="Image\Delete.png"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</Resource> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="Image\AddGreen.png" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,6 +1,7 @@ | |||
using BPASmart.Model.配方; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -10,5 +11,9 @@ namespace BPASmart.RecipeManagement.Globle | |||
public class GlobleData | |||
{ | |||
public static RecipeMaterials ChangeMaterail; | |||
public static Recipes ChangeRecipes; | |||
public static ObservableCollection<Order> orders { get; set; } = new ObservableCollection<Order>(); | |||
} | |||
} |
@@ -7,7 +7,7 @@ | |||
xmlns:view="clr-namespace:BPASmart.RecipeManagement.View" | |||
xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
Title="MainWindow" Height="900" Width="1600" WindowStyle="None" WindowStartupLocation="CenterScreen"> | |||
Title="MainWindow" Height="900" Width="1400" WindowStyle="None" WindowStartupLocation="CenterScreen"> | |||
<Window.DataContext> | |||
<vm:MainWindowViewModel/> | |||
</Window.DataContext> | |||
@@ -81,14 +81,16 @@ | |||
<StackPanel x:Name="mylistview" Background="#2196F3" Grid.RowSpan="2" | |||
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" | |||
MouseDown="mylistview_MouseDown" > | |||
<RadioButton Content="配方管理" Style="{DynamicResource RadioNavigation}" IsChecked="True" | |||
Click="NavButton_Click" Tag=""/> | |||
<RadioButton Content="订单管理" Style="{DynamicResource RadioNavigation}" IsChecked="True" | |||
Click="NavButton_Click" Tag="OrderManager"/> | |||
<RadioButton Content="配方管理" Style="{DynamicResource RadioNavigation}" | |||
Click="NavButton_Click" Tag="RecipeManager"/> | |||
<RadioButton Content="原料管理" Style="{DynamicResource RadioNavigation}" | |||
Click="NavButton_Click" Tag=""/> | |||
Click="NavButton_Click" Tag="MaterialManager"/> | |||
<RadioButton Content="工艺参数" Style="{DynamicResource RadioNavigation}" | |||
Click="NavButton_Click" Tag=""/> | |||
Click="NavButton_Click" Tag="TechnologySetting"/> | |||
<RadioButton Content="权限分配" Style="{DynamicResource RadioNavigation}" | |||
Click="NavButton_Click" Tag=""/> | |||
Click="NavButton_Click" Tag="PowerManager"/> | |||
</StackPanel> | |||
<Border Background="#2196F3" Grid.Row="2"> | |||
<Button Content="退出" | |||
@@ -98,7 +100,7 @@ | |||
</Button> | |||
</Border> | |||
<ContentControl x:Name="contentRegion" Grid.Column="1" Grid.Row="1" > | |||
<view:MaterialManager/> | |||
<view:PowerManager/> | |||
</ContentControl> | |||
</Grid> | |||
</Border> | |||
@@ -40,16 +40,13 @@ namespace BPASmart.RecipeManagement | |||
private void NavButton_Click(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (sender is Button bt) | |||
if (sender is RadioButton bt) | |||
{ | |||
Type type = Type.GetType($"BPASmartClient.MilkWithTea.View.{bt.Tag?.ToString()}"); | |||
Type type = Type.GetType($"BPASmart.RecipeManagement.View.{bt.Tag?.ToString()}"); | |||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); | |||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -0,0 +1,112 @@ | |||
<Window x:Class="BPASmart.RecipeManagement.View.CreateOrder" | |||
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:BPASmart.RecipeManagement.View" | |||
xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
Title="CreateOrder" Height="250" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="White" MouseLeftButtonDown="Window_MouseLeftButtonDown"> | |||
<Window.DataContext> | |||
<vm:CreateOrderViewModel/> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
</Window.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="40"/> | |||
</Grid.RowDefinitions> | |||
<Button Content="增加配方" Width="100" Height="30" HorizontalAlignment="Right" Margin="10,0" | |||
Background="#58B0ED" Foreground="White" Command="{Binding AddRecipeCommand}"/> | |||
<Border Grid.Row="1" BorderBrush="#B0E2FF" BorderThickness="0,1"> | |||
<ItemsControl ItemsSource="{Binding recipes}" Grid.Row="1" HorizontalAlignment="Center"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="40"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="150"/> | |||
<ColumnDefinition Width="100" /> | |||
<ColumnDefinition Width="60" /> | |||
</Grid.ColumnDefinitions> | |||
<ComboBox | |||
Name="cb" | |||
Grid.Column="0" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
BorderBrush="Black" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Black" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.recipesName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
SelectedItem="{Binding Name}" | |||
/> | |||
<StackPanel | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Name="tb" | |||
Grid.Column="1" | |||
Width="60" | |||
Height="29" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="{Binding RecipeCount}" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Margin="0,0,8,4" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="单" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Column="2" | |||
Width="50" | |||
Height="24" | |||
Foreground="White" | |||
FontSize="14" | |||
Background="#58B0ED" | |||
Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}" | |||
CommandParameter="{Binding ID}" | |||
Content="删 除" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Border> | |||
<StackPanel Grid.Row="4" Grid.ColumnSpan="3" Orientation="Horizontal" | |||
HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Button Content="保存" Foreground="White" FontSize="22" Width="120" Height="30" Margin="10,2" Background="#58B0ED" | |||
Command="{Binding SaveCommand}"/> | |||
<Button Content="取消" Foreground="White" FontSize="22" Width="120" Height="30" Margin="10,2" Background="#58B0ED" | |||
Click="Button_Click"/> | |||
</StackPanel> | |||
</Grid> | |||
</Window> |
@@ -0,0 +1,37 @@ | |||
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 BPASmart.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// CreateOrder.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class CreateOrder : Window | |||
{ | |||
public CreateOrder() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
{ | |||
this.DragMove(); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
{ | |||
this.Close(); | |||
} | |||
} | |||
} |
@@ -11,162 +11,9 @@ | |||
<vm:MaterialConfigureViewModel/> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<Style TargetType="{x:Type ComboBox}"> | |||
<Setter Property="Background" Value="White"/> | |||
<Setter Property="ItemContainerStyle"> | |||
<Setter.Value> | |||
<!--ComBoxItem--> | |||
<Style TargetType="ComboBoxItem"> | |||
<Setter Property="MinHeight" Value="22"></Setter> | |||
<Setter Property="MinWidth" Value="60"></Setter> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ComboBoxItem"> | |||
<Border Name="Back" Background="Transparent" BorderThickness="0,0,0,0" BorderBrush="#81D779" > | |||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="Back" Property="Background" Value="LightGray"></Setter> | |||
</Trigger> | |||
<Trigger Property="IsHighlighted" Value="True"> | |||
<Setter TargetName="Back" Property="Background" Value="LightGray"></Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ComboBox}"> | |||
<Border BorderThickness="1" BorderBrush="#CDC9C9 " CornerRadius="3" Width="{TemplateBinding Width}" Height="40" Background="{TemplateBinding Background}" > | |||
<Grid > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="3*"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid Grid.Column="0" x:Name="grid"> | |||
<ToggleButton | |||
Width="{Binding ElementName=grid,Path=ActualWidth}" | |||
Height="{Binding ElementName=grid, Path=ActualHeight}" | |||
Content="{TemplateBinding Text}" VerticalAlignment="Center" | |||
HorizontalAlignment="Left" Margin="5,0,0,0" | |||
BorderThickness="0" | |||
Foreground="{TemplateBinding Foreground}" | |||
Background="{TemplateBinding Background}" | |||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press" | |||
> | |||
<ToggleButton.Style > | |||
<Style TargetType="ToggleButton"> | |||
<Setter Property="Background" Value="White"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ToggleButton"> | |||
<Border Background="{TemplateBinding Background}" BorderThickness="0" > | |||
<TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" Margin="4 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center"/> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
<Style.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter Property="Background" Value="White"/> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter Property="Background" Value="White"/> | |||
</Trigger> | |||
</Style.Triggers> | |||
</Style> | |||
</ToggleButton.Style> | |||
</ToggleButton> | |||
</Grid> | |||
<Grid Grid.Column="1" > | |||
<ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||
Foreground="{TemplateBinding Foreground}" | |||
ClickMode="Press"> | |||
<ToggleButton.Style> | |||
<Style TargetType="ToggleButton"> | |||
<Setter Property="Background" Value="White"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ToggleButton"> | |||
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"> | |||
<Grid> | |||
<Image Source="pack://application:,,,/image/down,png" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Image.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform/> | |||
<SkewTransform/> | |||
<RotateTransform/> | |||
<TranslateTransform/> | |||
</TransformGroup> | |||
</Image.RenderTransform> | |||
</Image> | |||
</Grid> | |||
</Border> | |||
<!--<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
</Trigger> | |||
<EventTrigger RoutedEvent="Checked"> | |||
<BeginStoryboard> | |||
<Storyboard > | |||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="arrow_tb" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"> | |||
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/> | |||
<EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="180"/> | |||
</DoubleAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</EventTrigger> | |||
<EventTrigger RoutedEvent="Unchecked"> | |||
<BeginStoryboard> | |||
<Storyboard > | |||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="arrow_tb" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"> | |||
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="180"/> | |||
<EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/> | |||
</DoubleAnimationUsingKeyFrames> | |||
</Storyboard> | |||
</BeginStoryboard> | |||
</EventTrigger> | |||
</ControlTemplate.Triggers>--> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</ToggleButton.Style> | |||
</ToggleButton> | |||
</Grid> | |||
<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide"> | |||
<Border CornerRadius="1" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True"> | |||
<Border.Effect> | |||
<DropShadowEffect Color="Black" BlurRadius="2" ShadowDepth="0" Opacity="0.5"/> | |||
</Border.Effect> | |||
<ScrollViewer Margin="4,6,4,6" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True"> | |||
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True --> | |||
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="White"/> | |||
</ScrollViewer> | |||
</Border> | |||
</Popup> | |||
</Grid> | |||
<Border.Effect> | |||
<DropShadowEffect ShadowDepth="-1" Opacity="0.3" Color="#FF969696" BlurRadius="5"/> | |||
</Border.Effect> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Window.Resources> | |||
<Border CornerRadius="20" Background="#FFFAFA"> | |||
<Border CornerRadius="20" Background="White"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="17*"/> | |||
@@ -188,7 +35,7 @@ | |||
<TextBox Text="{Binding MaterialName}" FontSize="22" Grid.Column="1" Width="200" Height="40" | |||
VerticalAlignment="Center" HorizontalAlignment="Center" | |||
VerticalContentAlignment="Center"/> | |||
<ComboBox ItemsSource="{Binding MaterialTypes}" | |||
<ComboBox ItemsSource="{Binding MaterialTypes}" | |||
FontSize="18" | |||
Grid.Column="1" Grid.Row="1" Width="200" Height="40" | |||
SelectedItem="{Binding MaterialType}"/> | |||
@@ -14,9 +14,7 @@ | |||
<Style TargetType="ListViewItem" > | |||
<Setter Property="Margin" Value="60,20"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ListViewItem"> | |||
<Border x:Name="mborder" BorderBrush="#009AC0" BorderThickness="1,5" CornerRadius="10"> | |||
@@ -179,18 +177,7 @@ | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
<!--<ContextMenu> | |||
<ContextMenu FontSize="16" Foreground="White"> | |||
<MenuItem Header="新建原料" Name="MenuCreate" | |||
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.CreateMaterailCommand}"></MenuItem> | |||
<MenuItem Header="编辑原料" Name="MenuEdit" | |||
Command="{Binding RelativeSource={RelativeSource Mode= FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.EditMaterailCommand}" | |||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListView}},Path=SelectedItem}"></MenuItem> | |||
<MenuItem Header="删除原料" Name="MenuDelete" | |||
Command="{Binding RelativeSource={RelativeSource Mode= FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.DeleteMaterailCommand}" | |||
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListView}},Path=SelectedItem}"></MenuItem> | |||
</ContextMenu> | |||
</ContextMenu>--> | |||
</ListView> | |||
</Grid> | |||
@@ -0,0 +1,179 @@ | |||
<UserControl x:Class="BPASmart.RecipeManagement.View.OrderManager" | |||
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:BPASmart.RecipeManagement.View" | |||
xmlns:vm ="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:OrderManagerViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style TargetType="ListBoxItem"> | |||
<Setter Property="Margin" Value="2"/> | |||
<Setter Property="FontSize" Value="22"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ListBoxItem"> | |||
<Border BorderBrush="Black" BorderThickness="1"> | |||
<Grid HorizontalAlignment="Center" Margin="10 "> | |||
<Grid.RowDefinitions> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Row="0" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="配方:" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="数量:" /> | |||
<TextBlock | |||
Grid.Row="2" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="已完成:" /> | |||
<TextBlock | |||
Grid.Row="0" | |||
Grid.Column="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="{Binding Name}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Grid.Column="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="{Binding RecipeCount}" /> | |||
<TextBlock | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="" /> | |||
</Grid> | |||
</Border> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style TargetType="ListViewItem" > | |||
<Setter Property="Margin" Value="10"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ListViewItem"> | |||
<Border x:Name="mborder" BorderBrush="#009AC0" BorderThickness="3,3,3,10" CornerRadius="10" Margin="10" | |||
Background="White"> | |||
<Border.Effect> | |||
<DropShadowEffect Color="#696969" Direction="215" ShadowDepth="10" Opacity="0.8"/> | |||
</Border.Effect> | |||
<Grid | |||
Name="tt" | |||
Height="250" | |||
Width="300" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="*" /> | |||
<RowDefinition Height="2" /> | |||
<RowDefinition Height="40" /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> | |||
<TextBlock | |||
Grid.Row="0" | |||
Margin="2,5,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="18" | |||
Foreground="Black" | |||
Text="下单时间: " /> | |||
<TextBlock | |||
Grid.Row="0" | |||
Margin="2,5,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="18" | |||
Foreground="Black" | |||
Text="{Binding OrderdateTime}" /> | |||
</StackPanel> | |||
<ScrollViewer | |||
Grid.Row="1" | |||
Margin="20,10" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Auto"> | |||
<ListBox ItemsSource="{Binding Recipes}" FontFamily="楷体"> | |||
</ListBox> | |||
</ScrollViewer> | |||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Button Content="执行订单" Width="100" Height="24" HorizontalAlignment="Right" Margin="10,0" | |||
Background="#58B0ED" Foreground="White" | |||
Command="{Binding }" | |||
/> | |||
<Button Content="删除订单" Width="100" Height="24" HorizontalAlignment="Right" Margin="10,0" | |||
Background="#58B0ED" Foreground="White" | |||
Command="{Binding }" | |||
CommandParameter="{Binding}"/> | |||
</StackPanel> | |||
</Grid> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter Property="BorderBrush" Value="#D2B48C" TargetName="mborder"/> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="True"> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Button Content="创建订单" Width="100" Height="30" HorizontalAlignment="Right" Margin="10,0" | |||
Background="#58B0ED" Foreground="White" Command="{Binding CreateOrderCommand}"/> | |||
<ListView Grid.Row="1" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding orders}" Background="#FFFAFA" > | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Margin="10"/> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
</ListView> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,30 @@ | |||
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 BPASmart.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// OrderManager.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class OrderManager : UserControl | |||
{ | |||
public OrderManager() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,361 @@ | |||
<UserControl x:Class="BPASmart.RecipeManagement.View.PowerManager" | |||
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:BPASmart.RecipeManagement.View" | |||
xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:PowerManagerViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<ImageBrush x:Key="ImageBrushAddBlue" ImageSource="../Image/AddGreen.png"></ImageBrush> | |||
<ImageBrush x:Key="ImageBrushAddGray" ImageSource="../Image/Delete.png"></ImageBrush> | |||
<Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}"> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="OverridesDefaultStyle" Value="true" /> | |||
<Setter Property="IsTabStop" Value="false" /> | |||
<Setter Property="Focusable" Value="false" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RepeatButton}"> | |||
<Border Background="Transparent" /> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="ItemContainer" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="IconBorder" Background="Transparent" CornerRadius="4" BorderThickness="0"> | |||
<ContentPresenter /> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsSelected" Value="true"> | |||
<Setter TargetName="IconBorder" Property="BitmapEffect"> | |||
<Setter.Value> | |||
<OuterGlowBitmapEffect GlowColor="Transparent" GlowSize="5" /> | |||
</Setter.Value> | |||
</Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"> | |||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||
<Setter Property="OverridesDefaultStyle" Value="true" /> | |||
<Setter Property="IsTabStop" Value="false" /> | |||
<Setter Property="Focusable" Value="false" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type Thumb}"> | |||
<Border CornerRadius="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" /> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}"> | |||
<Grid> | |||
<Border CornerRadius="2" Width="0.5" Background="#FF046BFF" /> | |||
<Track x:Name="PART_Track" IsDirectionReversed="true"> | |||
<Track.DecreaseRepeatButton> | |||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" /> | |||
</Track.DecreaseRepeatButton> | |||
<Track.Thumb> | |||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="4,0,4,0" Background="DodgerBlue"></Thumb> | |||
</Track.Thumb> | |||
<Track.IncreaseRepeatButton> | |||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageDownCommand" /> | |||
</Track.IncreaseRepeatButton> | |||
</Track> | |||
</Grid> | |||
</ControlTemplate> | |||
<ControlTemplate x:Key="ScrollViewerControlTemplate1" TargetType="{x:Type ScrollViewer}"> | |||
<Grid x:Name="Grid" Background="{TemplateBinding Background}"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="Auto"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="Auto"/> | |||
</Grid.RowDefinitions> | |||
<Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="1"/> | |||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/> | |||
<ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" | |||
Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" | |||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" | |||
Template="{StaticResource VerticalScrollBar}"/> | |||
<ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/> | |||
</Grid> | |||
</ControlTemplate> | |||
</UserControl.Resources> | |||
<Grid Margin="0,10"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition Height="20"/> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<TextBlock Text="选择用户" FontSize="22" Foreground="DarkSlateGray" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20,0"/> | |||
<ComboBox Width="120" Margin="20,0" ItemsSource="{Binding UserName }" FontSize="16"/> | |||
<Button Foreground="White" Background="#009DFF" Margin="20,0" | |||
FontSize="18" Height="30" Width="120" | |||
Command="{Binding SaveCommand}" CommandParameter="Materials"> | |||
<TextBlock Text="保存" TextWrapping="Wrap"/> | |||
</Button> | |||
</StackPanel> | |||
<Grid Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Text="原料权限" FontSize="22" Foreground="DarkSlateGray" VerticalAlignment="Bottom" HorizontalAlignment="Center" /> | |||
<TextBlock Grid.Column="1" Text="配方权限" FontSize="22" Foreground="DarkSlateGray" VerticalAlignment="Bottom" HorizontalAlignment="Center" /> | |||
</Grid> | |||
<Grid Grid.Row="3" Margin="5,10,5,50"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="70"/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="20"/> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="70"/> | |||
<ColumnDefinition/> | |||
</Grid.ColumnDefinitions> | |||
<!--#region原料权限--> | |||
<Border Grid.Column="0" BorderBrush="#1874CD" BorderThickness="1" /> | |||
<Border Grid.Column="2" BorderBrush="#1874CD" BorderThickness="1" /> | |||
<ScrollViewer Margin="5" Template="{StaticResource ScrollViewerControlTemplate1}" CanContentScroll="True" | |||
Width="auto"> | |||
<ListBox Background="Transparent" ItemContainerStyle="{StaticResource ItemContainer}" FocusVisualStyle="{x:Null}" | |||
ItemsSource="{Binding AllMaterials}" > | |||
<ListBox.Template> | |||
<ControlTemplate> | |||
<StackPanel Background="Transparent" IsItemsHost="True"></StackPanel> | |||
</ControlTemplate> | |||
</ListBox.Template> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Height="28" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"></ColumnDefinition> | |||
<ColumnDefinition Width="60"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="tb_Name" Text="{Binding Name}" Foreground="Black" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" /> | |||
<Button x:Name="BtnDelete" Grid.Column="1" Background="Transparent" ToolTip="移除" VerticalAlignment="Center" HorizontalAlignment="Left" | |||
Command="{Binding DataContext.AddMaterialCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding Path=Text,ElementName=tb_Name}"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="Button"> | |||
<Grid> | |||
<Rectangle x:Name="BtnRetangle" Height="21" Width="21" Stroke="Transparent" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"> | |||
<Rectangle.Fill> | |||
<ImageBrush ImageSource="../Image/AddGreen.png"></ImageBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="BtnRetangle" Property="Height" Value="24"></Setter> | |||
<Setter TargetName="BtnRetangle" Property="Width" Value="24"></Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</ScrollViewer> | |||
<StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Button Foreground="White" Background="#009DFF" | |||
FontSize="18" Height="60" Width="60" Margin="0,20" | |||
Command="{Binding AddAllCommand}" CommandParameter="Materials"> | |||
<TextBlock Text="全部 | |||
添加" TextWrapping="Wrap"/> | |||
</Button> | |||
<Button Foreground="White" Background="#009DFF" | |||
FontSize="18" Height="60" Width="60" Margin="0,20" | |||
Command="{Binding DeleteAllCommand}" CommandParameter="Materials"> | |||
<TextBlock Text="全部 | |||
移除" TextWrapping="Wrap"/> | |||
</Button> | |||
</StackPanel> | |||
<ScrollViewer Grid.Column="2" Margin="5" Template="{StaticResource ScrollViewerControlTemplate1}" CanContentScroll="True"> | |||
<ListBox Background="Transparent" ItemContainerStyle="{StaticResource ItemContainer}" FocusVisualStyle="{x:Null}" Width="auto" | |||
ItemsSource="{Binding UserMaterials}" > | |||
<ListBox.Template> | |||
<ControlTemplate> | |||
<StackPanel Background="Transparent" IsItemsHost="True"></StackPanel> | |||
</ControlTemplate> | |||
</ListBox.Template> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Height="28" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"></ColumnDefinition> | |||
<ColumnDefinition Width="60"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="tb_Name" Text="{Binding Name}" Foreground="Black" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" /> | |||
<Button x:Name="BtnDelete" Grid.Column="1" Background="Transparent" ToolTip="移除" VerticalAlignment="Center" HorizontalAlignment="Left" | |||
Command="{Binding DataContext.DeleteMaterialCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding Path=Text,ElementName=tb_Name}"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="Button"> | |||
<Grid> | |||
<Rectangle x:Name="BtnRetangle" Height="21" Width="21" Stroke="Transparent" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"> | |||
<Rectangle.Fill> | |||
<ImageBrush ImageSource="../Image/Delete.png"></ImageBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="BtnRetangle" Property="Height" Value="24"></Setter> | |||
<Setter TargetName="BtnRetangle" Property="Width" Value="24"></Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
<!--#region 配方权限--> | |||
<Border Grid.Column="4" BorderBrush="#1874CD" BorderThickness="1" /> | |||
<Border Grid.Column="6" BorderBrush="#1874CD" BorderThickness="1" /> | |||
<ScrollViewer Grid.Column="4" Width="auto" Margin="5,5,5,5" Template="{StaticResource ScrollViewerControlTemplate1}" CanContentScroll="True" > | |||
<ListBox Background="Transparent" ItemContainerStyle="{StaticResource ItemContainer}" FocusVisualStyle="{x:Null}" | |||
ItemsSource="{Binding AllRecipes}" > | |||
<ListBox.Template> | |||
<ControlTemplate> | |||
<StackPanel Background="Transparent" IsItemsHost="True"></StackPanel> | |||
</ControlTemplate> | |||
</ListBox.Template> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Height="28" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"></ColumnDefinition> | |||
<ColumnDefinition Width="60"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="tb_Name" Text="{Binding Name}" Foreground="Black" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" /> | |||
<Button x:Name="BtnDelete" Grid.Column="1" Background="Transparent" ToolTip="移除" VerticalAlignment="Center" HorizontalAlignment="Left" | |||
Command="{Binding DataContext.AddRecipeCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding Path=Text,ElementName=tb_Name}"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="Button"> | |||
<Grid> | |||
<Rectangle x:Name="BtnRetangle" Height="21" Width="21" Stroke="Transparent" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"> | |||
<Rectangle.Fill> | |||
<ImageBrush ImageSource="../Image/AddGreen.png"></ImageBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="BtnRetangle" Property="Height" Value="24"></Setter> | |||
<Setter TargetName="BtnRetangle" Property="Width" Value="24"></Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</ScrollViewer> | |||
<StackPanel Grid.Column="5" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Button Foreground="White" Background="#009DFF" | |||
FontSize="18" Height="60" Width="60" Margin="0,20" | |||
Command="{Binding AddAllCommand}" CommandParameter="Recipes"> | |||
<TextBlock Text="全部 | |||
添加" TextWrapping="Wrap"/> | |||
</Button> | |||
<Button Foreground="White" Background="#009DFF" | |||
FontSize="18" Height="60" Width="60" Margin="0,20" | |||
Command="{Binding DeleteAllCommand}" CommandParameter="Recipes"> | |||
<TextBlock Text="全部 | |||
移除" TextWrapping="Wrap"/> | |||
</Button> | |||
</StackPanel> | |||
<ScrollViewer Grid.Column="6" Margin="5" Template="{StaticResource ScrollViewerControlTemplate1}" CanContentScroll="True"> | |||
<ListBox Background="Transparent" ItemContainerStyle="{StaticResource ItemContainer}" FocusVisualStyle="{x:Null}" | |||
Width="auto" | |||
ItemsSource="{Binding UserRecipes}" > | |||
<ListBox.Template> | |||
<ControlTemplate> | |||
<StackPanel Background="Transparent" IsItemsHost="True"></StackPanel> | |||
</ControlTemplate> | |||
</ListBox.Template> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid Height="28" Margin="5"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"></ColumnDefinition> | |||
<ColumnDefinition Width="60"></ColumnDefinition> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="tb_Name" Text="{Binding Name}" Foreground="Black" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Left" /> | |||
<Button x:Name="BtnDelete" Grid.Column="1" Background="Transparent" ToolTip="移除" VerticalAlignment="Center" HorizontalAlignment="Left" | |||
Command="{Binding DataContext.DeleteRecipeCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding Path=Text,ElementName=tb_Name}"> | |||
<Button.Template> | |||
<ControlTemplate TargetType="Button"> | |||
<Grid> | |||
<Rectangle x:Name="BtnRetangle" Height="21" Width="21" Stroke="Transparent" StrokeThickness="1" VerticalAlignment="Center" HorizontalAlignment="Left"> | |||
<Rectangle.Fill> | |||
<ImageBrush ImageSource="../Image/Delete.png"></ImageBrush> | |||
</Rectangle.Fill> | |||
</Rectangle> | |||
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"></ContentPresenter> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="BtnRetangle" Property="Height" Value="24"></Setter> | |||
<Setter TargetName="BtnRetangle" Property="Width" Value="24"></Setter> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
</Grid> | |||
</Grid> | |||
</UserControl> |
@@ -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 BPASmart.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// PowerManager.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class PowerManager : UserControl | |||
{ | |||
public PowerManager() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,158 @@ | |||
<UserControl x:Class="BPASmart.RecipeManagement.View.RecipeManager" | |||
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:BPASmart.RecipeManagement.View" | |||
xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:RecipeManagerViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<Style TargetType="ListViewItem" > | |||
<Setter Property="Margin" Value="10"/> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="ListViewItem"> | |||
<Border x:Name="mborder" BorderBrush="#009AC0" BorderThickness="1,5" CornerRadius="10" Margin="10" | |||
Background="Transparent"> | |||
<Grid | |||
Name="tt" | |||
Height="200" | |||
Width="150" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition Height="20" /> | |||
<RowDefinition Height="128" /> | |||
<RowDefinition Height="2" /> | |||
<RowDefinition Height="40" /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
Grid.Row="0" | |||
Margin="2,5,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
FontSize="18" | |||
Foreground="Black" | |||
Text="{Binding Name}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Top" | |||
Foreground="Black" | |||
Text="配方信息:" /> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<ItemsControl ItemsSource="{Binding recipeMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Foreground="#FF2AB2E7" | |||
Text="{Binding Name}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
<ItemsControl Grid.Column="1" | |||
VerticalAlignment="Center" | |||
VerticalContentAlignment="Center" ItemsSource="{Binding recipeMaterials}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<StackPanel Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#FF2AB2E7" | |||
Text=":" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#FF2AB2E7" | |||
Text="{Binding MaterialWeight}" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#FF2AB2E7" | |||
Text="g" /> | |||
</StackPanel> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Grid> | |||
</ScrollViewer> | |||
</Grid> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter Property="BorderBrush" Value="#D2B48C" TargetName="mborder"/> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="True"> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition/> | |||
</Grid.RowDefinitions> | |||
<TextBlock Text="配方清单" FontSize="28" Foreground="DarkSlateGray" VerticalAlignment="Center" HorizontalAlignment="Center"/> | |||
<ListView Grid.Row="1" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding RecipeList}" Margin=" 10" Background="#FFFAFA" > | |||
<ListView.ContextMenu> | |||
<ContextMenu FontSize="16" Foreground="White"> | |||
<MenuItem Header="新建配方" Name="MenuAdd" Command="{Binding CreateRecipeCommand}"></MenuItem> | |||
<MenuItem Header="编辑配方" Name="MenuEdit" | |||
Command="{Binding EditRecipeCommand }" | |||
CommandParameter="{Binding PlacementTarget.SelectedIndex,RelativeSource={RelativeSource AncestorType=ContextMenu}}"></MenuItem> | |||
<MenuItem Header="删除配方" Name="MenuDelete" | |||
Command="{Binding DeleteRecipeCommand}" | |||
CommandParameter="{Binding PlacementTarget.SelectedIndex,RelativeSource={RelativeSource AncestorType=ContextMenu}}"></MenuItem> | |||
</ContextMenu> | |||
</ListView.ContextMenu> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<WrapPanel Margin="10"/> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
</ListView> | |||
</Grid> | |||
</UserControl> |
@@ -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 BPASmart.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// RecipeManager.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipeManager : UserControl | |||
{ | |||
public RecipeManager() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,273 @@ | |||
<Window x:Class="BPASmartClient.RecipeManagement.View.RecipesConfigure" | |||
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.RecipeManagement.View" | |||
xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel" | |||
mc:Ignorable="d" | |||
Title="RecipesConfigure" Height="600" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="White" MouseLeftButtonDown="Window_MouseLeftButtonDown"> | |||
<Window.DataContext> | |||
<vm:RecipesConfigureViewModel/> | |||
</Window.DataContext> | |||
<Window.Resources> | |||
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}"> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="ItemContainerStyle"> | |||
<Setter.Value> | |||
<Style TargetType="ComboBoxItem"> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ComboBoxItem}"> | |||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> | |||
<Border x:Name="_borderbg" Background="White" /> | |||
<TextBlock | |||
x:Name="_txt" | |||
Margin="5,0,3,0" | |||
FontWeight="Black" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
Foreground="Black" | |||
Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" /> | |||
<Border | |||
x:Name="_border" | |||
Background="White" | |||
Opacity="0" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsSelected" Value="false" /> | |||
<Condition Property="IsMouseOver" Value="true" /> | |||
</MultiTrigger.Conditions> | |||
<Setter TargetName="_borderbg" Property="Background" Value="#AFEEEE" /> | |||
<Setter TargetName="_txt" Property="Foreground" Value="black" /> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ComboBox}"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.3*" MaxWidth="30" /> | |||
</Grid.ColumnDefinitions> | |||
<Border | |||
x:Name="_prybr" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
BorderBrush="{TemplateBinding BorderBrush}" | |||
BorderThickness="{TemplateBinding BorderThickness}" | |||
CornerRadius="0" /> | |||
<ContentPresenter | |||
x:Name="ContentSite" | |||
Margin="3,3,0,3" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding SelectionBoxItem}" | |||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" | |||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" | |||
IsHitTestVisible="False" /> | |||
<!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen --> | |||
<ToggleButton | |||
x:Name="ToggleButton" | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
ClickMode="Press" | |||
Focusable="false" | |||
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||
Template="{StaticResource ComboBoxToggleButton}" /> | |||
<!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 --> | |||
<TextBox | |||
x:Name="PART_EditableTextBox" | |||
Margin="2,0,0,0" | |||
VerticalAlignment="Center" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
CaretBrush="{TemplateBinding Foreground}" | |||
Focusable="True" | |||
Foreground="{TemplateBinding Foreground}" | |||
IsReadOnly="{TemplateBinding IsReadOnly}" | |||
Visibility="Hidden" /> | |||
<!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen --> | |||
<Popup | |||
x:Name="Popup" | |||
AllowsTransparency="True" | |||
Focusable="False" | |||
IsOpen="{TemplateBinding IsDropDownOpen}" | |||
Placement="Bottom" | |||
PopupAnimation="Slide"> | |||
<Grid | |||
x:Name="DropDown" | |||
MinWidth="{TemplateBinding ActualWidth}" | |||
MaxHeight="150" | |||
SnapsToDevicePixels="True"> | |||
<Border | |||
x:Name="DropDownBorder" | |||
BorderBrush="Black" | |||
BorderThickness="0" /> | |||
<ScrollViewer | |||
Margin="1" | |||
CanContentScroll="True" | |||
HorizontalScrollBarVisibility="Auto" | |||
SnapsToDevicePixels="True" | |||
VerticalScrollBarVisibility="Auto"> | |||
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True --> | |||
<!-- 一下可以设置列表背景色 --> | |||
<StackPanel | |||
Background="White" | |||
IsItemsHost="True" | |||
KeyboardNavigation.DirectionalNavigation="Contained" /> | |||
</ScrollViewer> | |||
</Grid> | |||
</Popup> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsEditable" Value="true"> | |||
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="ContentSite" Property="Opacity" Value="0.6" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Window.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50"/> | |||
<RowDefinition /> | |||
<RowDefinition Height="30"/> | |||
<RowDefinition Height="60"/> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="103*" /> | |||
<ColumnDefinition Width="147*" /> | |||
<ColumnDefinition Width="100*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Text="配方名称:" FontSize="22" | |||
HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/> | |||
<TextBox Text="{Binding RecipeName}" FontSize="20" Grid.Column="1" Width="160" Height="36" | |||
VerticalAlignment="Center" HorizontalAlignment="Center" | |||
VerticalContentAlignment="Center"/> | |||
<Button Grid.Column="2" | |||
Content="添加原料" | |||
Foreground="White" FontSize="16" Width="90" Height="30" Margin="10" Background="#58B0ED" | |||
Command="{Binding AddMaterailsCommand}"/> | |||
<ScrollViewer Grid.ColumnSpan="3" | |||
Grid.Row="1" | |||
Margin="15,10" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Auto"> | |||
<ItemsControl ItemsSource="{Binding recipeMaterials}" > | |||
<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="Black" | |||
BorderThickness="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Foreground="Black" | |||
IsEditable="False" | |||
ItemsSource="{Binding DataContext.materialsName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
Style="{StaticResource ComboBoxStyle}" | |||
SelectedItem="{Binding Name}" | |||
/> | |||
<StackPanel | |||
Grid.Column="1" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBox | |||
Name="tb" | |||
Grid.Column="1" | |||
Width="100" | |||
Height="29" | |||
Margin="3,1" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="{Binding MaterialWeight}" /> | |||
<TextBlock | |||
Grid.Column="1" | |||
Margin="0,0,8,4" | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
FontSize="20" | |||
Text="g" /> | |||
</StackPanel> | |||
<Button | |||
Grid.Column="2" | |||
Width="70" | |||
Height="28" | |||
Margin="25,0,0,0" | |||
Foreground="White" | |||
FontSize="16" | |||
Background="#58B0ED" | |||
Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}" | |||
CommandParameter="{Binding ID}" | |||
Content="删 除" /> | |||
</Grid> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer> | |||
<TextBlock Text="{Binding ErrorMessage}" Grid.Row="2" Grid.ColumnSpan="3" | |||
Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Center"/> | |||
<StackPanel Grid.Row="4" Grid.ColumnSpan="3" Orientation="Horizontal" | |||
HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Button Content="保存" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED" | |||
Command="{Binding SaveCommand}"/> | |||
<Button Content="取消" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED" | |||
Click="Button_Click"/> | |||
</StackPanel> | |||
</Grid> | |||
</Window> |
@@ -0,0 +1,37 @@ | |||
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.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// RecipesConfigure.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class RecipesConfigure : Window | |||
{ | |||
public RecipesConfigure() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void Button_Click(object sender, RoutedEventArgs e) | |||
{ | |||
this.Close(); | |||
} | |||
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
{ | |||
this.DragMove(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
<UserControl x:Class="BPASmart.RecipeManagement.View.TechnologySetting" | |||
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:BPASmart.RecipeManagement.View" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Grid> | |||
</Grid> | |||
</UserControl> |
@@ -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 BPASmart.RecipeManagement.View | |||
{ | |||
/// <summary> | |||
/// TechnologySetting.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class TechnologySetting : UserControl | |||
{ | |||
public TechnologySetting() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,62 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class CreateOrderViewModel: ObservableObject | |||
{ | |||
public ObservableCollection<Recipes> recipes { get; set; } = new ObservableCollection<Recipes>(); | |||
public ObservableCollection<string> recipesName { get; set; } = new ObservableCollection<string>(); | |||
public RelayCommand SaveCommand { get; set; } | |||
public RelayCommand<object> DeleteCommand { get; set; } | |||
public RelayCommand AddRecipeCommand { get; set; } | |||
private void Delete(object o) | |||
{ | |||
if(o == null) return; | |||
if(o is string id) | |||
{ | |||
var res = recipes.FirstOrDefault(x => x.ID == id); | |||
recipes.Remove(res); | |||
} | |||
} | |||
public CreateOrderViewModel() | |||
{ | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
Globle.GlobleData.orders.Add(new Order | |||
{ | |||
OrderId = Guid.NewGuid().ToString(), | |||
OrderdateTime = DateTime.Now.ToString(), | |||
Recipes = recipes | |||
}); | |||
}); | |||
DeleteCommand = new RelayCommand<object>(Delete); | |||
AddRecipeCommand = new RelayCommand(() => | |||
{ | |||
recipes.Add(new Recipes() { ID = Guid.NewGuid().ToString() }); | |||
}); | |||
foreach( var item in Json<LocalRecipes>.Data.locaRecipes ) | |||
{ | |||
recipesName.Add(item.Name); | |||
} | |||
} | |||
} | |||
} |
@@ -15,6 +15,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public MainWindowViewModel() | |||
{ | |||
Json<LocalMaterails>.Read(); | |||
Json<LocalRecipes>.Read(); | |||
} | |||
} | |||
@@ -0,0 +1,34 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.RecipeManagement.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 BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class OrderManagerViewModel:ObservableObject | |||
{ | |||
/// <summary> | |||
/// 订单集合 | |||
/// </summary> | |||
public ObservableCollection<Order> orders { get; set; } = Globle.GlobleData.orders; | |||
public RelayCommand CreateOrderCommand { get; set; } | |||
public OrderManagerViewModel() | |||
{ | |||
CreateOrderCommand = new RelayCommand(() => | |||
{ | |||
CreateOrder createOrder = new CreateOrder(); | |||
createOrder.ShowDialog(); | |||
}); | |||
} | |||
} | |||
} |
@@ -0,0 +1,150 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmartClient.Helper; | |||
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 BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class PowerManagerViewModel:ObservableObject | |||
{ | |||
public ObservableCollection<string> UserName { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 全部物料 | |||
/// </summary> | |||
public ObservableCollection<RecipeMaterials> AllMaterials { get; set; } = Json<LocalMaterails>.Data.locaMaterails; | |||
/// <summary> | |||
/// 用户权限物料 | |||
/// </summary> | |||
public ObservableCollection<RecipeMaterials> UserMaterials { get; set; } = new ObservableCollection<RecipeMaterials>(); | |||
/// <summary> | |||
/// 全部配方 | |||
/// </summary> | |||
public ObservableCollection<Recipes> AllRecipes { get; set; } = Json<LocalRecipes>.Data.locaRecipes; | |||
/// <summary> | |||
/// 用户权限配方 | |||
/// </summary> | |||
public ObservableCollection<Recipes> UserRecipes { get; set; } = new ObservableCollection<Recipes>(); | |||
public RelayCommand<object> DeleteAllCommand { get; set; } | |||
public RelayCommand<object> AddAllCommand { get; set; } | |||
public RelayCommand<object> AddMaterialCommand { get; set; } | |||
public RelayCommand<object> DeleteMaterialCommand { get; set; } | |||
public RelayCommand<object> AddRecipeCommand { get; set; } | |||
public RelayCommand<object> DeleteRecipeCommand { get; set; } | |||
private void DeleteAll(object o) | |||
{ | |||
if (o == null) return; | |||
if (o.ToString() == "Materials") | |||
{ | |||
UserMaterials.Clear(); | |||
} | |||
else if (o.ToString() == "Recipes") | |||
{ | |||
UserRecipes.Clear(); | |||
} | |||
} | |||
private void AddAll(object o) | |||
{ | |||
if (o == null) return; | |||
if (o.ToString() == "Materials") | |||
{ | |||
UserMaterials.Clear(); | |||
foreach (RecipeMaterials item in AllMaterials) | |||
{ | |||
UserMaterials.Add(item); | |||
} | |||
} | |||
else if (o.ToString() == "Recipes") | |||
{ | |||
UserRecipes.Clear(); | |||
foreach (Recipes item in AllRecipes) | |||
{ | |||
UserRecipes.Add(item); | |||
} | |||
} | |||
} | |||
private void AddMaterial(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string materail) | |||
{ | |||
var res = AllMaterials.FirstOrDefault(p => p.Name == materail); | |||
if (UserMaterials.FirstOrDefault(p => p.Name == res.Name) == null) | |||
{ | |||
UserMaterials.Add(res); | |||
} | |||
} | |||
} | |||
private void DeleteMaterial(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string materail) | |||
{ | |||
var res = UserMaterials.FirstOrDefault(p => p.Name == materail); | |||
UserMaterials.Remove(res); | |||
} | |||
} | |||
private void AddRecipe(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string materail) | |||
{ | |||
var res = AllRecipes.FirstOrDefault(p => p.Name == materail); | |||
if (UserRecipes.FirstOrDefault(p => p.Name == res.Name) == null) | |||
{ | |||
UserRecipes.Add(res); | |||
} | |||
} | |||
} | |||
private void DeleteRecipe(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string materail) | |||
{ | |||
var res = UserRecipes.FirstOrDefault(p => p.Name == materail); | |||
UserRecipes.Remove(res); | |||
} | |||
} | |||
public PowerManagerViewModel() | |||
{ | |||
DeleteAllCommand = new RelayCommand<object>(DeleteAll); | |||
AddAllCommand = new RelayCommand<object>(AddAll); | |||
AddMaterialCommand = new RelayCommand<object>(AddMaterial); | |||
DeleteMaterialCommand = new RelayCommand<object>(DeleteMaterial); | |||
AddRecipeCommand = new RelayCommand<object>(AddRecipe); | |||
DeleteRecipeCommand = new RelayCommand<object>(DeleteRecipe); | |||
UserName.Add("admin"); | |||
UserName.Add("员工1号"); | |||
UserName.Add("员工2号"); | |||
UserName.Add("员工3号"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,60 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.RecipeManagement.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 BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class RecipeManagerViewModel:ObservableObject | |||
{ | |||
public ObservableCollection<Recipes> RecipeList { get; set; } = Json<LocalRecipes>.Data.locaRecipes; | |||
public RelayCommand CreateRecipeCommand { get; set; } | |||
public RelayCommand<object> EditRecipeCommand { get; set; } | |||
public RelayCommand<object> DeleteRecipeCommand { get; set; } | |||
private void EditRecipe(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is int item && item >= 0) | |||
{ | |||
Globle.GlobleData.ChangeRecipes = new Recipes(); | |||
Globle.GlobleData.ChangeRecipes = RecipeList[item]; | |||
RecipesConfigure recipesConfigure = new RecipesConfigure(); | |||
recipesConfigure.ShowDialog(); | |||
} | |||
} | |||
private void DeleteRecipe(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is int i && i >= 0) | |||
{ | |||
RecipeList.RemoveAt(i); | |||
Json<LocalRecipes>.Save(); | |||
} | |||
} | |||
public RecipeManagerViewModel() | |||
{ | |||
CreateRecipeCommand = new RelayCommand(() => | |||
{ | |||
Globle.GlobleData.ChangeRecipes = null; | |||
RecipesConfigure recipesConfigure = new RecipesConfigure(); | |||
recipesConfigure.ShowDialog(); | |||
}); | |||
EditRecipeCommand = new RelayCommand<object>(EditRecipe); | |||
DeleteRecipeCommand = new RelayCommand<object>(DeleteRecipe); | |||
} | |||
} | |||
} |
@@ -0,0 +1,115 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmartClient.Helper; | |||
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 BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class RecipesConfigureViewModel:ObservableObject | |||
{ | |||
public ObservableCollection<RecipeMaterials> recipeMaterials { get; set; } = new ObservableCollection<RecipeMaterials>(); | |||
/// <summary> | |||
/// 原料名称集合 | |||
/// </summary> | |||
public ObservableCollection<string> materialsName { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 配方名称 | |||
/// </summary> | |||
public string RecipeName { get { return _repiceName; } set { _repiceName = value; OnPropertyChanged(); } } | |||
private string _repiceName; | |||
public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } } | |||
private string _errorMessage; | |||
public RelayCommand AddMaterailsCommand { get; set; } | |||
public RelayCommand SaveCommand { get; set; } | |||
public RelayCommand<object> DeleteCommand { get; set; } | |||
private void Delete(object o) | |||
{ | |||
if (o == null) return; | |||
if(o is string id) | |||
{ | |||
var res = recipeMaterials.FirstOrDefault(p=>p.ID == id); | |||
if (res != null) recipeMaterials.Remove(res); | |||
} | |||
} | |||
public RecipesConfigureViewModel() | |||
{ | |||
AddMaterailsCommand = new RelayCommand(() => | |||
{ | |||
recipeMaterials.Add(new RecipeMaterials() | |||
{ | |||
ID = Guid.NewGuid().ToString() | |||
}); | |||
}); | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
if(RecipeName == null) | |||
{ | |||
ErrorMessage = "配方名称为空"; | |||
return; | |||
} | |||
if (Globle.GlobleData.ChangeRecipes!=null) | |||
{ | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == Globle.GlobleData.ChangeRecipes.ID); | |||
res.recipeMaterials = recipeMaterials; | |||
res.Name = RecipeName; | |||
} | |||
else | |||
{ | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.Name == RecipeName); | |||
if (res != null) | |||
{ | |||
ErrorMessage = "配方名称已存在"; | |||
return; | |||
} | |||
Json<LocalRecipes>.Data.locaRecipes.Add(new Recipes | |||
{ | |||
ID = Guid.NewGuid().ToString() , | |||
Name = RecipeName, | |||
recipeMaterials = recipeMaterials | |||
}); | |||
} | |||
Json<LocalRecipes>.Save(); | |||
}); | |||
DeleteCommand = new RelayCommand<object>(Delete); | |||
if (Json<LocalMaterails>.Data.locaMaterails.Count > 0) | |||
{ | |||
foreach (var materail in Json<LocalMaterails>.Data.locaMaterails) | |||
{ | |||
materialsName.Add(materail.Name); | |||
} | |||
} | |||
if(Globle.GlobleData.ChangeRecipes != null) | |||
{ | |||
RecipeName = Globle.GlobleData.ChangeRecipes.Name.ToString(); | |||
recipeMaterials = Globle.GlobleData.ChangeRecipes.recipeMaterials; | |||
} | |||
} | |||
} | |||
} |