Przeglądaj źródła

修改界面状态显示的整体架构,使其后期跟方便优化改进

KWD 4 miesięcy temu
rodzic
commit
8be99af47d

+ 22 - 22
TeamAAS-VM/App.xaml

@@ -1,35 +1,37 @@
-<prism:PrismApplication x:Class="TeamAAS_VP.App"
-                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-                        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
-                        xmlns:c="clr-namespace:TeamAAS_VP.ValueConverter"
-                        xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
-                        xmlns:local="clr-namespace:TeamAAS_VP"
-                        xmlns:prism="http://prismlibrary.com/">
+<prism:PrismApplication
+    x:Class="TeamAAS_VP.App"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:c="clr-namespace:TeamAAS_VP.ValueConverter"
+    xmlns:local="clr-namespace:TeamAAS_VP"
+    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf">
     <Application.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
-                
+
                 <!--<ResourceDictionary Source="Resources/Languages1/Chinese.xaml" />-->
                 <ResourceDictionary Source="Resources\Styles\DefaultColors.xaml" />
 
                 <ResourceDictionary Source="Resources/FontSize/DefaultFontSize.xaml" />
 
-                <materialDesign:BundledTheme BaseTheme="Inherit"
-                                             PrimaryColor="DeepPurple"
-                                             SecondaryColor="Purple" />
-                <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
+                <materialDesign:BundledTheme
+                    BaseTheme="Inherit"
+                    PrimaryColor="DeepPurple"
+                    SecondaryColor="Purple" />
+                <!--  MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive!  -->
                 <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
-                <!-- Theme setting -->
+                <!--  Theme setting  -->
                 <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
-                
-                <!--MaterialDesign-->
+
+                <!--  MaterialDesign  -->
                 <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign3.Defaults.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
                 <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.Lime.xaml" />
-                <!--MaterialDesign-->
+                <!--  MaterialDesign  -->
 
                 <ResourceDictionary Source="pack://application:,,,/ICSharpCode.AvalonEdit;component/themes/generic.xaml" />
             </ResourceDictionary.MergedDictionaries>
@@ -38,12 +40,10 @@
             <c:StringFormatConverter x:Key="StringFormatConverter" />
             <c:InvertBooleanConverter x:Key="InvertBooleanConverter" />
             <c:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter" />
-            <c:ObjectToVisibilityConverter x:Key="ObjectToCollapsedConverter"
-                                           Invert="True" />
+            <c:ObjectToVisibilityConverter x:Key="ObjectToCollapsedConverter" Invert="True" />
             <c:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
-            <c:BooleanToVisibilityConverter x:Key="BooleanToCollapsedConverter"
-                                            Invert="True" />
+            <c:BooleanToVisibilityConverter x:Key="BooleanToCollapsedConverter" Invert="True" />
         </ResourceDictionary>
-        
+
     </Application.Resources>
 </prism:PrismApplication>

+ 225 - 92
TeamAAS-VM/Core/Management.cs

@@ -98,36 +98,14 @@ namespace TeamAAS_VP.Core
 
         #region 属性
 
-        private System.Windows.Media.Brush _StatusBackground;
-
-        public System.Windows.Media.Brush StatusBackground
-        {
-            get { return _StatusBackground; }
-            set { SetProperty(ref _StatusBackground, value); }
-        }
-
-        private System.Windows.Media.Brush _RunModelBackground;
-
-        public System.Windows.Media.Brush RunModelBackground
-        {
-            get { return _RunModelBackground; }
-            set { SetProperty(ref _RunModelBackground, value); }
-        }
-
-        private System.Windows.Media.Brush _ManualModeBackground;
-
-        public System.Windows.Media.Brush ManualModeBackground
-        {
-            get { return _ManualModeBackground; }
-            set { SetProperty(ref _ManualModeBackground, value); }
-        }
-
-        private System.Windows.Media.Brush _ClearModeBackground;
-
-        public System.Windows.Media.Brush ClearModeBackground
+        /// <summary>
+        /// 当前顶部显示的运行模式
+        /// </summary>
+        private RunDisplayMode _CurrentDisplayMode = RunDisplayMode.Unknown;
+        public RunDisplayMode CurrentDisplayMode
         {
-            get { return _ClearModeBackground; }
-            set { SetProperty(ref _ClearModeBackground, value); }
+            get { return _CurrentDisplayMode; }
+            set { SetProperty(ref _CurrentDisplayMode, value); }
         }
 
         private ObservableCollection<ShowRender> _Renders;
@@ -1261,6 +1239,7 @@ namespace TeamAAS_VP.Core
             if (plc == null || !plc.IsConnected) return;
             var current = _productService.GetCurrentProduct();
             if (current == null) return;
+            _LastAutoRunning = plc.ReadNode<bool>(addressConfig.AutoRunning.Address);
             if (current.PickCameraPoints != null && current.PickCameraPoints.Count > 0)
             {
                 foreach (var item in current.PickCameraPoints)
@@ -1685,8 +1664,8 @@ namespace TeamAAS_VP.Core
                                 {
                                     resultToMes.Add($"Screw{cameraIndex}_Fail");
                                     SendTaskMessage($"Screw{cameraIndex}:拍照失败", MessageLevel.Error);
-                                }                         
-                                
+                                }
+
                                 await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)2);
                             }
                         }
@@ -2244,7 +2223,7 @@ namespace TeamAAS_VP.Core
                         }
                     }
                 }
-                //切换成自动运行模式
+                // 切换成自动运行模式
                 else if (addressConfig.AutoRunning.Address.Contains(tuple.nodeId))
                 {
                     if (tuple.value is bool state)
@@ -2257,6 +2236,7 @@ namespace TeamAAS_VP.Core
                         {
                             return;
                         }
+
                         if (state)
                         {
                             SendTaskMessage("收到切换成自动模式", MessageLevel.Info);
@@ -2265,10 +2245,11 @@ namespace TeamAAS_VP.Core
                         {
                             SendTaskMessage("收到关闭自动模式", MessageLevel.Info);
                         }
+
                         CurrentRunStatus();
                     }
                 }
