Bläddra i källkod

recipe

样式分支
NXX 2 år sedan
förälder
incheckning
98f46e9185
21 ändrade filer med 1038 tillägg och 1 borttagningar
  1. +14
    -0
      BPASmart.Model/配方/LocalMaterails.cs
  2. +13
    -0
      BPASmart.Model/配方/LocalRecipes.cs
  3. +48
    -0
      BPASmart.Model/配方/RecipeMaterials.cs
  4. +14
    -0
      BPASmart.Model/配方/Recipes.cs
  5. +9
    -0
      BPASmart.RecipeManagement/App.xaml
  6. +17
    -0
      BPASmart.RecipeManagement/App.xaml.cs
  7. +10
    -0
      BPASmart.RecipeManagement/AssemblyInfo.cs
  8. +23
    -0
      BPASmart.RecipeManagement/BPASmart.RecipeManagement.csproj
  9. +14
    -0
      BPASmart.RecipeManagement/Globle/GlobleData.cs
  10. +105
    -0
      BPASmart.RecipeManagement/MainWindow.xaml
  11. +61
    -0
      BPASmart.RecipeManagement/MainWindow.xaml.cs
  12. +212
    -0
      BPASmart.RecipeManagement/View/MaterialConfigure.xaml
  13. +39
    -0
      BPASmart.RecipeManagement/View/MaterialConfigure.xaml.cs
  14. +198
    -0
      BPASmart.RecipeManagement/View/MaterialManager.xaml
  15. +33
    -0
      BPASmart.RecipeManagement/View/MaterialManager.xaml.cs
  16. +21
    -0
      BPASmart.RecipeManagement/ViewModel/MainWindowViewModel.cs
  17. +106
    -0
      BPASmart.RecipeManagement/ViewModel/MaterialConfigureViewModel.cs
  18. +67
    -0
      BPASmart.RecipeManagement/ViewModel/MaterialManagerViewModel.cs
  19. +10
    -0
      BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj
  20. Binär
     
  21. +24
    -1
      SmartClient.sln

+ 14
- 0
BPASmart.Model/配方/LocalMaterails.cs Visa fil

@@ -0,0 +1,14 @@
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 LocalMaterails
{
public ObservableCollection<RecipeMaterials> locaMaterails { get; set; } = new ObservableCollection<RecipeMaterials>();
}
}

+ 13
- 0
BPASmart.Model/配方/LocalRecipes.cs Visa fil

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.Model.配方
{
public class LocalRecipes
{
}
}

+ 48
- 0
BPASmart.Model/配方/RecipeMaterials.cs Visa fil

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

namespace BPASmart.Model.配方
{
public class RecipeMaterials:ObservableObject
{
/// <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(); } }
private string _name;
/// <summary>
/// 物料种类
/// </summary>
public MaterialType MaterialType { get { return _materialType; } set { _materialType = value; OnPropertyChanged(); } }
private MaterialType _materialType;
/// <summary>
/// 物料重量
/// </summary>
public int MaterialWeight { get { return _materialWeight; } set { _materialWeight = value; OnPropertyChanged(); } }
private int _materialWeight;
/// <summary>
/// 原料位置
/// </summary>
public string MaterialPosion { get { return _materialPosion; } set { _materialPosion = value;OnPropertyChanged(); } }
private string _materialPosion;
}

public enum MaterialType
{
无 = 0,
干料 = 1,
湿料 = 2,
粉体 = 3,
膏体 = 4
}

}

+ 14
- 0
BPASmart.Model/配方/Recipes.cs Visa fil

@@ -0,0 +1,14 @@
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 Recipes
{
public ObservableCollection<RecipeMaterials> Materials { get; set; }
}
}

+ 9
- 0
BPASmart.RecipeManagement/App.xaml Visa fil

@@ -0,0 +1,9 @@
<Application x:Class="BPASmart.RecipeManagement.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmart.RecipeManagement"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

+ 17
- 0
BPASmart.RecipeManagement/App.xaml.cs Visa fil

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmart.RecipeManagement
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 10
- 0
BPASmart.RecipeManagement/AssemblyInfo.cs Visa fil

@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 23
- 0
BPASmart.RecipeManagement/BPASmart.RecipeManagement.csproj Visa fil

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<Compile Remove="新文件夹1\**" />
<EmbeddedResource Remove="新文件夹1\**" />
<None Remove="新文件夹1\**" />
<Page Remove="新文件夹1\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmart.Model\BPASmart.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" />
</ItemGroup>

</Project>

+ 14
- 0
BPASmart.RecipeManagement/Globle/GlobleData.cs Visa fil

