Browse Source

添加新版本recipe edit界面

lixiang 1 year ago
parent
commit
54ce578158

+ 30 - 10
Venus/RecipeEditorControl/ViewModel/RecipeEditorControlViewModel.cs

@@ -32,8 +32,10 @@ namespace Aitex.UI.RecipeEditor
     
 
         public RecipeEditorControlViewModel()
-        {           
-
+        {
+            solidColorBrushes.Add(new SolidColorBrush(Colors.Coral));
+            solidColorBrushes.Add(new SolidColorBrush(Colors.Cyan));
+            solidColorBrushes.Add(new SolidColorBrush(Colors.Honeydew));
         }
 
 
@@ -60,9 +62,9 @@ namespace Aitex.UI.RecipeEditor
         public void OnDeleteStep()
         {
             if (CurrentRecipe != null&& CurrentRecipe.Steps.Count>0)
-            {
+            {              
                 CurrentRecipe.Steps.RemoveAt(CurrentRecipe.Steps.Count - 1);
-                currentGrid.ColumnDefinitions.RemoveAt(currentGrid.ColumnDefinitions.Count-1);
+                LoadRecipe(CurrentRecipe);
             }           
         }
 
@@ -83,9 +85,9 @@ namespace Aitex.UI.RecipeEditor
 
             CurrentRecipe = recipe;
             Grid grid = new Grid();
-            
+            grid.Margin = new Thickness(15);
             GridOptions.SetShowBorder(grid, true);
-            GridOptions.SetLineBrush(grid, Brushes.White);
+            GridOptions.SetLineBrush(grid, Brushes.Black);
             GridOptions.SetLineThickness(grid, 1);
 
             recipe.Steps.ToList().ForEach(x =>
@@ -203,6 +205,8 @@ namespace Aitex.UI.RecipeEditor
                         case "Int32":
                         case "String":
                             TextBox textBox = new TextBox();
+                            textBox.BorderThickness = new Thickness(0);
+                            //textBox.Background = new SolidColorBrush(Colors.BurlyWood);
                             textBox.SetBinding(TextBox.TextProperty, binding);
                             grid.Children.Add(textBox);
                             Grid.SetRow(textBox, i);
@@ -216,6 +220,9 @@ namespace Aitex.UI.RecipeEditor
 
                         case "Boolean":
                             CheckBox checkBox = new CheckBox();
+                            //checkBox.Background = new SolidColorBrush(Colors.BurlyWood);
+                            //checkBox.Margin = new Thickness(5);
+
                             checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
                             grid.Children.Add(checkBox);
                             Grid.SetRow(checkBox, i);
@@ -224,6 +231,11 @@ namespace Aitex.UI.RecipeEditor
 
                         default:
                             ComboBox comboBox = new ComboBox();
+                            comboBox.BorderThickness = new Thickness(0);
+                            comboBox.Style = new Style();
+                         
+
+                            //comboBox.Background=new SolidColorBrush(Colors.BurlyWood);
                             comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
                             ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
                             grid.Children.Add(comboBox);
@@ -241,7 +253,7 @@ namespace Aitex.UI.RecipeEditor
                         TextBlock textBlock = new TextBlock();
                         textBlock.Text = propertyInfoName;
                         grid.Children.Add(textBlock);
-
+                        textBlock.Background = new SolidColorBrush(Colors.BurlyWood);
                         Grid.SetRow(textBlock, i);
                         Grid.SetColumn(textBlock, 0);
                     }
@@ -285,11 +297,13 @@ namespace Aitex.UI.RecipeEditor
                     var item = propertyInfo.PropertyType.Name;
                     if (propertyInfo.Name == "UnitName")
                     {
-                        TextBlock textBlock1 = new TextBlock();
+                        TextBox textBlock1 = new TextBox();
 
                         //textBlock1.SetBinding(TextBlock.TextProperty, binding);
                         textBlock1.Text = propertyInfo.GetValue(x).ToString();
+                        textBlock1.BorderThickness = new Thickness(0);
                         textBlock1.Foreground = Brushes.Red;
+                        textBlock1.IsReadOnly = true;
                         //textBlock1.HorizontalAlignment = HorizontalAlignment.Center;
                         grid.Children.Add(textBlock1);
                         Grid.SetRow(textBlock1, i);
@@ -303,6 +317,8 @@ namespace Aitex.UI.RecipeEditor
                             case "String":
                                 TextBox textBox = new TextBox();
                                 textBox.BorderBrush = Brushes.Transparent;
+                                textBox.BorderThickness = new Thickness(0);
+
                                 textBox.SetBinding(TextBox.TextProperty, binding);
                                 grid.Children.Add(textBox);
                                 Grid.SetRow(textBox, i);
@@ -316,6 +332,7 @@ namespace Aitex.UI.RecipeEditor
 
                             case "Boolean":
                                 CheckBox checkBox = new CheckBox();
+                                checkBox.Margin = new Thickness(1);
                                 checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
                                 grid.Children.Add(checkBox);
                                 Grid.SetRow(checkBox, i);
@@ -324,8 +341,9 @@ namespace Aitex.UI.RecipeEditor
 
                             default:
                                 ComboBox comboBox = new ComboBox();
-                                comboBox.BorderBrush = Brushes.Transparent;
-                                //comboBox.Background = Brushes.White;
+                                comboBox.Style = new Style();
+                                comboBox.BorderThickness = new Thickness(0);
+                                comboBox.Background = Brushes.White;
                                 string path = propertyInfo.Name;
                                 comboBox.SetBinding(ComboBox.SelectedItemProperty, binding);
                                 ItemsControlHelper.SetEnumValuesToItemsSource(comboBox, true);
@@ -339,6 +357,8 @@ namespace Aitex.UI.RecipeEditor
                     {
                         TextBlock textBlock = new TextBlock();
                         textBlock.Text = propertyInfo.Name;
+                        textBlock.Background = solidColorBrushes[k % 3];
+
                         grid.Children.Add(textBlock);
                         Grid.SetRow(textBlock, i);
                         Grid.SetColumn(textBlock, 0);

+ 35 - 0
Venus/Venus_MainPages/Unity/GlobalFunction.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Venus_MainPages.Unity
+{
+    internal static class GlobalFunction
+    {
+        public static T GetDictionary<T>(Dictionary<string, object> valuePairs, string str)
+        {
+            if (valuePairs.TryGetValue(str, out object result))
+            {
+                return (T)result;
+
+            }
+            else
+            {
+                return default(T);
+            }
+        }
+        public static T GetDictionaryValue<T>(Dictionary<string, object> valuePairs, string str)
+        {
+            if (valuePairs.Keys.Contains(str))
+            {
+                return (T)Convert.ChangeType(valuePairs[str], typeof(T));
+            }
+            else
+            {
+                return default(T);
+            }
+        }
+    }
+}

+ 36 - 0
Venus/Venus_MainPages/Views/RecipeView.xaml

@@ -12,6 +12,42 @@
     <UserControl.Resources>
         <Style TargetType="Button" x:Key="MiddleButton"  BasedOn="{StaticResource {x:Type Button}}" />
         <Style TargetType="Button"></Style>
+        <Style TargetType="{x:Type CheckBox}">
+            <Setter Property="Background" Value="White" />
+            <Setter Property="BorderBrush" Value="#FF262E34"/>
+            <Setter Property="Foreground" Value="#FF262E34"/>
+            <Setter Property="BorderThickness" Value="1"/>
+            <Setter Property="Template">
+                <Setter.Value>
+                    <ControlTemplate TargetType="{x:Type CheckBox}">
+                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="White">
+                            <Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" Width="15" Height="15" Margin="1,0,0,0">
+                                <!--                                   your color here -->
+                                <Path Width="15" Height="10"  Stroke="HotPink" StrokeThickness="3" Name="eliCheck" Data="M 2,4 C 2,4 3,5 5,13 C 5,13 5,3 12,0" Visibility="Collapsed"/>
+                            </Border>
+                            <TextBlock Margin="5,0,0,0"  VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}"></TextBlock>
+                        </StackPanel>
+                        <ControlTemplate.Triggers>
+                            <Trigger Property="IsMouseOver" Value="True">
+                                <Setter Property="Background" Value="LightGray" />
+                            </Trigger>
+                            <Trigger Property="IsPressed" Value="True">
+                                <Setter Property="Background" Value="#FF9C9E9F" />
+                            </Trigger>
+                            <Trigger Property="IsEnabled" Value="False">
+                                <Setter Property="Background" Value="LightGray" />
+                                <Setter Property="Foreground" Value="Gray" />
+                                <Setter Property="BorderBrush" Value="Gray"/>
+                                <Setter TargetName="eliCheck" Property="Opacity" Value="0.5" />
+                            </Trigger>
+                            <Trigger Property="IsChecked" Value="True">
+                                <Setter TargetName="eliCheck" Property="Visibility" Value="Visible"></Setter>
+                            </Trigger>
+                        </ControlTemplate.Triggers>
+                    </ControlTemplate>
+                </Setter.Value>
+            </Setter>
+        </Style>
     </UserControl.Resources>
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="Loaded">