public bool EditStrategy(StrategyBase strategy) { Type type = strategy.GetType(); StrategyConfigurationInfo info = Items.FirstOrDefault(i => i.StrategyType == type); if (info == null) { XtraMessageBox.Show("Configuration form not found for strategy " + type.Name); return(false); } try { ConstructorInfo ci = info.ConfigurationFormType.GetConstructor(new Type[] { }); StrategySpecificConfigurationControlBase specificControl = (StrategySpecificConfigurationControlBase)ci.Invoke(new object[] { }); StrategyConfigurationForm form = new StrategyConfigurationForm(); form.Text = strategy.Name + " - Configuration"; form.StrategySpecificSettingsControl = specificControl; form.Strategy = strategy; if (form.ShowDialog() != DialogResult.OK) { return(false); } if (strategy != form.Strategy) { strategy.Assign(form.Strategy); } } catch (Exception e) { XtraMessageBox.Show("Invalid configuration form for strategy " + type.Name + " " + e.ToString()); return(false); } return(true); }
public void Add(StrategyConfigurationInfo info) { StrategyConfigurationInfo prev = Items.FirstOrDefault(i => i.StrategyType == info.StrategyType); if (prev != null) { Items.Remove(prev); } Items.Add(info); }
public bool ShowData(StrategyBase strategy) { Type type = strategy.GetType(); StrategyConfigurationInfo info = Items.FirstOrDefault(i => i.StrategyType == type); if (info == null) { XtraMessageBox.Show("Data form not found for strategy " + type.Name); return(false); } try { ConstructorInfo ci = info.DataFormType.GetConstructor(new Type[] { }); StrategyDataForm form = (StrategyDataForm)ci.Invoke(null); form.Text = strategy.Name + " - Data"; form.Strategy = strategy; form.Show(); } catch (Exception e) { XtraMessageBox.Show("Invalid configuration form for strategy " + type.Name + " " + e.ToString()); return(false); } return(true); }