Browse Source

添加蒙层

ltwork 1 year ago
parent
commit
d685b2b403

+ 32 - 0
BlankApp1/BlankApp1/Controls/Convert/BooleanToVisibilityConverter.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace PLCTool.Controls.Convert
+{
+    public class BooleanToVisibilityConverter : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value is bool && (bool)value)
+            {
+                return Visibility.Visible;
+            }
+            return Visibility.Collapsed;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value is Visibility && (Visibility)value == Visibility.Visible)
+            {
+                return true;
+            }
+            return false;
+        }
+    }
+}

+ 13 - 0
BlankApp1/BlankApp1/Events/MaskEvent.cs

@@ -0,0 +1,13 @@
+using Prism.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PLCTool.Events
+{
+    public class MaskEvent : PubSubEvent<bool>
+    {
+    }
+}

+ 12 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddSchViewModel.cs

@@ -199,7 +199,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 return;
             }
             //设备类型名称
-
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", DeviceKindName);
             parm.Add("Key2", ScheduleName);
@@ -216,6 +217,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 获取测试项
@@ -333,6 +336,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             var edit = conList.FirstOrDefault(x => x.Id == id);
             if (edit != null)
             {
+                //蒙层显示
+                _aggregator.GetEvent<MaskEvent>().Publish(true);
                 DialogParameters parm = new DialogParameters();
                 parm.Add("Key", edit);
                 //弹出详情对话框
@@ -355,6 +360,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     }
 
                 });
+                //蒙层显示
+                _aggregator.GetEvent<MaskEvent>().Publish(false);
             }
         }
 
