Просмотр исходного кода

光源通道选择弹窗化,点位管理功能增强

实现光源通道选择弹窗,支持多选与配置,优化工艺流程光源通道管理。点位管理增加上移/下移、删除确认及命令可用性判断。完善初始化流程,细化界面数值显示,更新多语言资源与项目文件。提升了光源配置灵活性和整体用户体验。
孝锋 徐 8 месяцев назад
Родитель
Сommit
fcb31fd5cc

+ 1 - 0
TeamAAS-VM/App.xaml.cs

@@ -174,6 +174,7 @@ namespace TeamAAS_VP
             containerRegistry.RegisterDialog<VisionScriptPage>();
             containerRegistry.RegisterDialog<SelectCameraBrand>();
             containerRegistry.RegisterDialog<AddLightController>();
+            containerRegistry.RegisterDialog<LightChannelList>();
             //**************************************************************************************
 
             // 注册 SQLSugar 客户端(单例模式)

+ 29 - 0
TeamAAS-VM/Models/Lights/ChannelConfig.cs

@@ -95,4 +95,33 @@ namespace TeamAAS_VP.Models.Lights
             DefaultBrightness = defaultBrightness;
         }
     }
+
+    public class ChannelConfigEx: ChannelConfig
+    {
+        //是否选中
+        private bool _IsSelected;
+        public bool IsSelected
+        {
+            get { return _IsSelected; }
+            set { SetProperty(ref _IsSelected, value); }
+        }
+
+        public ChannelConfigEx() : base()
+        {
+        }
+
+        public ChannelConfigEx(ChannelConfig channelConfig)
+        {
+            this.LocalIndex = channelConfig.LocalIndex;
+            this.GlobalIndex = channelConfig.GlobalIndex;
+            this.Name = channelConfig.Name;
+            this.Description = channelConfig.Description;
+            this.DefaultBrightness = channelConfig.DefaultBrightness;
+        }
+
+        public ChannelConfig ToChannelConfig()
+        {
+            return new ChannelConfig(this.LocalIndex, this.GlobalIndex, this.Name, this.Description, this.DefaultBrightness);
+        }
+    }
 }

