Browse Source

1add dummy recipe save check
2revise dummy recipe view logic

chenzk 1 week ago
parent
commit
b60aedb80f

+ 6 - 1
PunkHPX8_MainPages/ViewModels/DepRecipeViewModel.cs

@@ -413,12 +413,17 @@ namespace PunkHPX8_MainPages.ViewModels
                     platingsteps++;
                     if(obj.BiDireaction && obj.BiDFrequency == 0)
                     {
-                        MessageBox.Show("Frequency can not set 0 when Bi-Direction is true,Save Recipe Failed", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Information);
+                        MessageBox.Show("Frequency can not set 0 when Bi-Direction is true,Save Recipe Failed", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
                         return;
                     }
                 }
                 //计算Deposition PlatingSteps
                 Recipe.DepStepCount = platingsteps;
+                if(platingsteps == 0)
+                {
+                    MessageBox.Show("Deposition Steps can not null", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return;
+                }
                 //计算Deposition Totaltimes
                 string date = string.Empty;
                 var seconds = (int)(totaltime % 60);

+ 5 - 0
PunkHPX8_MainPages/ViewModels/DqdrRecipeViewModel.cs

@@ -373,6 +373,11 @@ namespace PunkHPX8_MainPages.ViewModels
         {
             if (CheckValid(_isEdit))
             {
+                if (!Recipe.IsIdentical)
+                {
+                    MessageBox.Show("Dummy recipe time is not equal to releated Dep Recipe", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return;
+                }
                 Recipe.SaveDate = DateTime.Now;
                 try
                 {

+ 1 - 0
PunkHPX8_Themes/UserControls/RecipeControlMetal.xaml

@@ -50,6 +50,7 @@
                                  SelectedRecipeNode="{Binding ElementName=self,Path=SelectedRecipeNode,Mode=TwoWay}"
                                  IsEngineeringMode ="{Binding ElementName=self,Path=IsEngineering,Mode=TwoWay}"
                                  IsProductionMode ="{Binding ElementName=self,Path=IsProduction,Mode=TwoWay}"
+                                 IsDummyLoadSelected ="{Binding ElementName=self,Path=IsDummyLoadSelected}"
                                  />
             <Grid Grid.Row="8" Grid.Column="1" Grid.RowSpan="2" Grid.ColumnSpan="2">
                 <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">

+ 42 - 17
PunkHPX8_Themes/UserControls/RecipeLoadControl.xaml.cs

@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.Linq;
+using System.Runtime.CompilerServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows;
@@ -68,7 +69,31 @@ namespace PunkHPX8_Themes.UserControls
             get { return (ObservableCollection<RecipeNode>)this.GetValue(RecipeNodesProperty); }
             set { this.SetValue(RecipeNodesProperty, value); }
         }
-
+        
+        public static readonly DependencyProperty IsDummyLoadSelectedProperty = DependencyProperty.Register(
+                "IsDummyLoadSelected", typeof(bool), typeof(RecipeLoadControl), new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnItemsSourceChanged)));
+        /// <summary>
+        /// IsDummyLoadSelected
+        /// </summary>
+        public bool IsDummyLoadSelected
+        {
+            get
+            {
+                return (bool)this.GetValue(IsDummyLoadSelectedProperty);
+            }
+            set
+            {
+                this.SetValue(IsDummyLoadSelectedProperty, value);
+            }
+        }
+        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            // 将 DependencyObject 转换为当前控件实例
+            if (d is RecipeLoadControl control)
+            {
+                control.UpdateRecipeNodes(); // 调用共用逻辑
+            }
+        }
 
         private void Self_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
         {
@@ -77,22 +102,7 @@ namespace PunkHPX8_Themes.UserControls
                 bool result = (bool)e.NewValue;
                 if (result)
                 {
-                    if (!string.IsNullOrEmpty(RecipeType))
-                    {
-                        RecipeNodes = RecipeClient.Instance.Service.GetRecipesByType(RecipeType);
-                        if ("dep".Equals(RecipeType))
-                        {
-                            ObservableCollection<RecipeNode> DqdrRecipeNodes = RecipeClient.Instance.Service.GetRecipesByType("dqdr");
-                            if (DqdrRecipeNodes != null)
-                            {
-                                foreach(var item in DqdrRecipeNodes)
-                                {
-                                    RecipeNodes.Add(item);
-                                }
-                            }
-                        }
-                    }
-                    
+                    UpdateRecipeNodes();
                 }
             }
         }
@@ -151,5 +161,20 @@ namespace PunkHPX8_Themes.UserControls
                 SelectedRecipeNode = null;
             }
         }
+
+        private void UpdateRecipeNodes()
+        {
+            if (!string.IsNullOrEmpty(RecipeType))
+            {
+                if ("dep".Equals(RecipeType) && IsDummyLoadSelected)
+                {
+                    RecipeNodes = RecipeClient.Instance.Service.GetRecipesByType("dqdr");
+                }
+                else
+                {
+                    RecipeNodes = RecipeClient.Instance.Service.GetRecipesByType(RecipeType);
+                }
+            }
+        }
     }
 }