@@ -0,0 +1,14 @@
using BPASmart.Model.配方;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.RecipeManagement.Globle
{
public class GlobleData
{
public static RecipeMaterials ChangeMaterail;
}
}

+ 105
- 0
BPASmart.RecipeManagement/MainWindow.xaml Visa fil

@@ -0,0 +1,105 @@
<Window x:Class="BPASmart.RecipeManagement.MainWindow"
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"
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">
<Window.DataContext>
<vm:MainWindowViewModel/>
</Window.DataContext>
<Window.Resources>
<Style x:Key="RadioNavigation" TargetType="RadioButton">
<Setter Property="Margin" Value="-4,10"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="GroupName" Value="Navigation"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}">
<Border x:Name="_borderOver" Background="Transparent" Width="200" BorderBrush="Transparent" BorderThickness="0,1">
<TextBlock Foreground="White" Text="{TemplateBinding Content}" FontSize="24" Background="Transparent"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="_borderOver" Value="#1971B6"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" TargetName="_borderOver" Value="White"/>
<Setter Property="BorderThickness" TargetName="_borderOver" Value="0,1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonNavigation" TargetType="Button">
<Setter Property="Height" Value="40"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}">
<Border x:Name="_borderOver" Background="Transparent" Width="200" BorderBrush="Transparent" BorderThickness="0,1">
<TextBlock Foreground="White" Text="{TemplateBinding Content}" FontSize="24" Background="Transparent"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="_borderOver" Value="#1971B6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border Background="Transparent">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<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}"
Click="NavButton_Click" Tag=""/>
<RadioButton Content="工艺参数" Style="{DynamicResource RadioNavigation}"
Click="NavButton_Click" Tag=""/>
<RadioButton Content="权限分配" Style="{DynamicResource RadioNavigation}"
Click="NavButton_Click" Tag=""/>
</StackPanel>
<Border Background="#2196F3" Grid.Row="2">
<Button Content="退出"
Style="{DynamicResource ButtonNavigation}"
Click="Button_Click">
</Button>
</Border>
<ContentControl x:Name="contentRegion" Grid.Column="1" Grid.Row="1" >
<view:MaterialManager/>
</ContentControl>
</Grid>
</Border>
</Window>

+ 61
- 0
BPASmart.RecipeManagement/MainWindow.xaml.cs Visa fil

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void mylistview_MouseDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}


private void NavButton_Click(object sender, RoutedEventArgs e)
{

try
{
if (sender is Button bt)
{
Type type = Type.GetType($"BPASmartClient.MilkWithTea.View.{bt.Tag?.ToString()}");
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
}
}
catch (Exception ex)
{
}
}
}
}

+ 212
- 0
BPASmart.RecipeManagement/View/MaterialConfigure.xaml Visa fil

@@ -0,0 +1,212 @@
<Window x:Class="BPASmart.RecipeManagement.View.MaterialConfigure"
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="MaterialConfigure" Height="300" Width="500" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="White" MouseLeftButtonDown="Window_MouseLeftButtonDown">
<Window.DataContext>
<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">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="17*"/>
<ColumnDefinition Width="33*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="40"/>
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="原料名称:" FontSize="22"
HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/>
<TextBlock Text="原料种类:" FontSize="22" Grid.Row="1"
HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/>
<TextBlock Text="原料位置:" FontSize="22" Grid.Row="2"
HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/>
<TextBox Text="{Binding MaterialName}" FontSize="22" Grid.Column="1" Width="200" Height="40"
VerticalAlignment="Center" HorizontalAlignment="Center"
VerticalContentAlignment="Center"/>
<ComboBox ItemsSource="{Binding MaterialTypes}"
FontSize="18"
Grid.Column="1" Grid.Row="1" Width="200" Height="40"
SelectedItem="{Binding MaterialType}"/>
<TextBox Text="{Binding MaterialPosion}" FontSize="22" Grid.Column="1" Grid.Row="2"
Width="100" Height="40"
VerticalAlignment="Center" HorizontalAlignment="Center"
VerticalContentAlignment="Center"/>
<TextBlock Text="{Binding ErrorMessage}" Grid.Row="3" Grid.ColumnSpan=" 2"
Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<StackPanel Grid.Row="4" Grid.ColumnSpan="2" 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>
</Border>
</Window>

+ 39
- 0
BPASmart.RecipeManagement/View/MaterialConfigure.xaml.cs Visa fil

@@ -0,0 +1,39 @@
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>
/// MaterialConfigure.xaml 的交互逻辑
/// </summary>
public partial class MaterialConfigure : Window
{
public MaterialConfigure()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();

}

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
}
}

+ 198
- 0
BPASmart.RecipeManagement/View/MaterialManager.xaml Visa fil