+ 9 - 0
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -5109,6 +5109,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 请选择要启用的光源通道 的本地化字符串。
+        /// </summary>
+        public static string 请选择要启用的光源通道 {
+            get {
+                return ResourceManager.GetString("请选择要启用的光源通道", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 读取配置参数 的本地化字符串。
         /// </summary>

+ 21 - 0
TeamAAS-VM/Resources/Languages/Lang.en.resx

@@ -1998,4 +1998,25 @@
   <data name="正在初始化光源控制器" xml:space="preserve">
     <value>Initializing Light Controller</value>
   </data>
+  <data name="通过下相机获取P0" xml:space="preserve">
+    <value>Get P0 with the camera below</value>
+  </data>
+  <data name="选择下相机视觉流程" xml:space="preserve">
+    <value>Select the next camera vision process</value>
+  </data>
+  <data name="光源通道列表" xml:space="preserve">
+    <value>Light channel list</value>
+  </data>
+  <data name="光源通道" xml:space="preserve">
+    <value>Light channel</value>
+  </data>
+  <data name="添加通道" xml:space="preserve">
+    <value>Add channel</value>
+  </data>
+  <data name="删除通道" xml:space="preserve">
+    <value>delete channel</value>
+  </data>
+  <data name="请选择要启用的光源通道" xml:space="preserve">
+    <value>Please select a light channel to enable</value>
+  </data>
 </root>

+ 21 - 0
TeamAAS-VM/Resources/Languages/Lang.ja-JP.resx

@@ -1998,4 +1998,25 @@
   <data name="正在初始化光源控制器" xml:space="preserve">
     <value>ライトコントローラーを初期化しています</value>
   </data>
+  <data name="通过下相机获取P0" xml:space="preserve">
+    <value>下のカメラでP 0をゲット</value>
+  </data>
+  <data name="选择下相机视觉流程" xml:space="preserve">
+    <value>次のカメラビジョンプロセスを選択してください</value>
+  </data>
+  <data name="光源通道列表" xml:space="preserve">
+    <value>ライトチャンネルリスト</value>
+  </data>
+  <data name="光源通道" xml:space="preserve">
+    <value>ライトチャンネル</value>
+  </data>
+  <data name="添加通道" xml:space="preserve">
+    <value>チャンネルを追加</value>
+  </data>
+  <data name="删除通道" xml:space="preserve">
+    <value>チャンネルを削除</value>
+  </data>
+  <data name="请选择要启用的光源通道" xml:space="preserve">
+    <value>有効にするライトチャンネルを選択してください</value>
+  </data>
 </root>

+ 3 - 0
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -2108,4 +2108,7 @@
   <data name="删除通道" xml:space="preserve">
     <value>删除通道</value>
   </data>
+  <data name="请选择要启用的光源通道" xml:space="preserve">
+    <value>请选择要启用的光源通道</value>
+  </data>
 </root>

+ 21 - 0
TeamAAS-VM/Resources/Languages/Lang.zh-TW.resx

@@ -1998,4 +1998,25 @@
   <data name="正在初始化光源控制器" xml:space="preserve">
     <value>正在初始化光源控制器</value>
   </data>
+  <data name="通过下相机获取P0" xml:space="preserve">
+    <value>透過下相機獲取P0</value>
+  </data>
+  <data name="选择下相机视觉流程" xml:space="preserve">
+    <value>選擇下相機視覺流程</value>
+  </data>
+  <data name="光源通道列表" xml:space="preserve">
+    <value>光源通道列表</value>
+  </data>
+  <data name="光源通道" xml:space="preserve">
+    <value>光源通道</value>
+  </data>
+  <data name="添加通道" xml:space="preserve">
+    <value>添加通道</value>
+  </data>
+  <data name="删除通道" xml:space="preserve">
+    <value>刪除通道</value>
+  </data>
+  <data name="请选择要启用的光源通道" xml:space="preserve">
+    <value>請選擇要啟用的光源通道</value>
+  </data>
 </root>

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

@@ -781,6 +781,7 @@
     <Compile Include="ValueConverter\StringFormatConverter.cs" />
     <Compile Include="ViewModels\DebugMod\LightManualViewModel.cs" />
     <Compile Include="ViewModels\Calibration\FixedUpCameraFindP0ViewModel.cs" />
+    <Compile Include="ViewModels\Product\LightChannelListViewModel.cs" />
     <Compile Include="ViewModels\Product\PlcPointParamsViewModel.cs" />
     <Compile Include="ViewModels\Setting\AddLightControllerViewModel.cs" />
     <Compile Include="ViewModels\Setting\AddPlcViewModel.cs" />
@@ -939,6 +940,9 @@
     <Compile Include="Views\Product\FeederParams.xaml.cs">
       <DependentUpon>FeederParams.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Product\LightChannelList.xaml.cs">
+      <DependentUpon>LightChannelList.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Product\PalletManage.xaml.cs">
       <DependentUpon>PalletManage.xaml</DependentUpon>
     </Compile>
@@ -1264,6 +1268,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Product\LightChannelList.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Product\PalletManage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 13 - 5
TeamAAS-VM/ViewModels/MainWindowViewModel.cs

@@ -261,7 +261,7 @@ namespace TeamAAS_VP.ViewModels
             SendTaskMessage(Lang.软件启动, MessageLevel.Info);
             StartTime = DateTime.Now;
             _regionManager.RequestNavigate("MainRegionContext", "HomeView");
-            double max = 13;
+            double max = 14;
             double curvalue = 0;
             currentUser = Guid.NewGuid();
             Status.Add(new StatusInfo(currentUser, $"{Lang.当前用户}:{_systemDatabaseService.GetCurrentUser().UserName}[{_systemDatabaseService.GetCurrentUser().userPart.ToString()}]", new SolidColorBrush(Colors.White)));
@@ -321,7 +321,15 @@ namespace TeamAAS_VP.ViewModels
             }));
             await management.InitLightControllers();
 
-            //-------------------SETP 7: 加载所有产品-----------------------------------------------------------------------
+            //-------------------SETP 7: 初始化电批-----------------------------------------------------------------------
+            curvalue += 1;
+            _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
+            {
+                _eventAggregator.GetEvent<ProgressNotification>().Publish(new UProgressBar.ProgressParameter { Maximum = max, Minimum = 0, SubTitle = $"{Lang.初始化中}...", Message = $"正在连接电批...", Value = curvalue });
+            }));
+            await management.InitScrewDriver();
+
+            //-------------------SETP 8: 加载所有产品-----------------------------------------------------------------------
             curvalue += 1;
             _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