-                //切换成维修模式
+                // 切换成维修模式
                 else if (addressConfig.ManualMode.Address.Contains(tuple.nodeId))
                 {
                     if (tuple.value is bool state)
@@ -2281,16 +2262,20 @@ namespace TeamAAS_VP.Core
                         {
                             return;
                         }
+
                         if (state)
                         {
-                            ClearModeBackground = System.Windows.Media.Brushes.White;
-                            RunModelBackground = System.Windows.Media.Brushes.White;
-                            ManualModeBackground = System.Windows.Media.Brushes.Orange;
                             SendTaskMessage("收到切换成维修模式", MessageLevel.Info);
                         }
+                        else
+                        {
+                            SendTaskMessage("收到退出维修模式", MessageLevel.Info);
+                        }
+
+                        CurrentRunStatus();
                     }
                 }
-                //切换成流线模式
+                // 切换成流线模式
                 else if (addressConfig.ClearMode.Address.Contains(tuple.nodeId))
                 {
                     if (tuple.value is bool state)
@@ -2303,13 +2288,17 @@ namespace TeamAAS_VP.Core
                         {
                             return;
                         }
+
                         if (state)
                         {
-                            ClearModeBackground = System.Windows.Media.Brushes.Yellow;
-                            RunModelBackground = System.Windows.Media.Brushes.White;
-                            ManualModeBackground = System.Windows.Media.Brushes.White;
                             SendTaskMessage("收到切换成流线模式", MessageLevel.Info);
                         }
+                        else
+                        {
+                            SendTaskMessage("收到退出流线模式", MessageLevel.Info);
+                        }
+
+                        CurrentRunStatus();
                     }
                 }
                 //plc报警
@@ -2328,12 +2317,10 @@ namespace TeamAAS_VP.Core
                         if (state)
                         {
                             SendTaskMessage("收到PLC报警", MessageLevel.Error);
-                            StatusBackground = System.Windows.Media.Brushes.Red;
                         }
                         else
                         {
                             SendTaskMessage("收到PLC消除报警", MessageLevel.Debug);
-                            StatusBackground = System.Windows.Media.Brushes.Green;
                         }
                     }
                 }
@@ -2430,8 +2417,8 @@ namespace TeamAAS_VP.Core
                                 {
                                     code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
                                 }
-                                productSn = code;
 
+                                productSn = code;
 
                                 //询问mes
                                 if (state == 1)
@@ -2812,7 +2799,7 @@ namespace TeamAAS_VP.Core
                                                             PROCESS_END_TIME = serverTimeResult.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffff") + "+08:00",
                                                             SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
                                                             COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
-                                                            REVISION = stationConfig.DataInfo.REVISION+"_"+ revision[i],
+                                                            REVISION = stationConfig.DataInfo.REVISION + "_" + revision[i],
                                                             WO = wo[i],
                                                             MFG_LOT = stationConfig.DataInfo.MFG_LOT,
                                                             MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
@@ -2951,7 +2938,7 @@ namespace TeamAAS_VP.Core
                                                                     {
                                                                         SendTaskMessage($"扭力曲线图读取失败", MessageLevel.Error);
                                                                     }
-                                                                }                                                                
+                                                                }
                                                                 CompressionImage(filePath, filename, device.Station, device.FixtureId);
                                                                 //上传csv
                                                                 bool isAfter20 = dt.Hour >= 20;
@@ -3047,72 +3034,212 @@ namespace TeamAAS_VP.Core
             });
         }
 