@@ -508,6 +515,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         {
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", "");
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddDetailView", parm, async callback =>
             {
@@ -529,6 +538,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         /// <summary>

+ 4 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -114,7 +114,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", schid);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("ReadSchView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -124,6 +125,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 复位

+ 8 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceKindViewModel.cs

@@ -94,6 +94,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             var finrProject = allDeviceKindList.FirstOrDefault(x => (x.DeviceKindId == id));
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", finrProject);
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddOrEditDeviceKindView", parm, async callback =>
             {
@@ -136,6 +138,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void Delete(object obj)
@@ -227,7 +231,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <exception cref="NotImplementedException"></exception>
         private void Add(object obj)
         {
-
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddOrEditDeviceKindView", async callback =>
             {
@@ -260,6 +265,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 获取所有项目

+ 8 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/DeviceViewModel.cs

@@ -106,6 +106,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             var findDevice = allDeviceList.FirstOrDefault(x => (x.DeviceId == id));
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", findDevice);
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddOrEditDeviceView", parm, async callback =>
             {
@@ -149,6 +151,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 删除
@@ -264,7 +268,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <exception cref="NotImplementedException"></exception>
         private void Add(object obj)
         {
-
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddOrEditDeviceView", async callback =>
             {
@@ -298,6 +303,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 获取所有项目

+ 8 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/EditSchViewModel.cs

@@ -83,7 +83,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", deviceKindName);
             parm.Add("Key2", scheduleName);
-           
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddItemDetailView", parm, async callback =>
             {
@@ -94,10 +95,14 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void EditSchDtl(object obj)
         {
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             long schDtlId = Convert.ToInt64(obj);
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", schDtlId);
@@ -111,6 +116,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void Query(object obj)

+ 8 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -72,6 +72,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             var findPlc = allPLCConfigList.FirstOrDefault(x => (x.Id ==id));
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", findPlc);
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddDetailView", parm, async callback =>
             {
@@ -107,6 +109,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void Delete(object obj)
@@ -187,7 +191,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <exception cref="NotImplementedException"></exception>
         private void Add(object obj)
         {
-           
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddDetailView", async callback =>
             {
@@ -215,6 +220,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 获取PLC配置

+ 9 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/ProjectViewModel.cs

@@ -82,6 +82,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", finrProject);
             //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("AddOrEditProjectView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -123,6 +125,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void Delete(object obj)
@@ -223,7 +227,8 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <exception cref="NotImplementedException"></exception>
         private void Add(object obj)
         {
-
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             //弹出详情对话框
             _dialog.ShowDialog("AddOrEditProjectView", async callback =>
             {
@@ -256,6 +261,9 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 }
 
             });
+
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 获取所有项目

+ 17 - 4
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/DeviceTestViewModel.cs

@@ -5,7 +5,9 @@ using MiniExcelLibs;
 using Model.Dto;
 using Model.Entities;
 using PLCTool.Common;
+using PLCTool.Events;
 using Prism.Commands;
+using Prism.Events;
 using Prism.Mvvm;
 using Prism.Regions;
 using Prism.Services.Dialogs;
@@ -34,11 +36,12 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private readonly IMapper _mapper;
         private readonly IDialogService _dialog;
         private readonly ILogger _logger;
+        private readonly IEventAggregator _aggregator;
         private List<BasDeviceWithSchModel> allDeviceAndSchList = new List<BasDeviceWithSchModel>();//所有设备,并带有测试方案
         private List<BasDeviceWithSchModel> allDeviceList = new List<BasDeviceWithSchModel>();//所有设备
         private List<BasDeviceWithSchModel> conditionDevices = new List<BasDeviceWithSchModel>();//符合条件的方案
         private string selectProjectName;
-        public DeviceTestViewModel(IRegionManager regionManager,IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, IDialogService dialog, ILogger logger)
+        public DeviceTestViewModel(IRegionManager regionManager,IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, IDialogService dialog, ILogger logger, IEventAggregator aggregator)
         {
             _regionManager = regionManager;
             _iBasicDeviceService = iBasicDeviceService;
@@ -50,6 +53,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             _mapper = mapper;
             _dialog = dialog;
             _logger = logger;
+            _aggregator = aggregator;
             QueryCommand = new DelegateCommand<object>(Query);
           
             ExportCommand = new DelegateCommand<string>(Export);
@@ -131,7 +135,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", schid);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("ReadSchView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -141,6 +146,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 返回界面
@@ -167,7 +174,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             parm.Add("Key", id);
             parm.Add("Key2", deviceId);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("AutoTestView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -177,6 +185,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         private void ManualTest(object obj)
@@ -190,7 +200,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             parm.Add("Key", id);
             parm.Add("Key2", deviceId);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("ManualTestView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -200,6 +211,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         /// <summary>

+ 13 - 4
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ResultQueryViewModel.cs

@@ -20,6 +20,8 @@ using Newtonsoft.Json;
 using QuestPDF.Fluent;
 using System.Windows;
 using Prism.Regions;
+using PLCTool.Events;
+using Prism.Events;
 
 namespace PLCTool.ViewModels.BusinessManageViewModel
 {
@@ -38,11 +40,12 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private readonly IMapper _mapper;
         private readonly IDialogService _dialog;
         private readonly ILogger _logger;
+        private readonly IEventAggregator _aggregator;
         private List<DeviceDtlWithResultModel> allDeviceAndSchResultList = new List<DeviceDtlWithResultModel>();//所有设备,并带有测试方案
         private List<DeviceDtlWithResultModel> allDeviceList = new List<DeviceDtlWithResultModel>();//所有方案
         private List<DeviceDtlWithResultModel> conditionDevices = new List<DeviceDtlWithResultModel>();//符合条件的方案
         private string selectProjectName;
-        public ResultQueryViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordDtlService iBizTestRecordDtlService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IRegionManager regionManager,IMapper mapper, IDialogService dialog, ILogger logger)
+        public ResultQueryViewModel(IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordDtlService iBizTestRecordDtlService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IRegionManager regionManager,IMapper mapper, IDialogService dialog, ILogger logger, IEventAggregator aggregator)
         {
             _iBasicDeviceService = iBasicDeviceService;
             _iBasicDeviceKindService = iBasicDeviceKindService;
@@ -55,6 +58,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             _mapper = mapper;
             _dialog = dialog;
             _logger = logger;
+            _aggregator = aggregator;
             QueryCommand = new DelegateCommand<object>(Query);
 
             ExportCommand = new DelegateCommand<string>(Export);
@@ -86,7 +90,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             parm.Add("Key", id);
             parm.Add("Key2", deviceId);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("RetryTestView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -96,7 +101,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 }
 
             });
-
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
         /// <summary>
         /// 加载页面
@@ -143,7 +149,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", id);
             //弹出详情对话框
-            //弹出详情对话框
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(true);
             _dialog.ShowDialog("TestResultDetailView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
@@ -153,6 +160,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 }
 
             });
+            //蒙层显示
+            _aggregator.GetEvent<MaskEvent>().Publish(false);
         }
 
         /// <summary>

+ 15 - 0
BlankApp1/BlankApp1/ViewModels/MainWindowViewModel.cs

@@ -51,6 +51,12 @@ namespace BlankApp1.ViewModels
             logger.LogError("error");
 
             aggregator.GetEvent<BreadEvent>().Subscribe(RecvBreadMsg);
+            aggregator.GetEvent<MaskEvent>().Subscribe(DisplayMask);
+        }
+
+        private void DisplayMask(bool isVis)
+        {
+            IsMaskVisible=isVis;
         }
 
         private void RecvBreadMsg(List<CrumbViewModel> list)
@@ -170,6 +176,15 @@ namespace BlankApp1.ViewModels
             get { return plcIsConnect; }
             set { plcIsConnect = value; RaisePropertyChanged(); }
         }
+
+        private bool isMaskVisible = false;
+        public bool IsMaskVisible
+        {
+            get { return isMaskVisible; }
+            set { isMaskVisible = value; RaisePropertyChanged(); }
+        }
+
+        
         #endregion
     }
 }

+ 2 - 2
BlankApp1/BlankApp1/Views/MainWindow.xaml

@@ -88,6 +88,7 @@
             </Style.Triggers>
         </Style>
         <convt:Bool2ColorConverter x:Key="boolToColorConvert"/>
+        <convt:BooleanToVisibilityConverter x:Key="BoolToVis"/>
     </Window.Resources>
     <Grid>
         <Grid.RowDefinitions>
@@ -167,8 +168,7 @@
 
         </Border>
         <!--蒙版-->
-        <ContentControl Grid.RowSpan="3" prism:RegionManager.RegionName="MaskRegion" />
-
+        <Grid Grid.RowSpan="3" Background="#20000000" Visibility="{Binding IsMaskVisible, Converter={StaticResource BoolToVis}}"/> 
 
     </Grid>
 </Window>

+ 1 - 1
BlankApp1/BlankApp1/Views/MaskView.xaml

@@ -7,6 +7,6 @@
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid>
-        <Grid   Background="#80000000" />
+        <Grid   Background="#20000000" />
     </Grid>
 </UserControl>