@@ -329,7 +337,7 @@ namespace TeamAAS_VP.ViewModels
             }));
              await _productService.InitializeAsync();
 
-            //-------------------SETP 8: 开启服务器监听-----------------------------------------------------------------------
+            //-------------------SETP 9: 开启服务器监听-----------------------------------------------------------------------
             curvalue += 1;
             _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
@@ -337,7 +345,7 @@ namespace TeamAAS_VP.ViewModels
             }));
             management.InitBgTcp();
 
-            //-------------------SETP 9: 开启Modbus Tcp-----------------------------------------------------------------------
+            //-------------------SETP 10: 开启Modbus Tcp-----------------------------------------------------------------------
             curvalue += 1;
             _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
@@ -345,7 +353,7 @@ namespace TeamAAS_VP.ViewModels
             }));
             management.InitModbusTcp();
 
-            //-------------------SETP 10: 开启后台脚本-----------------------------------------------------------------------
+            //-------------------SETP 11: 开启后台脚本-----------------------------------------------------------------------
             curvalue += 1;
             _ = App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {

+ 101 - 0
TeamAAS-VM/ViewModels/Product/LightChannelListViewModel.cs

@@ -0,0 +1,101 @@
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models;
+using TeamAAS_VP.Models.Lights;
+using TeamAAS_VP.Models.PLC;
+using TeamAAS_VP.Resources.Languages;
+
+namespace TeamAAS_VP.ViewModels.Product
+{
+    public class LightChannelListViewModel : BindableBase, IDialogAware
+    {
+        private readonly IConfigService _configService;
+
+        private ObservableCollection<ChannelConfigEx> _AllLightChannels;
+        public ObservableCollection<ChannelConfigEx> AllLightChannels
+        {
+            get { return _AllLightChannels; }
+            set { SetProperty(ref _AllLightChannels, value); }
+        }
+
+        private DelegateCommand _ConfirmCommand;
+        public DelegateCommand ConfirmCommand =>
+            _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand));
+
+        private DelegateCommand _CancelCommand;
+        public DelegateCommand CancelCommand =>
+            _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand));
+
+        public LightChannelListViewModel(IConfigService configService)
+        {
+            _configService = configService;
+        }
+
+        void ExecuteConfirmCommand()
+        {
+            //获取所有选择的通道
+            var selectedChannels = AllLightChannels.Where(c => c.IsSelected).ToArray();
+            //将通道配置扩展转换为通道配置
+            ChannelConfig[] Channels = selectedChannels.Select(c => c.ToChannelConfig()).ToArray();
+
+            IDialogParameters parameters = new DialogParameters();
+            parameters.Add("Channels", Channels);
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters));
+        }
+
+        /// <summary>
+        /// 取消按钮
+        /// </summary>
+        void ExecuteCancelCommand()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, null));
+        }
+
+        public string Title { get; set; } = "添加机器人";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            Title = "选择要使用的光源通道";
+            ChannelConfig[] channels=parameters.GetValue<ChannelConfig[]>("Channels");
+
+            AllLightChannels =new ObservableCollection<ChannelConfigEx>();
+            var allChanels = _configService.GetAllLightChannels();
+            foreach (var item in allChanels)
+            {
+                AllLightChannels.Add(new ChannelConfigEx(item));
+            }
+
+            //设置已选择的通道
+            foreach (var channel in channels)
+            {
+                var exist = AllLightChannels.FirstOrDefault(c => c.GlobalIndex == channel.GlobalIndex);
+                if (exist != null)
+                {
+                    exist.IsSelected = true;
+                }
+            }
+
+        }
+    }
+}

+ 104 - 13
TeamAAS-VM/ViewModels/Product/PlcPointParamsViewModel.cs

@@ -60,6 +60,12 @@ namespace TeamAAS_VP.ViewModels.Product
                 if (SetProperty(ref _selectedPointInDataGrid, value))
                 {
                     SelectedPointInComboBox = value;
+                    // update command availability
+                    _MovePointUpCommand?.RaiseCanExecuteChanged();
+                    _MovePointDownCommand?.RaiseCanExecuteChanged();
+                    // 更新依赖可执行状态的命令
+                    _TechPointCommand?.RaiseCanExecuteChanged();
+                    _ExecuteMotion?.RaiseCanExecuteChanged();
                 }
                 // 可以同步到 SelectPoint 属性
                 SelectedPoint = value;