-        public bool concurrenty = true;
+        #region 界面状态显示
+
+        // 新增字段
+        private readonly object _runStatusLock = new object();
+
+        private RunDisplayMode _lastRunDisplayMode = RunDisplayMode.Unknown;
+
+        /// <summary>
+        /// 刷新当前运行状态
+        /// </summary>
         public void CurrentRunStatus()
         {
-            if (!concurrenty)
+            lock (_runStatusLock)
             {
-                return;
+                RunDisplayMode mode;
+
+                try
+                {
+                    mode = EvaluateRunDisplayMode();
+                }
+                catch (Exception ex)
+                {
+                    LogHelper.WriteLogError("刷新运行状态时出错", ex);
+                    mode = RunDisplayMode.Manual;
+                }
+
+                ApplyRunDisplayMode(mode);
             }
-            concurrenty = true;
-            bool connectStaus = true;
-            bool mesStatus = true;
-            bool paraStatus = true;
-            try
+        }
+
+        /// <summary>
+        /// 计算当前应该显示的模式
+        /// </summary>
+        private RunDisplayMode EvaluateRunDisplayMode()
+        {
+            // 1. 流线模式优先
+            if (_LastClearMode)
+            {
+                return RunDisplayMode.Clear;
+            }
+
+            // 2. 调机模式次优先
+            if (_LastManualMode)
+            {
+                return RunDisplayMode.Manual;
+            }
+
+            // 3. 没进自动运行,默认按调机显示
+            if (!_LastAutoRunning)
+            {
+                return RunDisplayMode.Manual;
+            }
+
+            // 4. 自动运行时,再检查前置条件
+            bool connectStatus = IsAllDeviceConnected();
+            bool mesStatus = IsMesReady();
+            bool paraStatus = IsParameterReady();
+
+            if (connectStatus && mesStatus && paraStatus)
+            {
+                return RunDisplayMode.Auto;
+            }
+
+            return RunDisplayMode.Manual;
+        }
+
+        /// <summary>
+        /// 所有设备是否连接正常
+        /// </summary>
+        private bool IsAllDeviceConnected()
+        {
+            List<StatusInfo> statusSnapshot = null;
+
+            App.Current.Dispatcher.Invoke(() =>
+            {
+                statusSnapshot = Status?.ToList() ?? new List<StatusInfo>();
+            });
+
+            if (statusSnapshot.Count == 0)
             {
+                return false;
+            }
 
-                for (int i = 0; i < 1; i++)
+            foreach (var item in statusSnapshot)
+            {
+                // 注意:这里不要直接 item.Background == Brushes.Red
+                if (item?.Background is SolidColorBrush brush)
                 {
-                    var stationConfig = _configService.GetDeviceInfo(i);
-                    if (!stationConfig.EnableMES ||  !stationConfig.SaveCsv)
+                    bool res = true;
+                    App.Current.Dispatcher.Invoke(() =>
                     {
-                        SendTaskMessage("当前MES功能/保存CSV功能未启用,请检查...", MessageLevel.Info);
-                        mesStatus = false;
-                        break;
+                        if (brush.Color == Colors.Red)
+                        {
+                            SendTaskMessage("当前设备存在连接失败,请检查..." + item.Message, MessageLevel.Error);
+                            res = false;
+                        }
+                    });
+                    if (!res)
+                    {
+                        return false;
                     }
                 }
-                var systemConfig = _configService.GetSystemConfiguration();
-                if (!systemConfig.IsSaveScrewCurve)
+            }
+
+            return true;
+        }
+
+        /// <summary>
+        /// MES相关配置是否满足
+        /// </summary>
+        private bool IsMesReady()
+        {
+            var allDevices = _configService.GetAllDeviceInfos();
+
+            for (int i = 0; i < ((allDevices.Count >= 8) ? 2 : 1); i++)
+            {
+                var stationConfig = allDevices.FirstOrDefault(d => d.DeviceNo == (i == 0 ? 0 : 7));
+
+                if (stationConfig == null)
+                {
+                    SendTaskMessage("当前MES未配置,请检查...", MessageLevel.Error);
+                    return false;
+                }
+                if (string.IsNullOrEmpty(stationConfig.SaveCsvPath) && i == 0)
                 {
-                    paraStatus = false;
-                    SendTaskMessage("当前保存扭力曲线未勾选,请检查...", MessageLevel.Info);
+                    SendTaskMessage("当前CSV路径为空,请检查...", MessageLevel.Error);
+                    return false;
                 }
-                foreach (var item in Status)
+
+                if (!stationConfig.EnableMES || !stationConfig.SaveCsv)
                 {
-                    if (item.Background == System.Windows.Media.Brushes.Red)
-                    {
-                        SendTaskMessage("当前有设备未连接,请检查...", MessageLevel.Info);
-                        connectStaus = false;
-                        break;
-                    }
+                    SendTaskMessage("当前未启用MES或未启用CSV保存,请检查...", MessageLevel.Error);
+                    return false;
                 }
             }
-            catch (Exception)
+            return true;
+        }
+
+        /// <summary>
+        /// 参数相关配置是否满足
+        /// </summary>
+        private bool IsParameterReady()
+        {
+            var systemConfig = _configService.GetSystemConfiguration();
+            if (systemConfig == null)
+            {
+                SendTaskMessage("当前无系统文件,请检查...", MessageLevel.Error);
+                return false;
+            }
+
+            if (!systemConfig.IsSaveScrewCurve)
             {
-                connectStaus = false;
-                mesStatus = false;
-                paraStatus = false;
+                SendTaskMessage("当前保存扭力曲线未勾选,请检查...", MessageLevel.Error);
+                return false;
             }
-            if (connectStaus && mesStatus && paraStatus && _LastAutoRunning)
+            if (string.IsNullOrEmpty(systemConfig.ScrewCurvePath))
             {
-                RunModelBackground = System.Windows.Media.Brushes.Green;
-                ClearModeBackground = System.Windows.Media.Brushes.White;
-                ManualModeBackground = System.Windows.Media.Brushes.White;
-                SendTaskMessage("当前为生产模式", MessageLevel.Info);
+                SendTaskMessage("当前保存扭力曲线为空,请检查...", MessageLevel.Error);
+                return false;
             }
-            else
+            return true;
+
+        }
+
+        /// <summary>
+        /// 应用显示模式到UI
+        /// </summary>
+        private void ApplyRunDisplayMode(RunDisplayMode mode)
+        {
+            // 模式没变化就不重复刷UI,也不重复打日志
+            if (_lastRunDisplayMode == mode)
             {
-                RunModelBackground = System.Windows.Media.Brushes.White;
-                ClearModeBackground = System.Windows.Media.Brushes.White;
-                ManualModeBackground = System.Windows.Media.Brushes.Orange;
-                SendTaskMessage("当前为调机模式", MessageLevel.Info);
+                return;
             }
-            concurrenty = true;
+
+            _lastRunDisplayMode = mode;
+
+            App.Current.Dispatcher.Invoke(() =>
+            {
+                switch (mode)
+                {
+                    case RunDisplayMode.Auto:
+                        CurrentDisplayMode = mode;
+                        SendTaskMessage("当前为运行模式", MessageLevel.Debug);
+                        break;
+
+                    case RunDisplayMode.Clear:
+                        CurrentDisplayMode = mode;
+                        SendTaskMessage("当前为流线模式", MessageLevel.Info);
+                        break;
+
+                    case RunDisplayMode.Manual:
+                    default:
+                        CurrentDisplayMode = mode;
+                        SendTaskMessage("当前为调机模式", MessageLevel.Info);
+                        break;
+                }
+            });
         }
 
+        #endregion
+
+        #region 压力采集
 
         private float _maxPressure = float.MinValue;
-        #region Pressure collection helpers
+
         /// <summary>
         /// 开始采集压力值
         /// </summary>
