using Aitex.Core.UI.MVVM; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using OpenSEMI.ClientBase; using System.Collections.Generic; using System.Windows.Input; using MECF.Framework.Common.CommonData; using VirgoUI.Client.Models.Sys; namespace VirgoUI.Client.Models.Utility.EndPoint { class EndPointViewModel : ModuleUiViewModelBase, ISupportMultipleSystem { private int MenuPermission; public class AlogarithmTypeItem { public string AlogarithmName { get; set; } } public List AlgorithmTypes { get; set; } public ICommand SaveCommand { get; private set; } public EndPointConfigItem ConfigItem { get; set; } public EndPointViewModel() { MenuPermission = ClientApp.Instance.GetPermission("epd"); SaveCommand = new DelegateCommand(SaveConfig); ConfigItem = new EndPointConfigItem(); AlgorithmTypes = new List() { new AlogarithmTypeItem() { AlogarithmName = "Unknown"}, new AlogarithmTypeItem() { AlogarithmName = "Above_ABS_Value"}, new AlogarithmTypeItem() { AlogarithmName = "Below_ABS_Value"}, new AlogarithmTypeItem() { AlogarithmName = "Drop_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Up_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Range_In"}, new AlogarithmTypeItem() { AlogarithmName = "Gradient"}, new AlogarithmTypeItem() { AlogarithmName = "Peek"}, new AlogarithmTypeItem() { AlogarithmName = "Valley"}, new AlogarithmTypeItem() { AlogarithmName = "Min_Drop_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Min_Up_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Max_Drop_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Max_Up_Percent"}, new AlogarithmTypeItem() { AlogarithmName = "Rise_Fall"}, new AlogarithmTypeItem() { AlogarithmName = "Fall_Rise"}, }; } protected override void OnActivate() { base.OnActivate(); LoadConfig(); } protected override void OnDeactivate(bool close) { base.OnDeactivate(close); } public void LoadConfig() { string config = (string)QueryDataClient.Instance.Service.GetConfig("System.EndPoint.EndPointDefaultValue"); ConfigItem.SetValue(config); NotifyOfPropertyChange(nameof(ConfigItem)); } void SaveConfig(object param) { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation("System.SetConfig", "System.EndPoint.EndPointDefaultValue", ConfigItem.ToValue()); } protected override void InvokeBeforeUpdateProperty(Dictionary data) { base.InvokeBeforeUpdateProperty(data); } } }