@@ -163,15 +169,15 @@ namespace TeamAAS_VP.ViewModels.Product
 
         private DelegateCommand<object> _ExecuteMotion;
         public DelegateCommand<object> ExecuteMotion =>
-            _ExecuteMotion ?? (_ExecuteMotion = new DelegateCommand<object>(ExecuteExecuteMotion).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
+            _ExecuteMotion ?? (_ExecuteMotion = new DelegateCommand<object>(ExecuteExecuteMotion).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute).ObservesProperty(() => SelectedPointInDataGrid));
 
         private DelegateCommand<object> _JogCommand;
         public DelegateCommand<object> JogCommand =>
-            _JogCommand ?? (_JogCommand = new DelegateCommand<object>(ExecuteJogCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
+             _JogCommand ?? (_JogCommand = new DelegateCommand<object>(ExecuteJogCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
 
         private DelegateCommand _TechPointCommand;
         public DelegateCommand TechPointCommand =>
-            _TechPointCommand ?? (_TechPointCommand = new DelegateCommand(ExecuteTechPointCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute));
+            _TechPointCommand ?? (_TechPointCommand = new DelegateCommand(ExecuteTechPointCommand).ObservesCanExecute(() => CanExecute).ObservesProperty(() => Robot).ObservesProperty(() => Robot.CanExecute).ObservesProperty(() => SelectedPointInDataGrid));
 
         private DelegateCommand<string> _MotorCommand;
         public DelegateCommand<string> MotorCommand =>
@@ -202,7 +208,12 @@ namespace TeamAAS_VP.ViewModels.Product
         public DelegateCommand DeletePointCommand =>
             _DeletePointCommand ?? (_DeletePointCommand = new DelegateCommand(ExecuteDeletePointCommand));
 
-        
+        private DelegateCommand _MovePointUpCommand;
+        public DelegateCommand MovePointUpCommand => _MovePointUpCommand ?? (_MovePointUpCommand = new DelegateCommand(ExecuteMovePointUpCommand, CanMovePointUp));
+
+        private DelegateCommand _MovePointDownCommand;
+        public DelegateCommand MovePointDownCommand => _MovePointDownCommand ?? (_MovePointDownCommand = new DelegateCommand(ExecuteMovePointDownCommand, CanMovePointDown));
+
 
         #endregion
 
@@ -318,6 +329,10 @@ namespace TeamAAS_VP.ViewModels.Product
         /// <param name="obj"></param>
         async void ExecuteExecuteMotion(object parameter)
         {
+            if (parameter == null)
+            {
+                return;
+            }
             var values = (object[])parameter;
             var point = values[0] as RPoint;
             MotionCommand motionCmd = (MotionCommand)values[1];
@@ -354,6 +369,8 @@ namespace TeamAAS_VP.ViewModels.Product
         async void ExecuteTechPointCommand()
         {
             if (Robot == null || !Robot.IsConnected) return;
+            if (SelectedPoint == null) return;
+
             try
             {
                 var curpos = await Robot.GetRobotPosAsync();
@@ -460,14 +477,12 @@ namespace TeamAAS_VP.ViewModels.Product
         {
             get
             {
-                if (Robot != null)
-                {
-                    return Robot.CanExecute;
-                }
-                else
+                // 命令可执行仅当机器人可执行且已选择点位
+                if (Robot != null && Robot.CanExecute)
                 {
-                    return false;
+                    return SelectedPointInDataGrid != null;
                 }
+                return false;
             }
         }
 
@@ -511,6 +526,9 @@ namespace TeamAAS_VP.ViewModels.Product
             {
                 Number = Points.Count + 1,
             });
+            // update commands
+            _MovePointUpCommand?.RaiseCanExecuteChanged();
+            _MovePointDownCommand?.RaiseCanExecuteChanged();
         }
 
         /// <summary>
@@ -518,16 +536,89 @@ namespace TeamAAS_VP.ViewModels.Product
         /// </summary>
         void ExecuteDeletePointCommand()
         {
-            if (SelectedPoint==null)
+            if (SelectedPoint == null)
             {
                 return;
             }
+            // 确认删除
+            if (MessageBox.Show("确认要删除选中的点位吗?", "删除点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+            {
+                return;
+            }
+            int removedIndex = Points.IndexOf(SelectedPoint);
             Points.Remove(SelectedPoint);
             //重新编号
-            for (int i = 1; i < Points.Count; i++)
+            for (int i = 0; i < Points.Count; i++)
             {
                 Points[i].Number = i + 1;
             }
+            // adjust selection
+            if (Points.Count > 0)
+            {
+                int newIndex = Math.Min(removedIndex, Points.Count - 1);
+                SelectedPointInDataGrid = Points[newIndex];
+            }
+            else
+            {
+                SelectedPointInDataGrid = null;
+            }
+            // update commands
+            _MovePointUpCommand?.RaiseCanExecuteChanged();
+            _MovePointDownCommand?.RaiseCanExecuteChanged();
+        }
+
+        private bool CanMovePointUp()
+        {
+            return SelectedPointInDataGrid != null && Points.IndexOf(SelectedPointInDataGrid) > 0;
+        }
+
+        private bool CanMovePointDown()
+        {
+            return SelectedPointInDataGrid != null && Points.IndexOf(SelectedPointInDataGrid) >= 0 && Points.IndexOf(SelectedPointInDataGrid) < Points.Count - 1;
+        }
+
+        /// <summary>
+        /// 向上移动点位
+        /// </summary>
+        void ExecuteMovePointUpCommand()
+        {
+            if (SelectedPointInDataGrid == null) return;
+            // 确认移动
+            if (MessageBox.Show("确认将选中点位上移一位吗?", "移动点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+            {
+                return;
+            }
+            int idx = Points.IndexOf(SelectedPointInDataGrid);
+            if (idx <= 0) return;
+            var item = SelectedPointInDataGrid;
+            Points.Move(idx, idx - 1);
+            // renumber
+            for (int i = 0; i < Points.Count; i++) Points[i].Number = i + 1;
+            SelectedPointInDataGrid = item;
+            _MovePointUpCommand?.RaiseCanExecuteChanged();
+            _MovePointDownCommand?.RaiseCanExecuteChanged();
+        }
+
+        /// <summary>
+        /// 向下移动点位
+        /// </summary>
+        void ExecuteMovePointDownCommand()
+        {
+            if (SelectedPointInDataGrid == null) return;
+            // 确认移动
+            if (MessageBox.Show("确认将选中点位下移一位吗?", "移动点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+            {
+                return;
+            }
+            int idx = Points.IndexOf(SelectedPointInDataGrid);
+            if (idx < 0 || idx >= Points.Count - 1) return;
+            var item = SelectedPointInDataGrid;
+            Points.Move(idx, idx + 1);
+            // renumber
+            for (int i = 0; i < Points.Count; i++) Points[i].Number = i + 1;
+            SelectedPointInDataGrid = item;
+            _MovePointUpCommand?.RaiseCanExecuteChanged();
+            _MovePointDownCommand?.RaiseCanExecuteChanged();
         }
         #endregion
 
@@ -556,7 +647,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 SelectedIndex = 0;
                 Points = SelectProduct.PickCameraPoints;
 
-                if (Robot==null)
+                if (Robot == null)
                 {
                     Robot = _robotService.GetRobotByNumber(1);
                 }

+ 24 - 25
TeamAAS-VM/ViewModels/Product/ProcessBasicsViewModel.cs

@@ -19,8 +19,10 @@ using TeamAAS_VP.Events;
 using TeamAAS_VP.Interfaces;
 using TeamAAS_VP.Models;
 using TeamAAS_VP.Models.Calibration;
-using TeamAAS_VP.Models.Product;
 using TeamAAS_VP.Models.Lights;
+using TeamAAS_VP.Models.Product;
+using TeamAAS_VP.Resources.Languages;
+using TeamAAS_VP.Services;
 
 namespace TeamAAS_VP.ViewModels.Product
 {
@@ -259,11 +261,11 @@ namespace TeamAAS_VP.ViewModels.Product
         public DelegateCommand LoadedCommand =>
             _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
 
-        private DelegateCommand _AddLightChannelCommand;
-        public DelegateCommand AddLightChannelCommand => _AddLightChannelCommand ?? (_AddLightChannelCommand = new DelegateCommand(ExecuteAddLightChannelCommand));
+        private DelegateCommand _SelectLightChannelCommand;
+        public DelegateCommand SelectLightChannelCommand =>
+            _SelectLightChannelCommand ?? (_SelectLightChannelCommand = new DelegateCommand(ExecuteSelectLightChannelCommand));
 
-        private DelegateCommand _RemoveLightChannelCommand;
-        public DelegateCommand RemoveLightChannelCommand => _RemoveLightChannelCommand ?? (_RemoveLightChannelCommand = new DelegateCommand(ExecuteRemoveLightChannelCommand).ObservesCanExecute(() => SelectedLightChannel != null));
+        
         #endregion
 
         #region 事件
@@ -364,31 +366,28 @@ namespace TeamAAS_VP.ViewModels.Product
         }
 
         /// <summary>
-        /// 添加光源通道
+        /// 选择光源通道
         /// </summary>
-        void ExecuteAddLightChannelCommand()
+        void ExecuteSelectLightChannelCommand()
         {
             if (SelectProcedure == null) return;
-            if (SelectProcedure.LightChannels == null)
-                SelectProcedure.LightChannels = new System.Collections.ObjectModel.ObservableCollection<ChannelConfig>();
-            var ch = new ChannelConfig
+            if (SelectProcedure.LightChannels == null) SelectProcedure.LightChannels=new ObservableCollection<ChannelConfig>();
+
+            DialogParameters keyValues = new DialogParameters();
+            keyValues.Add("Channels", SelectProcedure.LightChannels.ToArray());
+            _dialogService.ShowDialog("LightChannelList", keyValues, rst =>
             {
-                Name = $"Channel {SelectProcedure.LightChannels.Count + 1}",
-                LocalIndex = SelectProcedure.LightChannels.Count,
-                GlobalIndex = SelectProcedure.LightChannels.Count + 1,
-                DefaultBrightness = 100
-            };
-            SelectProcedure.LightChannels.Add(ch);
-        }
+                //对话框关闭之后的回调函数,可以在这解析结果。
+                ButtonResult result1 = rst.Result;
 
-        /// <summary>
-        /// 移除光源通道
-        /// </summary>
-        void ExecuteRemoveLightChannelCommand()
-        {
-            if (SelectProcedure == null || SelectedLightChannel == null) return;
-            SelectProcedure.LightChannels.Remove(SelectedLightChannel);
-            SelectedLightChannel = null;
+                if (result1 == ButtonResult.OK)
+                {
+                    ChannelConfig[] channels = rst.Parameters.GetValue<ChannelConfig[]>("Channels");
+                    SelectProcedure.LightChannels = new ObservableCollection<ChannelConfig>(channels);
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
+                }
+
+            });
         }
 
         /// <summary>

+ 16 - 7
TeamAAS-VM/Views/Calibration/CalibrationTeachCenterPoint.xaml

@@ -129,11 +129,16 @@
                     </Button.ToolTip>
                 </Button>
                 <TextBlock Grid.Row="1"
-                           Grid.ColumnSpan="2">
+                           Grid.ColumnSpan="2"
+                           Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">
                     <TextBlock.Text>
-                        <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3}}">
-                            <Binding Path="SelectCalibration.CenterPoint.X" />
-                            <Binding Path="SelectCalibration.CenterPoint.Y" />
+                        <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3}">
+                            <Binding Path="SelectCalibration.CenterPoint.X"
+                                     TargetNullValue="0.000"
+                                     FallbackValue="0.000" />
+                            <Binding Path="SelectCalibration.CenterPoint.Y"
+                                     TargetNullValue="0.000"
+                                     FallbackValue="0.000" />
                         </MultiBinding>
                     </TextBlock.Text>
                 </TextBlock>
@@ -159,9 +164,13 @@
                            Grid.ColumnSpan="2"
                            Visibility="{Binding IsShowTechHome,Converter={StaticResource BooleanToVisibilityConverter}}">
                     <TextBlock.Text>
-                        <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3}}">
-                            <Binding Path="SelectCalibration.HomePoint.X" />
-                            <Binding Path="SelectCalibration.HomePoint.Y" />
+                        <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3}">
+                            <Binding Path="SelectCalibration.HomePoint.X"
+                                     TargetNullValue="0.000"
+                                     FallbackValue="0.000" />
+                            <Binding Path="SelectCalibration.HomePoint.Y"
+                                     TargetNullValue="0.000"
+                                     FallbackValue="0.000" />
                         </MultiBinding>
                     </TextBlock.Text>
                 </TextBlock>

+ 7 - 11
TeamAAS-VM/Views/Calibration/FixedUpCameraFindP0.xaml

@@ -184,20 +184,16 @@
                     <TextBlock Grid.Row="6"
                                Grid.ColumnSpan="2">
                         <TextBlock.Text>
-                            <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}}">
-                                <Binding Path="SelectCalibration.MarkPoint.X" />
-                                <Binding Path="SelectCalibration.MarkPoint.Y" />
+                            <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}">
+                                <Binding Path="SelectCalibration.MarkPoint.X"
+                                         TargetNullValue="0.000"
+                                         FallbackValue="0.000" />
+                                <Binding Path="SelectCalibration.MarkPoint.Y"
+                                         TargetNullValue="0.000"
+                                         FallbackValue="0.000" />
                             </MultiBinding>
                         </TextBlock.Text>
                     </TextBlock>
