using MuchInfo.Chart.Data.Models; using MuchInfo.Chart.DataAdapter; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace MuchInfo.Chart.FormulaEdit { public class EditFormulaViewModel { private IDataService _iDataService; public EditFormulaViewModel(List programModels) { _programModels = programModels; _iDataService = new DataService(); SelectProgramModel = _programModels.FirstOrDefault(); } //编辑公式集合 private List _programModels; /// /// 编辑公式集合 /// public List ProgramModels { get { return _programModels; } set { _programModels = value; } } private ProgramModel _selectProgramModel; /// /// 当前选择的公式 /// public ProgramModel SelectProgramModel { get { return _selectProgramModel; } set { _selectProgramModel = value; } } /// /// 修改用户编辑参数 /// public void ChangeParam() { Task.Factory.StartNew(() => { _iDataService.SaveFormulaParams(ProgramModels); }); } /// /// 调用公式编辑器编辑公式 /// public void EditFormula() { if (SelectProgramModel != null) { var formula = SelectProgramModel.CovertToFormulaModel(); _iDataService.EditFormula(formula.FormulaName); } } /// /// 打开公式管理器 /// public void OpenEditer() { if (SelectProgramModel != null) { var formula = SelectProgramModel.CovertToFormulaModel(); _iDataService.OpenFormulaEdit(formula.FormulaName); } } } }