@@ -3121,7 +3248,7 @@ namespace TeamAAS_VP.Core
         /// <param name="positionIndex">锁付点编号</param>
         private void StartPressureCollection(string productName, string productCode, int positionIndex)
         {
-            
+
             try
             {
                 // cancel existing if any
@@ -3150,7 +3277,7 @@ namespace TeamAAS_VP.Core
                 if (plc == null || !plc.IsConnected) return;
                 Task.Run(async () =>
                 {
-                    
+
                     SendTaskMessage($"Pressure collection started for position {positionIndex}", MessageLevel.Debug);
                     while (!token.IsCancellationRequested)
                     {
@@ -3224,7 +3351,7 @@ namespace TeamAAS_VP.Core
                     SendTaskMessage("No pressure samples collected.", MessageLevel.Info);
                     return;
                 }
-                
+
                 // save to file under configured path
                 try
                 {
@@ -3250,7 +3377,7 @@ namespace TeamAAS_VP.Core
                     {
                         _eventAggregator.GetEvent<PressureFinishNotification>().Publish((true, snapshot.ToArray(), pngPath));
                     });
-                    
+
                     //判断是否保存锁付曲线
                     if (systemConfig.IsSaveScrewCurve)
                     {
@@ -3260,7 +3387,7 @@ namespace TeamAAS_VP.Core
                             sb.AppendLine("Timestamp,Value");
                             foreach (var s in snapshot)
                             {
-                                sb.AppendLine($"{s.Timestamp:O},{s.Value}");                                
+                                sb.AppendLine($"{s.Timestamp:O},{s.Value}");
                             }
 
                             File.WriteAllText(fullPath, sb.ToString());
@@ -3304,6 +3431,8 @@ namespace TeamAAS_VP.Core
         }
         #endregion
 
+        #region 产品记录
+
         private async void DoYieldTime(object state)
         {
             try
@@ -3325,6 +3454,9 @@ namespace TeamAAS_VP.Core
             }
         }
 
+        #endregion
+
+        #region 字符判定
 
         /// <summary>
         /// 判断是否符合当站
@@ -3371,6 +3503,8 @@ namespace TeamAAS_VP.Core
 
         }
 
+        #endregion
+
         #region vm启动检测
 
         /// <summary>
@@ -3408,7 +3542,6 @@ namespace TeamAAS_VP.Core
         }
         #endregion
 
-
         #region 产品锁付记录进行存储
         /// <summary>
         /// 产品锁付记录进行存储

+ 32 - 32
TeamAAS-VM/Data/SystemDatabaseService.cs

@@ -130,7 +130,7 @@ namespace TeamAAS_VP.Data
             {
                 UserId = userId,
                 Success = true,
-                Time = DateTime.UtcNow,
+                Time = DateTime.Now,
                 Message = "Set as current user"
             };
 
@@ -150,7 +150,7 @@ namespace TeamAAS_VP.Data
             {
                 UserId = user.Id,
                 Success = true,
-                Time = DateTime.UtcNow,
+                Time = DateTime.Now,
                 Message = user.UserName
             };
             await RecordUserLoginAsync(rec);
@@ -194,7 +194,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordUserLoginAsync(UserLoginRecord record)
         {
             if (record == null) throw new ArgumentNullException(nameof(record));
-            if (record.Time == default(DateTime)) record.Time = DateTime.UtcNow;
+            if (record.Time == default(DateTime)) record.Time = DateTime.Now;
             await _db.Insertable(record).ExecuteCommandAsync();
         }
 
@@ -401,9 +401,9 @@ namespace TeamAAS_VP.Data
         public async Task<int> GetTodayProductionAsync(string productName)
         {
             //今天的起始时间
-            var todayStart = DateTime.UtcNow.Date;
+            var todayStart = DateTime.Now.Date;
             //今天的结束时间
-            var todayEnd = DateTime.UtcNow.Date;
+            var todayEnd = DateTime.Now.Date;
             todayEnd = todayEnd.AddDays(1);
             //按照产品名称和时间范围查询生产记录的总数
             var total = await _db.Queryable<ProductionRecord>()
@@ -419,8 +419,8 @@ namespace TeamAAS_VP.Data
         /// <returns></returns>
         public async Task<int> GetLastHourProductionAsync(string productName)
         {
-            var lastHourStart = DateTime.UtcNow.AddHours(-1);
-            var lastHourEnd = DateTime.UtcNow;
+            var lastHourStart = DateTime.Now.AddHours(-1);
+            var lastHourEnd = DateTime.Now;
             //按照产品名称和时间范围查询生产记录的总数
             var total = await _db.Queryable<ProductionRecord>()
                 .Where(r => r.ProductName == productName && r.Timestamp >= lastHourStart && r.Timestamp < lastHourEnd)
@@ -436,9 +436,9 @@ namespace TeamAAS_VP.Data
         public async Task<int> GetNGProductionAsync(string productName)
         {
             //今天的起始时间
-            var todayStart = DateTime.UtcNow.Date;
+            var todayStart = DateTime.Now.Date;
             //今天的结束时间
-            var todayEnd = DateTime.UtcNow.Date;
+            var todayEnd = DateTime.Now.Date;
             todayEnd = todayEnd.AddDays(1);
             //按照产品名称和时间范围查询生产记录的总数
             var total = await _db.Queryable<ProductionRecord>()
@@ -455,7 +455,7 @@ namespace TeamAAS_VP.Data
         public Task<int> GetCurrentMonthProductionAsync(string productName)
         {
 
-            var now = DateTime.UtcNow;
+            var now = DateTime.Now;
             var monthStart = new DateTime(now.Year, now.Month, 1);
             var monthEnd = monthStart.AddMonths(1);
             //按照产品名称和时间范围查询生产记录的总数
@@ -472,7 +472,7 @@ namespace TeamAAS_VP.Data
         /// <returns></returns>
         public Task<int> GetCurrentWeekProductionAsync(string productName)
         {
-            var now = DateTime.UtcNow;
+            var now = DateTime.Now;
             var weekStart = FirstDayOfWeek(now);
             var weekEnd = weekStart.AddDays(7);
             //按照产品名称和时间范围查询生产记录的总数
@@ -545,7 +545,7 @@ namespace TeamAAS_VP.Data
         /// <returns></returns>
         public async Task<Dictionary<DateTime, Dictionary<string, int>>> GetMonthlyProductionByDayAndCategoryAsync(string productName)
         {
-            var now = DateTime.UtcNow;
+            var now = DateTime.Now;
             var monthStart = new DateTime(now.Year, now.Month, 1);
             var monthEnd = monthStart.AddMonths(1);
             var list = await _db.Queryable<ProductionRecord>()
@@ -570,7 +570,7 @@ namespace TeamAAS_VP.Data
         /// <returns></returns>
         public async Task<Dictionary<int, Dictionary<string, int>>> GetWeeklyProductionByDayAndCategoryAsync(string productName)
         {
-            var now = DateTime.UtcNow;
+            var now = DateTime.Now;
             var weekStart = FirstDayOfWeek(now);
             var weekEnd = weekStart.AddDays(7);
             var list = await _db.Queryable<ProductionRecord>()
@@ -594,7 +594,7 @@ namespace TeamAAS_VP.Data
         /// <returns></returns>
         public async Task<Dictionary<int, Dictionary<string, int>>> GetDailyProductionByHourAndCategoryAsync(string productName)
         {
-            var now = DateTime.UtcNow;
+            var now = DateTime.Now;
             var dayStart = now.Date;
             var dayEnd = dayStart.AddDays(1);
             var list = await _db.Queryable<ProductionRecord>()
@@ -637,7 +637,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordAlarmAsync(AlarmRecord alarm)
         {
             if (alarm == null) throw new ArgumentNullException(nameof(alarm));
-            if (alarm.Time == default(DateTime)) alarm.Time = DateTime.UtcNow;
+            if (alarm.Time == default(DateTime)) alarm.Time = DateTime.Now;
             await _db.Insertable(alarm).ExecuteCommandAsync();
         }
 
@@ -670,7 +670,7 @@ namespace TeamAAS_VP.Data
             try
             {
                 if (result == null) throw new ArgumentNullException(nameof(result));
-                if (result.Timestamp == default(DateTime)) result.Timestamp = DateTime.UtcNow;
+                if (result.Timestamp == default(DateTime)) result.Timestamp = DateTime.Now;
                 await _db.Insertable(result).ExecuteCommandAsync();
             }
             catch (Exception)
@@ -724,7 +724,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordScrewFeederBatchAsync(ScrewFeederBatchRecord record)
         {
             if (record == null) throw new ArgumentNullException(nameof(record));
-            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.UtcNow;
+            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.Now;
             record.Id = record.Id == Guid.Empty ? Guid.NewGuid() : record.Id;
             await _db.Insertable(record).ExecuteCommandAsync();
         }
@@ -798,7 +798,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordPhotoCaptureAsync(PhotoCaptureRecord record)
         {
             if (record == null) throw new ArgumentNullException(nameof(record));
-            if (record.CaptureTime == default(DateTime)) record.CaptureTime = DateTime.UtcNow;
+            if (record.CaptureTime == default(DateTime)) record.CaptureTime = DateTime.Now;
             record.Id = record.Id == Guid.Empty ? Guid.NewGuid() : record.Id;
             await _db.Insertable(record).ExecuteCommandAsync();
         }
@@ -852,7 +852,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordHeadChangeAsync(HeadChangeRecord record)
         {
             if (record == null) throw new ArgumentNullException(nameof(record));
-            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.UtcNow;
+            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.Now;
             record.Id = record.Id == Guid.Empty ? Guid.NewGuid() : record.Id;
             await _db.Insertable(record).ExecuteCommandAsync();
         }
@@ -916,7 +916,7 @@ namespace TeamAAS_VP.Data
                 {
                     var newRec = new HeadChangeRecord
                     {
-                        ChangeTime = DateTime.UtcNow,
+                        ChangeTime = DateTime.Now,
                         HeadBatchNumber = string.Empty,
                         CurrentLockCount = 1,
                         OperatorName = operatorName
@@ -949,7 +949,7 @@ namespace TeamAAS_VP.Data
         public async Task RecordNozzleChangeAsync(NozzleChangeRecord record)
         {
             if (record == null) throw new ArgumentNullException(nameof(record));
-            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.UtcNow;
+            if (record.ChangeTime == default(DateTime)) record.ChangeTime = DateTime.Now;
             record.Id = record.Id == Guid.Empty ? Guid.NewGuid() : record.Id;
             await _db.Insertable(record).ExecuteCommandAsync();
         }
@@ -996,7 +996,7 @@ namespace TeamAAS_VP.Data
                 {
                     var newRec = new NozzleChangeRecord
                     {
-                        ChangeTime = DateTime.UtcNow,
+                        ChangeTime = DateTime.Now,
                         NozzleBatchNumber = string.Empty,
                         CurrentLockCount = 1,
                         OperatorName = operatorName
@@ -1046,7 +1046,7 @@ namespace TeamAAS_VP.Data
             {
                 var record = new NozzleChangeRecord
                 {
-                    ChangeTime = DateTime.UtcNow.AddMinutes(-i * 10),
+                    ChangeTime = DateTime.Now.AddMinutes(-i * 10),
                     NozzleBatchNumber = $"Batch-{i}",
                     CurrentLockCount = i,
                     OperatorName = $"Operator-{i}"
@@ -1059,7 +1059,7 @@ namespace TeamAAS_VP.Data
             {
                 var record = new HeadChangeRecord
                 {
-                    ChangeTime = DateTime.UtcNow.AddMinutes(-i * 15),
+                    ChangeTime = DateTime.Now.AddMinutes(-i * 15),
                     HeadBatchNumber = $"HeadBatch-{i}",
                     CurrentLockCount = i,
                     OperatorName = $"HeadOperator-{i}"
@@ -1072,7 +1072,7 @@ namespace TeamAAS_VP.Data
             {
                 var record = new ScrewFeederBatchRecord
                 {
-                    ChangeTime = DateTime.UtcNow.AddMinutes(-i * 20),
+                    ChangeTime = DateTime.Now.AddMinutes(-i * 20),
                     BatchNumber = $"ScrewBatch-{i}",
                     FeederNumber = i + 1
                 };
@@ -1088,7 +1088,7 @@ namespace TeamAAS_VP.Data
                     ProductName = "产品1",
                     Category = (i % 2 == 0) ? "OK" : "NG",
                     Quantity = 1,
-                    Timestamp = DateTime.UtcNow.AddMinutes(-i * 5),
+                    Timestamp = DateTime.Now.AddMinutes(-i * 5),
                     UserName = "TestUser",
                     Remark = $"TotalSeconds:1.10"
                 };
@@ -1101,7 +1101,7 @@ namespace TeamAAS_VP.Data
                 var result = new LockResult(i % 4, $"PN-{i % 5}", 10.5f, 0.3f, (i % 3 != 0))
                 {
                     ProductName = "产品1",
-                    Timestamp = DateTime.UtcNow.AddMinutes(-i * 3),
+                    Timestamp = DateTime.Now.AddMinutes(-i * 3),
                 };
                 await RecordLockResultAsync(result);
             }
@@ -1118,7 +1118,7 @@ namespace TeamAAS_VP.Data
                         CameraName = $"下相机",
                         ProductSN = $"SN-{i}",
                         IsSuccess = (i % 2 == 0),
-                        CaptureTime = DateTime.UtcNow.AddMinutes(-i * 7),
+                        CaptureTime = DateTime.Now.AddMinutes(-i * 7),
                         ImagePath = $"/images/photo_{i}.jpg"
                     };
                     await RecordPhotoCaptureAsync(record);
@@ -1155,9 +1155,9 @@ namespace TeamAAS_VP.Data
         public async Task<int> GetThrowNumberAsync()
         {
             //今天的起始时间
-            var todayStart = DateTime.UtcNow.Date;
+            var todayStart = DateTime.Now.Date;
             //今天的结束时间
-            var todayEnd = DateTime.UtcNow.Date;
+            var todayEnd = DateTime.Now.Date;
             todayEnd = todayEnd.AddDays(1);
             //按照时间范围查询抛料的总数
             var total = await _db.Queryable<ThrowRecord>()
@@ -1173,9 +1173,9 @@ namespace TeamAAS_VP.Data
         public async Task ResetThrowNumberAsync()
         {
             //今天的起始时间
-            var todayStart = DateTime.UtcNow.Date;
+            var todayStart = DateTime.Now.Date;
             //今天的结束时间
-            var todayEnd = DateTime.UtcNow.Date;
+            var todayEnd = DateTime.Now.Date;
             todayEnd = todayEnd.AddDays(1);
             await _db.Deleteable<ThrowRecord>().Where(r => r.DayTime >= todayStart && r.DayTime < todayEnd).ExecuteCommandAsync();
         }

+ 13 - 0
TeamAAS-VM/Enums/RunDisplayMode.cs

@@ -0,0 +1,13 @@
+namespace TeamAAS_VP.Enums
+{
+    /// <summary>
+    /// 顶部运行模式显示枚举
+    /// </summary>
+    public enum RunDisplayMode
+    {
+        Unknown = 0,
+        Auto = 1,    // 生产
+        Manual = 2,  // 调机
+        Clear = 3    // 流线
+    }
+}

+ 7 - 6
TeamAAS-VM/Resources/FontSize/DefaultFontSize.xaml

@@ -1,17 +1,18 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-                    xmlns:sys="clr-namespace:System;assembly=mscorlib">
-    <!--标题-->
+<ResourceDictionary
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:sys="clr-namespace:System;assembly=mscorlib">
+    <!--  标题  -->
     <sys:Double x:Key="Font.Size.Title1">34</sys:Double>
     <sys:Double x:Key="Font.Size.Title2">20</sys:Double>
     <sys:Double x:Key="Font.Size.Title3">18</sys:Double>
     <sys:Double x:Key="Font.Size.Title4">16</sys:Double>
-    <!--正文-->
+    <!--  正文  -->
     <sys:Double x:Key="Font.Size.Body1">18</sys:Double>
     <sys:Double x:Key="Font.Size.Body2">16</sys:Double>
     <sys:Double x:Key="Font.Size.Body3">14</sys:Double>
     <sys:Double x:Key="Font.Size.Body4">12</sys:Double>
-    <!--标注-->
+    <!--  标注  -->
     <sys:Double x:Key="Font.Size.Captions1">16</sys:Double>
     <sys:Double x:Key="Font.Size.Captions2">14</sys:Double>
     <sys:Double x:Key="Font.Size.Captions3">12</sys:Double>

+ 7 - 14
TeamAAS-VM/Resources/Styles/DefaultColors.xaml

@@ -1,15 +1,8 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-    <SolidColorBrush x:Key="DefaultBackground"
-                     Color="#424242" />
-    <SolidColorBrush x:Key="DefaultFore"
-                     Color="#F0F0F0" />
-    <SolidColorBrush x:Key="DefaultNavigationCheckedBackground"
-                     Color="Transparent" />
-    <SolidColorBrush x:Key="DefaultNavigationCheckedFore"
-                     Color="#50ac52" />
-    <SolidColorBrush x:Key="DefaultNavigationUnCheckedBackground"
-                     Color="Transparent" />
-    <SolidColorBrush x:Key="DefaultNavigationUnCheckedFore"
-                     Color="#424242" />
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <SolidColorBrush x:Key="DefaultBackground" Color="#424242" />
+    <SolidColorBrush x:Key="DefaultFore" Color="#F0F0F0" />
+    <SolidColorBrush x:Key="DefaultNavigationCheckedBackground" Color="Transparent" />
+    <SolidColorBrush x:Key="DefaultNavigationCheckedFore" Color="#50ac52" />
+    <SolidColorBrush x:Key="DefaultNavigationUnCheckedBackground" Color="Transparent" />
+    <SolidColorBrush x:Key="DefaultNavigationUnCheckedFore" Color="#424242" />
 </ResourceDictionary>

+ 1 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -540,6 +540,7 @@
     <Compile Include="Core\StabilityAnalyzer.cs" />
     <Compile Include="Core\TxtFile.cs" />
     <Compile Include="Core\VisionProFileHelper.cs" />
+    <Compile Include="Enums\RunDisplayMode.cs" />
     <Compile Include="Events\CurrentStatusNotification.cs" />
     <Compile Include="Events\DelaySaveImageNotification.cs" />
     <Compile Include="Events\MainTabSwitchNotification.cs" />

+ 240 - 160
TeamAAS-VM/Views/MainWindowView.xaml

@@ -1,26 +1,28 @@
-<Window x:Class="TeamAAS_VP.Views.MainWindowView"
-        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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
-        xmlns:prism="http://prismlibrary.com/"
-        xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
-        xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels"
-        xmlns:local="clr-namespace:TeamAAS_VP"
-        xmlns:converter="clr-namespace:TeamAAS_VP.ValueConverter"
-        xmlns:lex="http://wpflocalizeextension.codeplex.com"
-        lex:LocalizeDictionary.DesignCulture="zh-CN"
-        lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
-        lex:ResxLocalizationProvider.DefaultDictionary="Lang"
-        mc:Ignorable="d"
-        d:DataContext="{d:DesignInstance Type=vm:MainWindowViewModel}"
-        d:Height="768"
-        d:Width="1024"
-        WindowState="Maximized"
-        WindowStartupLocation="CenterScreen"
-        Closing="Window_Closing"
-        FontFamily="{DynamicResource DefaultFont}">
+<Window
+    x:Class="TeamAAS_VP.Views.MainWindowView"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+    xmlns:converter="clr-namespace:TeamAAS_VP.ValueConverter"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:lex="http://wpflocalizeextension.codeplex.com"
+    xmlns:local="clr-namespace:TeamAAS_VP"
+    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    xmlns:prism="http://prismlibrary.com/"
+    xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels"
+    xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
+    d:DataContext="{d:DesignInstance Type=vm:MainWindowViewModel}"
+    d:Height="768"
+    d:Width="1024"
+    lex:LocalizeDictionary.DesignCulture="zh-CN"
+    lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
+    lex:ResxLocalizationProvider.DefaultDictionary="Lang"
+    Closing="Window_Closing"
+    FontFamily="{DynamicResource DefaultFont}"
+    WindowStartupLocation="CenterScreen"
+    WindowState="Maximized"
+    mc:Ignorable="d">
     <Window.Title>
         <MultiBinding StringFormat=" {0} {1}">
             <Binding Path="CompanyTitle" />
@@ -30,6 +32,57 @@
     <Window.Resources>
         <converter:NavigationStateConverter x:Key="_NavigationState" />
         <converter:NavigationStateConverter1 x:Key="_NavigationState1" />
+
+        <!-- 普通状态背景 -->
+        <SolidColorBrush x:Key="ModeNormalBrush" Color="White" />
+        <!-- 生产模式背景 -->
+        <SolidColorBrush x:Key="ModeAutoBrush" Color="Green" />
+        <!-- 调机模式背景 -->
+        <SolidColorBrush x:Key="ModeManualBrush" Color="Orange" />
+        <!-- 流线模式背景 -->
+        <SolidColorBrush x:Key="ModeClearBrush" Color="Yellow" />
+
+        <!-- 生产卡片样式 -->
+        <Style x:Key="AutoModeCardStyle" TargetType="materialDesign:Card">
+            <Setter Property="Background" Value="{StaticResource ModeNormalBrush}" />
+            <Setter Property="Margin" Value="50,10" />
+            <Setter Property="HorizontalAlignment" Value="Center" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Style.Triggers>
+                <DataTrigger Binding="{Binding management.CurrentDisplayMode}"
+                         Value="{x:Static enums:RunDisplayMode.Auto}">
+                    <Setter Property="Background" Value="{StaticResource ModeAutoBrush}" />
+                </DataTrigger>
+            </Style.Triggers>
+        </Style>
+
+        <!-- 调机卡片样式 -->
+        <Style x:Key="ManualModeCardStyle" TargetType="materialDesign:Card">
+            <Setter Property="Background" Value="{StaticResource ModeNormalBrush}" />
+            <Setter Property="Margin" Value="20,10" />
+            <Setter Property="HorizontalAlignment" Value="Center" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Style.Triggers>
+                <DataTrigger Binding="{Binding management.CurrentDisplayMode}"
+                         Value="{x:Static enums:RunDisplayMode.Manual}">
+                    <Setter Property="Background" Value="{StaticResource ModeManualBrush}" />
+                </DataTrigger>
+            </Style.Triggers>
+        </Style>
+
+        <!-- 流线卡片样式 -->
+        <Style x:Key="ClearModeCardStyle" TargetType="materialDesign:Card">
+            <Setter Property="Background" Value="{StaticResource ModeNormalBrush}" />
+            <Setter Property="Margin" Value="50,10" />
+            <Setter Property="HorizontalAlignment" Value="Center" />
+            <Setter Property="VerticalAlignment" Value="Center" />
+            <Style.Triggers>
+                <DataTrigger Binding="{Binding management.CurrentDisplayMode}"
+                         Value="{x:Static enums:RunDisplayMode.Clear}">
+                    <Setter Property="Background" Value="{StaticResource ModeClearBrush}" />
+                </DataTrigger>
+            </Style.Triggers>
+        </Style>
     </Window.Resources>
     <b:Interaction.Triggers>
         <b:EventTrigger EventName="Loaded">
@@ -39,8 +92,7 @@
             <b:InvokeCommandAction Command="{Binding ClosedCommand}" />
         </b:EventTrigger>
     </b:Interaction.Triggers>
-    <materialDesign:DialogHost DialogTheme="Inherit"
-                               Identifier="RootDialog">
+    <materialDesign:DialogHost DialogTheme="Inherit" Identifier="RootDialog">
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition Height="100" />
@@ -63,141 +115,167 @@
                     <ColumnDefinition Width="100" />
                     <ColumnDefinition Width="100" />
                 </Grid.ColumnDefinitions>
-                <Grid.Resources>
-                
-                </Grid.Resources>
+                <Grid.Resources />
                 <!--<TextBlock Text="运行窗口" HorizontalAlignment="Center"/>-->
-                <Button Grid.Column="0"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 运行窗口}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=0}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Home">
-                    <materialDesign:PackIcon Kind="HomeOutline"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=0}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="0"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=0}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Home"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 运行窗口}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=0}"
+                        Kind="HomeOutline" />
                 </Button>
-                <Button Grid.Column="1"
-                        Grid.Row="1"                        
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 产品管理}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=1}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Products">
-                    <materialDesign:PackIcon Kind="FileTableBoxOutline"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=1}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="1"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=1}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Products"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 产品管理}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=1}"
+                        Kind="FileTableBoxOutline" />
                 </Button>
-                <Button Grid.Column="2"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 调试}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=2}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Debug">
-                    <materialDesign:PackIcon Kind="WrenchOutline"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=2}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="2"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=2}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Debug"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 调试}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=2}"
+                        Kind="WrenchOutline" />
                 </Button>
-                <Button Grid.Column="3"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 设置}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=3}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Setting">
-                    <materialDesign:PackIcon Kind="Cog"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=3}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="3"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=3}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Setting"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 设置}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=3}"
+                        Kind="Cog" />
                 </Button>