-
-                    <TextBlock Text="请确保相机已对准标定板中心位置"
-                               Grid.Row="7"
-                               Foreground="Red"
-                               Margin="0,10"
-                               Grid.ColumnSpan="2" />
-
-
                 </Grid>
             </Grid>
 

+ 102 - 0
TeamAAS-VM/Views/Product/LightChannelList.xaml

@@ -0,0 +1,102 @@
+<UserControl x:Class="TeamAAS_VP.Views.Product.LightChannelList"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:TeamAAS_VP.Views.Product"
+             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:sys="clr-namespace:System;assembly=mscorlib"
+             xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
+             xmlns:valRules="clr-namespace:TeamAAS_VP.Identity"
+             xmlns:ext="clr-namespace:TeamAAS_VP.Extension"
+             xmlns:c="clr-namespace:TeamAAS_VP.ValueConverter"
+             xmlns:lex="http://wpflocalizeextension.codeplex.com"
+             xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.Product"
+             lex:LocalizeDictionary.DesignCulture="zh-CN"
+             lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
+             lex:ResxLocalizationProvider.DefaultDictionary="Lang"
+             mc:Ignorable="d"
+             d:Background="White"
+             d:DataContext="{d:DesignInstance Type=vm:LightChannelListViewModel}"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             FontFamily="{DynamicResource DefaultFont}">
+    <prism:Dialog.WindowStyle>
+        <Style TargetType="Window">
+            <Setter Property="prism:Dialog.WindowStartupLocation"
+                    Value="CenterScreen" />
+            <!--<Setter Property="WindowChrome.WindowChrome">
+            <Setter.Value>
+                <WindowChrome CaptionHeight="0"
+                              ResizeBorderThickness="1" />
+            </Setter.Value>
+        </Setter>-->
+            <Setter Property="WindowStyle"
+                    Value="None" />
+            <Setter Property="AllowDrop"
+                    Value="True" />
+            <Setter Property="BorderThickness"
+                    Value="0" />
+            <Setter Property="ShowInTaskbar"
+                    Value="False" />
+            <Setter Property="SizeToContent"
+                    Value="WidthAndHeight" />
+            <Setter Property="WindowState"
+                    Value="Normal" />
+            <Setter Property="Topmost"
+                    Value="True" />
+        </Style>
+    </prism:Dialog.WindowStyle>
+
+    <Grid HorizontalAlignment="Center">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*" />
+            <RowDefinition Height="50" />
+        </Grid.RowDefinitions>
+
+        <!--参数详情-->
+        <StackPanel>
+            <TextBlock Text="{lex:Loc 请选择要启用的光源通道}"
+                       FontWeight="Bold"
+                       Margin="0,0,0,8" />
+            <ListBox x:Name="AvailableListBox"
+                     ItemsSource="{Binding AllLightChannels}"
+                     SelectionMode="Extended"
+                     MinHeight="200"
+                     MaxHeight="500">
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="{Binding GlobalIndex}"
+                                       Margin="6,0" />
+                            <TextBlock Text="{Binding Name}" />
+                            <TextBlock Text="{Binding Description}"
+                                       Margin="6,0" />
+                            <CheckBox IsChecked="{Binding IsSelected}" />
+                        </StackPanel>
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
+            </ListBox>
+        </StackPanel>
+        
+        <StackPanel Grid.Row="1"
+                    Orientation="Horizontal"
+                    HorizontalAlignment="Right">
+            <Button Height="30"
+                    materialDesign:ButtonAssist.CornerRadius="10"
+                    ToolTip="{lex:Loc 确定}"
+                    Command="{Binding ConfirmCommand}">
+                <TextBlock Text="{lex:Loc 确定}" />
+            </Button>
+            <Button Height="30"
+                    Margin="20,0"
+                    materialDesign:ButtonAssist.CornerRadius="10"
+                    Style="{StaticResource MaterialDesignRaisedButton}"
+                    ToolTip="{lex:Loc 取消}"
+                    Command="{Binding CancelCommand}">
+                <TextBlock Text="{lex:Loc 取消}" />
+            </Button>
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 28 - 0
TeamAAS-VM/Views/Product/LightChannelList.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace TeamAAS_VP.Views.Product
+{
+    /// <summary>
+    /// LightChannelList.xaml 的交互逻辑
+    /// </summary>
+    public partial class LightChannelList : UserControl
+    {
+        public LightChannelList()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 8 - 1
TeamAAS-VM/Views/Product/PlcPointParams.xaml

@@ -232,7 +232,14 @@
                                     Margin="5,2"
                                     MinWidth="80"
                                     Command="{Binding DeletePointCommand}" />
-                            
+                            <Button Content="上移"
+                                    Margin="5,2"
+                                    MinWidth="80"
+                                    Command="{Binding MovePointUpCommand}" />
+                            <Button Content="下移"
+                                    Margin="5,2"
+                                    MinWidth="80"
+                                    Command="{Binding MovePointDownCommand}" />
                         </StackPanel>
                         <DataGrid x:Name="dgPoints"
                                   AutoGenerateColumns="False"

+ 16 - 14
TeamAAS-VM/Views/Product/ProcessBasics.xaml

@@ -127,6 +127,8 @@
                                    MinHeight="35" />
                     <RowDefinition Height="auto"
                                    MinHeight="35" />
+                    <RowDefinition Height="auto"
+                                   MinHeight="35" />
                 </Grid.RowDefinitions>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="auto" />
@@ -219,27 +221,27 @@
                     </ComboBox.ItemTemplate>
                 </ComboBox>
 
-                <!-- 光源通道配置 -->
+                <!-- 光源通道配置(已改为弹窗选择) -->
                 <TextBlock Text="{lex:Loc 光源通道,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}"
                            Grid.Row="7"
-                           Grid.Column="0" />
-                <StackPanel Grid.Row="7"
-                            Grid.Column="1"
-                            Orientation="Horizontal">
-                    <Button Content="{lex:Loc 添加通道}"
-                            Command="{Binding AddLightChannelCommand}"
-                            Margin="0,0,5,0" />
-                    <Button Content="{lex:Loc 删除通道}"
-                            Command="{Binding RemoveLightChannelCommand}"
-                            Margin="0,0,5,0" />
-                </StackPanel>
+                           Grid.RowSpan="2" />
+                <Button Grid.Row="7"
+                        Grid.Column="1"
+                        HorizontalAlignment="Right"
+                        materialDesign:HintAssist.Hint="{lex:Loc 选择光源通道}"
+                        Style="{StaticResource MaterialDesignFloatingActionButton}"
+                        Command="{Binding SelectLightChannelCommand}">
+                    <materialDesign:PackIcon Width="20"
+                                             Height="20"
+                                             Kind="ListBoxOutline" />
+                </Button>
 
                 <ListBox Grid.Row="8"
-                         Grid.ColumnSpan="2"
+                         Grid.Column="1"
                          ItemsSource="{Binding SelectProcedure.LightChannels}"
                          SelectedItem="{Binding SelectedLightChannel}"
                          Height="120"
-                         Margin="0,10,0,0">
+                         Margin="0,5,0,0">
                     <ListBox.ItemTemplate>
                         <DataTemplate>
                             <TextBlock Width="120"