@@ -0,0 +1,198 @@
<UserControl x:Class="BPASmart.RecipeManagement.View.MaterialManager"
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:MaterialManagerViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<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">
<Grid Width="100" >
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="#4F94CD" Offset="0"/>
<GradientStop Color="Transparent" Offset="0.3"/>
<GradientStop Color="Transparent" Offset="0.7"/>
<GradientStop Color="#4F94CD" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding MaterialPosion}" Height="20" Width="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,0"/>
<TextBlock Text="{Binding Name}" Grid.ColumnSpan="2"
FontSize="24"
HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Row="1" Text="种类:" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="16"
VerticalAlignment="Center" HorizontalAlignment="Left"
Text="{Binding MaterialType}" TextAlignment="Center"></TextBlock>
</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>

<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>
</UserControl.Resources>
<Grid Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="原料清单" FontSize="28" Foreground="DarkSlateGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<ListView x:Name="mylistview" Grid.Row="1"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding MaterialList}" Margin=" 10" Background="#FFFAFA" >
<ListView.ContextMenu>
<ContextMenu FontSize="16" Foreground="White">
<MenuItem Header="新建原料" Name="MenuAdd" Command="{Binding CreateMaterailCommand}"></MenuItem>
<MenuItem Header="编辑原料" Name="MenuEdit"
Command="{Binding EditMaterailCommand }"
CommandParameter="{Binding PlacementTarget.SelectedIndex,RelativeSource={RelativeSource AncestorType=ContextMenu}}"></MenuItem>
<MenuItem Header="删除原料" Name="MenuDelete"
Command="{Binding DeleteMaterailCommand}"
CommandParameter="{Binding PlacementTarget.SelectedIndex,RelativeSource={RelativeSource AncestorType=ContextMenu}}"></MenuItem>
</ContextMenu>
</ListView.ContextMenu>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Margin="10"/>
</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>
</Grid>
</UserControl>

+ 33
- 0
BPASmart.RecipeManagement/View/MaterialManager.xaml.cs Visa fil

@@ -0,0 +1,33 @@
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>
/// MaterialManager.xaml 的交互逻辑
/// </summary>
public partial class MaterialManager : UserControl
{
public MaterialManager()
{
InitializeComponent();
}



}
}

+ 21
- 0
BPASmart.RecipeManagement/ViewModel/MainWindowViewModel.cs Visa fil

@@ -0,0 +1,21 @@
using BPASmart.Model.配方;
using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.RecipeManagement.ViewModel
{
public class MainWindowViewModel: ObservableObject
{

public MainWindowViewModel()
{
Json<LocalMaterails>.Read();
}

}
}

+ 106
- 0
BPASmart.RecipeManagement/ViewModel/MaterialConfigureViewModel.cs Visa fil

@@ -0,0 +1,106 @@
using BPASmart.Model.配方;
using BPASmart.RecipeManagement.Globle;
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 MaterialConfigureViewModel:ObservableObject
{

public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } }
private string _materialName;

public ObservableCollection<MaterialType> MaterialTypes { get; set; } = new ObservableCollection<MaterialType>();

public MaterialType MaterialType { get{ return _materialType; } set { _materialType = value; OnPropertyChanged(); } }
private MaterialType _materialType = 0;

public string MaterialPosion { get { return _materialPosion; } set { _materialPosion = value; OnPropertyChanged(); } }
private string _materialPosion;

public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } }
private string _errorMessage;

public RelayCommand SaveCommand { get; set; }

public MaterialConfigureViewModel()
{
if(GlobleData.ChangeMaterail != null)
{
MaterialName = GlobleData.ChangeMaterail.Name;
MaterialType = GlobleData.ChangeMaterail.MaterialType;
MaterialPosion = GlobleData.ChangeMaterail.MaterialPosion;
}

foreach(MaterialType item in Enum.GetValues(typeof(MaterialType)))
{
MaterialTypes.Add(item);
}


SaveCommand = new RelayCommand(() =>
{
if(MaterialName == null)
{
ErrorMessage = "原料名称不能为空";
return;
}
if(GlobleData.ChangeMaterail!=null)//编辑原料
{
var res = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p=>p.ID == GlobleData.ChangeMaterail.ID);
if (res != null)
{
res.Name = MaterialName;
res.MaterialType = MaterialType;
res.MaterialPosion = MaterialPosion;
Json<LocalMaterails>.Save();
ErrorMessage = "保存成功";
}
}
else //添加新原料
{
if(Json<LocalMaterails>.Data.locaMaterails != null)
{
var res = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.Name == MaterialName);
if (res != null)
{
ErrorMessage = "原料名称已存在";
return;
}
Json<LocalMaterails>.Data.locaMaterails.Add(new RecipeMaterials
{
ID = Guid.NewGuid().ToString(),
Name = MaterialName,
MaterialType = MaterialType,
MaterialPosion = MaterialPosion
});
Json<LocalMaterails>.Save();
ErrorMessage = "保存成功";
}
else
{
Json<LocalMaterails>.Data.locaMaterails.Add(new RecipeMaterials
{
ID = Guid.NewGuid().ToString(),
Name = MaterialName,
MaterialType = MaterialType,
MaterialPosion = MaterialPosion
});
Json<LocalMaterails>.Save();
ErrorMessage = "保存成功";
}
}
});
}
}
}