-                <materialDesign:Card Grid.Column="4"
-                                     Margin="10"
-                                     Grid.Row="1"
-                                     Background="White"
-                                     UniformCornerRadius="15">
-                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-                        <TextBlock Text="{Binding MyTitle}"
-                                FontSize="{DynamicResource Font.Size.Title1}"
-                                HorizontalAlignment="Center"
-                                   Margin="280,0,0,0"
-                                VerticalAlignment="Center"
-                                FontWeight="Bold"/>
-                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.RunModelBackground}" >
-                            <TextBlock Text="{lex:Loc 生产}" FontSize="22" Margin="8" />
-                        </materialDesign:Card >
-                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,10" Background="{Binding management.ManualModeBackground}" >
-                            <TextBlock Text="{lex:Loc 调机}" FontSize="22" Margin="8"/>
+                <materialDesign:Card
+                    Grid.Row="1"
+                    Grid.Column="4"
+                    Margin="10"
+                    Background="White"
+                    UniformCornerRadius="15">
+                    <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
+                        <TextBlock
+                            Margin="280,0,0,0"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center"
+                            FontSize="{DynamicResource Font.Size.Title1}"
+                            FontWeight="Bold"
+                            Text="{Binding MyTitle}" />
+                        <materialDesign:Card Style="{StaticResource AutoModeCardStyle}">
+                            <TextBlock
+                                Margin="8"
+                                FontSize="22"
+                                Text="{lex:Loc 生产}" />
                         </materialDesign:Card>
