|
@@ -9,6 +9,7 @@ using System.Windows.Controls;
|
|
|
using System.Windows.Data;
|
|
|
using System.Windows.Media;
|
|
|
using Venus_Core;
|
|
|
+using Venus_Core.Attributes;
|
|
|
|
|
|
namespace Aitex.UI.RecipeEditor
|
|
|
{
|
|
@@ -25,7 +26,7 @@ namespace Aitex.UI.RecipeEditor
|
|
|
|
|
|
public StackPanel GridStackPanel { get; set; } //step容器
|
|
|
List<SolidColorBrush> solidColorBrushes = new List<SolidColorBrush>();//step模块颜色
|
|
|
- public StackPanel HeadStackPanel { get; set; } //head容器
|
|
|
+ public WrapPanel HeadWrapPanel { get; set; } //head容器
|
|
|
|
|
|
|
|
|
|
|
@@ -57,6 +58,7 @@ namespace Aitex.UI.RecipeEditor
|
|
|
recipeStep.LstUnit.Add(new GasControlUnit());
|
|
|
recipeStep.LstUnit.Add(new ESCHVUnit());
|
|
|
recipeStep.LstUnit.Add(new ProcessKitUnit());
|
|
|
+ recipeStep.StepNo = GridStackPanel.Children.Count;
|
|
|
|
|
|
CurrentRecipe.Steps.Add(recipeStep);
|
|
|
var item = RecipeStepToGrid(recipeStep);
|
|
@@ -81,31 +83,39 @@ namespace Aitex.UI.RecipeEditor
|
|
|
public void LoadRecipe(Recipe recipe)
|
|
|
{
|
|
|
GridStackPanel.Children.Clear();
|
|
|
- CurrentRecipe =recipe;
|
|
|
+ CurrentRecipe = null;
|
|
|
+
|
|
|
+ GC.Collect(); // This should pick up the control removed at a previous MouseDown
|
|
|
+ GC.WaitForPendingFinalizers(); // Doesn't help either
|
|
|
+ GC.Collect();
|
|
|
+ GC.WaitForPendingFinalizers(); // Doesn't help either
|
|
|
+
|
|
|
+ CurrentRecipe = recipe;
|
|
|
recipe.Steps.ToList().ForEach(x =>
|
|
|
{
|
|
|
var tupleValue = RecipeStepToGrid(x);
|
|
|
GridStackPanel.Children.Add(tupleValue.Item1);
|
|
|
});
|
|
|
|
|
|
- LoadHeadStackPanel(recipe);
|
|
|
+ LoadHeadWrapPanel(recipe);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 选中recipe,头部界面显示
|
|
|
/// </summary>
|
|
|
/// <param name="recipe"></param>
|
|
|
- private void LoadHeadStackPanel(Recipe recipe)
|
|
|
+ private void LoadHeadWrapPanel(Recipe recipe)
|
|
|
{
|
|
|
- HeadStackPanel.Children.Clear();
|
|
|
+ HeadWrapPanel.Children.Clear();
|
|
|
Type type = recipe.Header.GetType();
|
|
|
foreach (var propertyInfo in type.GetProperties())
|
|
|
{
|
|
|
TextBlock textBlock = new TextBlock();
|
|
|
textBlock.FontSize = 15;
|
|
|
+ //textBlock.Width = 100;
|
|
|
textBlock.Text = propertyInfo.Name + ":";
|
|
|
textBlock.Margin = new Thickness(15, 0, 0, 0);
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Center;
|
|
|
- HeadStackPanel.Children.Add(textBlock);
|
|
|
+ HeadWrapPanel.Children.Add(textBlock);
|
|
|
Binding binding = new Binding()
|
|
|
{
|
|
|
Source = recipe.Header, // 数据源
|
|
@@ -122,15 +132,23 @@ namespace Aitex.UI.RecipeEditor
|
|
|
case "Int32":
|
|
|
case "String":
|
|
|
control = new TextBox();
|
|
|
- //control.Margin = new Thickness(1, 0, 0, 0);
|
|
|
- control.BorderThickness = new Thickness(0);
|
|
|
+
|
|
|
+ control.Margin = new Thickness(1, 0, 0, 0);
|
|
|
+ control.BorderThickness = new Thickness(0,0,0,1);
|
|
|
+ //control.BorderBrush = Brushes.Black;
|
|
|
control.FontSize = 15;
|
|
|
control.Foreground = Brushes.Green;
|
|
|
control.Background = Brushes.Transparent;
|
|
|
control.VerticalAlignment = VerticalAlignment.Center;
|
|
|
control.MinWidth = 15;
|
|
|
+ //control.Width = 200;
|
|
|
control.SetBinding(TextBox.TextProperty, binding);
|
|
|
- if (propertyInfoName == "Name" || propertyInfoName == "CreateTime" || propertyInfoName == "LastModifiedBy")
|
|
|
+ //if (propertyInfoName == "Name" || propertyInfoName == "CreateTime" || propertyInfoName == "LastModifiedBy")
|
|
|
+ //{
|
|
|
+ // (control as TextBox).IsReadOnly = true;
|
|
|
+ //}
|
|
|
+ object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
|
|
|
+ if (objAttrs.Length > 0)
|
|
|
{
|
|
|
(control as TextBox).IsReadOnly = true;
|
|
|
}
|
|
@@ -143,12 +161,12 @@ namespace Aitex.UI.RecipeEditor
|
|
|
|
|
|
default:
|
|
|
control = new ComboBox();
|
|
|
- control.Height = 25;
|
|
|
+ control.Height = 23;
|
|
|
control.SetBinding(ComboBox.SelectedItemProperty, binding);
|
|
|
ItemsControlHelper.SetEnumValuesToItemsSource(control, true);
|
|
|
break;
|
|
|
}
|
|
|
- HeadStackPanel.Children.Add(control);
|
|
|
+ HeadWrapPanel.Children.Add(control);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -169,7 +187,7 @@ namespace Aitex.UI.RecipeEditor
|
|
|
GridOptions.SetShowBorder(grid, true);
|
|
|
GridOptions.SetLineBrush(grid, Brushes.White);
|
|
|
GridOptions.SetLineThickness(grid, 1);
|
|
|
- grid.Margin = new Thickness(15, 0, 0, 0);
|
|
|
+ grid.Margin = new Thickness(15, 5, 0, 0);
|
|
|
|
|
|
Type recipeType = recipeStep.GetType();
|
|
|
int i = 0;
|
|
@@ -198,6 +216,11 @@ namespace Aitex.UI.RecipeEditor
|
|
|
grid.Children.Add(textBox);
|
|
|
Grid.SetRow(textBox, i);
|
|
|
Grid.SetColumn(textBox, 1);
|
|
|
+ object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
|
|
|
+ if (objAttrs.Length > 0)
|
|
|
+ {
|
|
|
+ textBox.IsReadOnly = true;
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
case "Boolean":
|
|
@@ -276,6 +299,11 @@ namespace Aitex.UI.RecipeEditor
|
|
|
grid.Children.Add(textBox);
|
|
|
Grid.SetRow(textBox, i);
|
|
|
Grid.SetColumn(textBox, 1);
|
|
|
+ object[] objAttrs = propertyInfo.GetCustomAttributes(typeof(IsOnlyReadAttribute), true);
|
|
|
+ if (objAttrs.Length > 0)
|
|
|
+ {
|
|
|
+ textBox.IsReadOnly = true;
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
case "Boolean":
|
|
@@ -312,6 +340,8 @@ namespace Aitex.UI.RecipeEditor
|
|
|
return new ValueTuple<Grid, List<int>>(grid, ints);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
if (e.RemovedItems.Count > 0)
|