+ 67
- 0
BPASmart.RecipeManagement/ViewModel/MaterialManagerViewModel.cs Visa fil

@@ -0,0 +1,67 @@
using System;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using BPASmart.Model.配方;
using Microsoft.Toolkit.Mvvm.Input;
using BPASmart.RecipeManagement.View;
using System.Windows.Controls;
using BPASmart.RecipeManagement.Globle;
using BPASmartClient.Helper;

namespace BPASmart.RecipeManagement.ViewModel
{
public class MaterialManagerViewModel:ObservableObject
{
/// <summary>
/// 原料集合
/// </summary>
public ObservableCollection<RecipeMaterials> MaterialList { get; set; } = Json<LocalMaterails>.Data.locaMaterails;

public RelayCommand CreateMaterailCommand { get; set; }
public RelayCommand<object> EditMaterailCommand { get; set; }
public RelayCommand<object> DeleteMaterailCommand { get; set; }

private void EditMaterail(object o)
{
if(o == null) return;
if(o is int item)
{
GlobleData.ChangeMaterail = new RecipeMaterials();
GlobleData.ChangeMaterail = MaterialList[item];
MaterialConfigure materialConfigure = new MaterialConfigure();
materialConfigure.ShowDialog();
}
}

private void DeleteMaterail(object o)
{
if (o == null) return;
if (o is int item)
{
MaterialList.RemoveAt(item);
Json<LocalMaterails>.Save();
}
}

public MaterialManagerViewModel()
{

CreateMaterailCommand = new RelayCommand(() =>
{
GlobleData.ChangeMaterail = null;
MaterialConfigure materialConfigure = new MaterialConfigure();
materialConfigure.ShowDialog();
});

EditMaterailCommand = new RelayCommand<object>(EditMaterail);

DeleteMaterailCommand = new RelayCommand<object>(DeleteMaterail);
}
}
}

+ 10
- 0
BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj Visa fil

@@ -9,10 +9,20 @@
<ApplicationIcon>hbl.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="image\down.png" />
</ItemGroup>

<ItemGroup>
<Content Include="hbl.ico" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="image\down.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" />


Binär
Visa fil


+ 24
- 1
SmartClient.sln Visa fil

@@ -164,7 +164,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.Model", "BPASmart.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.Server", "BPASmart.Server\BPASmart.Server.csproj", "{F67FBFAC-6C80-466D-A596-1B9B10E885FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Communication", "Communication\Communication.csproj", "{1062F7C7-0117-413C-A45E-8F9B525FC036}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Communication", "Communication\Communication.csproj", "{1062F7C7-0117-413C-A45E-8F9B525FC036}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.RecipeManagement", "BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj", "{A6059469-4CCB-4ACD-A739-C83549DD0D40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -1520,6 +1522,26 @@ Global
{1062F7C7-0117-413C-A45E-8F9B525FC036}.Release|x64.Build.0 = Release|Any CPU
{1062F7C7-0117-413C-A45E-8F9B525FC036}.Release|x86.ActiveCfg = Release|Any CPU
{1062F7C7-0117-413C-A45E-8F9B525FC036}.Release|x86.Build.0 = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|ARM.Build.0 = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|ARM64.Build.0 = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|x64.ActiveCfg = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|x64.Build.0 = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|x86.ActiveCfg = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Debug|x86.Build.0 = Debug|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|Any CPU.Build.0 = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|ARM.ActiveCfg = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|ARM.Build.0 = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|ARM64.ActiveCfg = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|ARM64.Build.0 = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|x64.ActiveCfg = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|x64.Build.0 = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|x86.ActiveCfg = Release|Any CPU
{A6059469-4CCB-4ACD-A739-C83549DD0D40}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1596,6 +1618,7 @@ Global
{5083C91F-B23E-445D-8B7F-AF87E636E847} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086}
{F67FBFAC-6C80-466D-A596-1B9B10E885FC} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086}
{1062F7C7-0117-413C-A45E-8F9B525FC036} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086}
{A6059469-4CCB-4ACD-A739-C83549DD0D40} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


Laddar…
Avbryt
Spara