-                        <materialDesign:Card HorizontalAlignment="Center" VerticalAlignment="Center" Margin="50,10" Background="{Binding management.ClearModeBackground}" >
-                            <TextBlock Text="{lex:Loc 流线}" FontSize="22" Margin="8" />
+
+                        <materialDesign:Card Style="{StaticResource ManualModeCardStyle}">
+                            <TextBlock
+                                Margin="8"
+                                FontSize="22"
+                                Text="{lex:Loc 调机}" />
+                        </materialDesign:Card>
+
+                        <materialDesign:Card Style="{StaticResource ClearModeCardStyle}">
+                            <TextBlock
+                                Margin="8"
+                                FontSize="22"
+                                Text="{lex:Loc 流线}" />
                         </materialDesign:Card>
                     </StackPanel>
 
 
                 </materialDesign:Card>
-                <Button Grid.Column="5"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 校准}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=5}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Calib">
-                    <materialDesign:PackIcon Kind="CrosshairsGps"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=5}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="5"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=5}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Calib"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 校准}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=5}"
+                        Kind="CrosshairsGps" />
                 </Button>
-                <Button Grid.Column="6"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 统计}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=6}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="Statistics">
-                    <materialDesign:PackIcon Kind="ChartBellCurveCumulative"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=6}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="6"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=6}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="Statistics"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 统计}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=6}"
+                        Kind="ChartBellCurveCumulative" />
                 </Button>
-                <Button Grid.Column="7"
-                        Grid.Row="1"
-                        Style="{StaticResource MaterialDesignIconButton}"
-                        ToolTip="{lex:Loc 用户}"
-                        Width="90"
-                        Height="90"
-                        Background="{Binding NavigationIndex,Converter={StaticResource _NavigationState},ConverterParameter=7}"
-                        Command="{Binding NavigationCommand}"
-                        CommandParameter="User">
-                    <materialDesign:PackIcon Kind="AccountMultipleOutline"
-                                             Width="70"
-                                             Height="70"
-                                             Foreground="{Binding NavigationIndex,Converter={StaticResource _NavigationState1},ConverterParameter=7}" />
+                <Button
+                    Grid.Row="1"
+                    Grid.Column="7"
+                    Width="90"
+                    Height="90"
+                    Background="{Binding NavigationIndex, Converter={StaticResource _NavigationState}, ConverterParameter=7}"
+                    Command="{Binding NavigationCommand}"
+                    CommandParameter="User"
+                    Style="{StaticResource MaterialDesignIconButton}"
+                    ToolTip="{lex:Loc 用户}">
+                    <materialDesign:PackIcon
+                        Width="70"
+                        Height="70"
+                        Foreground="{Binding NavigationIndex, Converter={StaticResource _NavigationState1}, ConverterParameter=7}"
+                        Kind="AccountMultipleOutline" />
                 </Button>
             </Grid>
 
-            <ContentControl Grid.Row="1"
-                            prism:RegionManager.RegionName="MainRegionContext" />
-            <!--状态栏-->
-            <StatusBar x:Name="status"
-                       Grid.Row="2">
-                <ItemsControl ItemsSource="{Binding Status}" HorizontalAlignment="Left" VerticalAlignment="Center">
+            <ContentControl Grid.Row="1" prism:RegionManager.RegionName="MainRegionContext" />
+            <!--  状态栏  -->
+            <StatusBar x:Name="status" Grid.Row="2">
+                <ItemsControl
+                    HorizontalAlignment="Left"
+                    VerticalAlignment="Center"
+                    ItemsSource="{Binding Status}">
                     <ItemsControl.ItemsPanel>
                         <ItemsPanelTemplate>
                             <VirtualizingStackPanel Orientation="Horizontal" />
@@ -205,26 +283,28 @@
                     </ItemsControl.ItemsPanel>
                     <ItemsControl.ItemTemplate>
                         <DataTemplate>
-                            <TextBlock Text="{Binding Message,Mode=TwoWay}"
-                                       MinWidth="40"
-                                       Foreground="Black"
-                                       Background="{Binding Background,Mode=TwoWay}"
-                                       Margin="4,0"
-                                       VerticalAlignment="Center"
-                                       FontSize="{DynamicResource Font.Size. Font.Size.Captions4}"
-                                       Opacity="0.7"/>
-                            
+                            <TextBlock
+                                MinWidth="40"
+                                Margin="4,0"
+                                VerticalAlignment="Center"
+                                Background="{Binding Background, Mode=TwoWay}"
+                                FontSize="{DynamicResource Font.Size. Font.Size.Captions4}"
+                                Foreground="Black"
+                                Opacity="0.7"
+                                Text="{Binding Message, Mode=TwoWay}" />
+
                         </DataTemplate>
                     </ItemsControl.ItemTemplate>
                 </ItemsControl>
             </StatusBar>
-            <materialDesign:Snackbar Grid.Row="1"
-                                     x:Name="SnackbarSeven"
-                                     Opacity="0.8"
-                                     HorizontalContentAlignment="Center"
-                                     FontSize="{DynamicResource Font.Size.Body1}"
-                                     MessageQueue="{materialDesign:MessageQueue}"
-                                     VerticalAlignment="Bottom" />
+            <materialDesign:Snackbar
+                x:Name="SnackbarSeven"
+                Grid.Row="1"
+                VerticalAlignment="Bottom"
+                HorizontalContentAlignment="Center"
+                FontSize="{DynamicResource Font.Size.Body1}"
+                MessageQueue="{materialDesign:MessageQueue}"
+                Opacity="0.8" />
         </Grid>
     </materialDesign:DialogHost>