From 3cb7be72632db59b36be278809dcc5ccd526fdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Mon, 13 Jun 2022 16:39:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=85=8D=E6=96=B9=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Themes/Generic.xaml | 11 +- .../UserControls/IcoButton.cs | 49 +++- DosingSystem/Model/LocaPar.cs | 14 + DosingSystem/Model/RecipeModel.cs | 37 +++ DosingSystem/View/MainWindow.xaml | 184 +------------- DosingSystem/View/NewRecipeView.xaml | 203 +++++++++++++++ DosingSystem/View/NewRecipeView.xaml.cs | 31 +++ DosingSystem/View/RecipeSettingsView.xaml | 240 +++++++++++++++++- DosingSystem/ViewModel/MainViewModel.cs | 3 +- DosingSystem/ViewModel/NewRecipeViewModel.cs | 111 ++++++++ .../ViewModel/RecipeSettingsViewModel.cs | 22 ++ 11 files changed, 710 insertions(+), 195 deletions(-) create mode 100644 DosingSystem/Model/LocaPar.cs create mode 100644 DosingSystem/Model/RecipeModel.cs create mode 100644 DosingSystem/View/NewRecipeView.xaml create mode 100644 DosingSystem/View/NewRecipeView.xaml.cs create mode 100644 DosingSystem/ViewModel/NewRecipeViewModel.cs diff --git a/BPASmartClient.CustomResource/Themes/Generic.xaml b/BPASmartClient.CustomResource/Themes/Generic.xaml index df62dff6..4bbc2757 100644 --- a/BPASmartClient.CustomResource/Themes/Generic.xaml +++ b/BPASmartClient.CustomResource/Themes/Generic.xaml @@ -15,10 +15,6 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" /> - + diff --git a/BPASmartClient.CustomResource/UserControls/IcoButton.cs b/BPASmartClient.CustomResource/UserControls/IcoButton.cs index ddec3c05..aa8a72c3 100644 --- a/BPASmartClient.CustomResource/UserControls/IcoButton.cs +++ b/BPASmartClient.CustomResource/UserControls/IcoButton.cs @@ -72,6 +72,28 @@ namespace BPASmartClient.CustomResource.UserControls DependencyProperty.Register("Command", typeof(Action), typeof(IcoButton), new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); + + public Action CommandObj + { + get { return (Action)GetValue(CommandObjProperty); } + set { SetValue(CommandObjProperty, value); } + } + public static readonly DependencyProperty CommandObjProperty = + DependencyProperty.Register("CommandObj", typeof(Action), typeof(IcoButton), + new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); + + + //public object CommandPar + //{ + // get { return (object)GetValue(CommandParProperty); } + // set { SetValue(CommandParProperty, value); } + //} + //public static readonly DependencyProperty CommandParProperty = + // DependencyProperty.Register("CommandPar", typeof(object), typeof(IcoButton), + // new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); + + + public string Content { get { return (string)GetValue(ContentProperty); } @@ -110,13 +132,29 @@ namespace BPASmartClient.CustomResource.UserControls new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(OnPropertyChanged))); + public Brush EnableColor + { + get { return (Brush)GetValue(EnableColorProperty); } + set { SetValue(EnableColorProperty, value); } + } + public static readonly DependencyProperty EnableColorProperty = + DependencyProperty.Register("EnableColor", typeof(Brush), typeof(IcoButton), + new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(OnPropertyChanged))); + + + public override void OnApplyTemplate() { base.OnApplyTemplate(); var icon = base.GetTemplateChild("PART_icoText") as TextBlock; var content = base.GetTemplateChild("PART_content") as TextBlock; var gr = base.GetTemplateChild("PART_gr") as Grid; - + //if (!this.IsEnabled) + //{ + // this.Foreground = EnableColor; + // this.BorderBrush = EnableColor; + //} + //this.IsEnabledChanged += IcoButton_IsEnabledChanged; if (icon != null) { Binding binding = new Binding("IcoText"); @@ -141,6 +179,15 @@ namespace BPASmartClient.CustomResource.UserControls } } + private void IcoButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) + { + //if (!this.IsEnabled) + //{ + // this.Foreground = EnableColor; + // this.BorderBrush = EnableColor; + //} + } + /// /// 鼠标离开颜色 /// diff --git a/DosingSystem/Model/LocaPar.cs b/DosingSystem/Model/LocaPar.cs new file mode 100644 index 00000000..3addd1f2 --- /dev/null +++ b/DosingSystem/Model/LocaPar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Collections.ObjectModel; + +namespace DosingSystem.Model +{ + public class LocaPar + { + public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + } +} diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs new file mode 100644 index 00000000..8fdeedba --- /dev/null +++ b/DosingSystem/Model/RecipeModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DosingSystem.ViewModel; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace DosingSystem.Model +{ + public class RecipeModel : ObservableObject + { + + /// + /// 序号 + /// + public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } + private int _mSerialNum; + + /// + /// 配方名称 + /// + public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } + private string _mRecipeName; + + /// + /// 配方编码 + /// + public string RecipCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } + private string _mRecipCode; + + public ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); + + + } +} diff --git a/DosingSystem/View/MainWindow.xaml b/DosingSystem/View/MainWindow.xaml index 901dea26..45e64487 100644 --- a/DosingSystem/View/MainWindow.xaml +++ b/DosingSystem/View/MainWindow.xaml @@ -13,7 +13,7 @@ Height="800" AllowsTransparency="True" Background="{x:Null}" - Topmost="True" + Topmost="False" WindowStartupLocation="CenterScreen" WindowStyle="None" mc:Ignorable="d"> @@ -235,38 +235,6 @@ Foreground="#feffff" Text="{Binding WindowTitleName}" /> - - @@ -280,154 +248,4 @@ - - - - - - - - - - - - - - - - - diff --git a/DosingSystem/View/NewRecipeView.xaml b/DosingSystem/View/NewRecipeView.xaml new file mode 100644 index 00000000..2525f588 --- /dev/null +++ b/DosingSystem/View/NewRecipeView.xaml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +