using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.MorkCL.Model.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.MorkCL.ViewModel { public class ParSetViewModel:NotifyBase { public ParSetViewModel() { Param = Json.Data; SaveInfoCommand = new(() => { if (MessageNotify.GetInstance.ShowDialog("确认保存配置文件?")) { if (Param.IsUseSplitStorage) { if (!VerifyData()) { MessageNotify.GetInstance.ShowNotify("失败", "参数不合规,保存失败。", EnumPromptType.Error); return; } } Json.Save(); MessageNotify.GetInstance.ShowNotify("成功", "保存参数设置成功。"); } }); } private ConnectPar _param; /// /// 配置参数。 /// public ConnectPar Param { get { return _param; } set { _param = value; OnPropertyChanged(); } } /// /// 保存配置信息 /// public BPARelayCommand SaveInfoCommand { get; set; } private bool VerifyData() { if (CheckNumRange(Param.FryPanAccessoriesMin_1,1,8)&& CheckNumRange(Param.FryPanAccessoriesMax_1, 1, 8)&& CheckNumRange(Param.FryPanAccessoriesMin_2, 1, 8)&& CheckNumRange(Param.FryPanAccessoriesMax_2, 1, 8)) { return true; } else { MessageNotify.GetInstance.ShowDialog("辅料库位的位置号码应大于等于 1 且 小于等于8 ,请检查后重试。",DialogType.Error); return false; } } private bool CheckNumRange(int number,int min,int max) { if (number >= min && number <= max) { return true; } else return false; } } }