public override void InitContextMenu() { base.InitContextMenu(); PredicateMenuList.Clear(); MainViewModel.Resource.ConditionPrototypeList.ForEach(v => { var command = new CommonCommand((obj) => { var o = v.CreateInstance() as ICondition; o.GetInstrumentList = () => { var l = new List <IInstrument>(); foreach (var inst in InstrumentList) { l.Add(inst); } return(l); }; o.AnalyseDataSource = CurrentDataSource; var vm = new ConditionViewModel() { TargetObject = o }; PredicateList.Add(vm); TargetProject.PredicateList.Add(o); }); command.Name = "New " + v.Name; command.Memo = v.Memo; command.ForegroundBrush = new SolidColorBrush(Colors.Blue); PredicateMenuList.Add(command); }); var pcommand = new CommonCommand((obj) => { if (CurrentPredicate != null && PredicateList.Contains(CurrentPredicate)) { PredicateList.Remove(CurrentPredicate); } }); pcommand.Name = "Delete Predicate"; pcommand.Memo = "Delete Current Predicate"; pcommand.ForegroundBrush = new SolidColorBrush(Colors.Orange); PredicateMenuList.Add(pcommand); }
public void OpenCondition(ConditionViewModel condition) { if (condition != null && condition.TargetObject != null) { condition.AnalyseStartTime = AnalyseStartTime; condition.AnalyseEndTime = TestEndTime; condition.AnalyseGrade = AnalyseGrade; //condition.TargetObject.GetMarketData = (instrument,start,end,grade) => { return CurrentDataSource.GetDataList(instrument,start,end,grade); }; condition.TargetObject.AnalyseDataSource = CurrentDataSource; var c = new ConditionControl() { DataContext = condition }; if (OpenView != null) { OpenView("Name", c, true); } } }
public virtual void InitContextMenu() { ConditionMenuList.Clear(); MainViewModel.Resource.ConditionPrototypeList.ForEach(v => { var command = new CommonCommand((obj) => { var o = v.CreateInstance() as ICondition; o.GetInstrumentList = () => { var l = new List <IInstrument>(); foreach (var inst in InstrumentList) { l.Add(inst); } return(l); }; o.AnalyseDataSource = CurrentDataSource; var vm = new ConditionViewModel() { TargetObject = o }; ConditionList.Add(vm); GetTargetProject().ConditionList.Add(o); }); command.Name = "New " + v.Name; command.Memo = v.Memo; command.ForegroundBrush = new SolidColorBrush(Colors.Blue); ConditionMenuList.Add(command); }); var dcommand = new CommonCommand((obj) => { if (CurrentCondition != null && ConditionList.Contains(CurrentCondition)) { ConditionList.Remove(CurrentCondition); } }); dcommand.Name = "Delete Condition"; dcommand.Memo = "Delete Current Condition"; dcommand.ForegroundBrush = new SolidColorBrush(Colors.Orange); ConditionMenuList.Add(dcommand); }