/// <summary> /// Helper, loads custom indicators. /// </summary> void InitializeCustomPlatformIndicators() { List <Type> indicatorTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(PlatformIndicator), true, false, ReflectionHelper.GetApplicationEntryAssemblyReferencedAssemblies(), new Type[] { }); lock (this) { _indicatorsGroups.Add(IndicatorGroup.Custom, new Dictionary <string, PlatformIndicator>()); foreach (Type type in indicatorTypes) {// Extract user friendly names. string name = type.Name; if (UserFriendlyNameAttribute.GetTypeAttributeValue(type, ref name)) { name = type.Name + ", " + name; } if (type.GetConstructor(new Type[] { }) == null) {// Can not create indicator since it needs a parameterless constructor. continue; } PlatformIndicator indicator = (PlatformIndicator)Activator.CreateInstance(type); _indicatorsGroups[IndicatorGroup.Custom].Add(name, indicator); } } }
/// <summary> /// Will load all the indicators from the assembly. /// </summary> /// <param name="assembly"></param> public void CollectCustomIndicatorsFromAssembly(Assembly assembly) { List <Type> indicatorTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(typeof(PlatformIndicator), true, false, new Assembly[] { assembly }, new Type[] { }); lock (this) { if (_indicatorsGroups.ContainsKey(IndicatorGroup.Custom) == false) { _indicatorsGroups.Add(IndicatorGroup.Custom, new Dictionary <string, PlatformIndicator>()); } foreach (Type type in indicatorTypes) {// Extract user friendly names. string name = type.Name; if (UserFriendlyNameAttribute.GetTypeAttributeValue(type, ref name)) { name = type.Name + ", " + name; } if (type.GetConstructor(new Type[] { }) == null) {// Can not create indicator since it needs a parameterless constructor. continue; } PlatformIndicator indicator = (PlatformIndicator)Activator.CreateInstance(type); _indicatorsGroups[IndicatorGroup.Custom][name] = indicator; } } }
protected override void OnRemovedFromChart() { if (_indicator != null) { _indicator.IndicatorCalculatedEvent -= new Indicator.IndicatorCalculatedDelegate(_indicator_IndicatorCalculatedEvent); _indicator = null; } }
public PlatformIndicator SimpleClone() { PlatformIndicator indicator = OnSimpleClone(); indicator.RangeMaximum = this.RangeMaximum; indicator.RangeMinimum = this.RangeMinimum; return(indicator); }
/// <summary> /// /// </summary> public void UnInitialize() { lock (this) { if (_indicator != null) { if (_indicator.Parameters != null) { _indicator.Parameters.ParameterUpdatedValueEvent -= new IndicatorParameters.ParameterUpdatedValueDelegate(Parameters_ParameterUpdatedValueEvent); } _indicator.IndicatorCalculatedEvent -= new Indicator.IndicatorCalculatedDelegate(_indicator_IndicatorCalculatedEvent); _indicator = null; } } }
/// <summary> /// /// </summary> public bool Initialize(PlatformIndicator indicator) { lock (this) { _indicator = indicator; _indicator.IndicatorCalculatedEvent += new Indicator.IndicatorCalculatedDelegate(_indicator_IndicatorCalculatedEvent); _indicator.Parameters.ParameterUpdatedValueEvent += new IndicatorParameters.ParameterUpdatedValueDelegate(Parameters_ParameterUpdatedValueEvent); foreach (string setName in indicator.Results.SetsNamesUnsafe) { if (_outputResultSetsPens.ContainsKey(setName) == false) {// For newly added names, initialize with default pen color. _outputResultSetsPens.Add(setName, DefaultPen); } } } return(true); }
private void buttonNew_Click(object sender, EventArgs e) { if (listViewIndicatorTypes.SelectedItems.Count == 0 || _pendingIndicator == null) { return; } // Get rid of the _pending indicator reference as soon as possible. PlatformIndicator pendingIndicator = _pendingIndicator; _pendingIndicator = null; _session.DataProvider.DataBars.Indicators.AddIndicator(pendingIndicator); if (AddIndicatorEvent != null) { AddIndicatorEvent(pendingIndicator, GetSelectedPane()); } UpdateUI(); //// Select the newly created indicator. //this.listViewIndicators.Items[listViewIndicators.Items.Count - 1].Selected = true; //this.listViewIndicators.Focus(); //_pendingIndicator = null; // Invoke the creation of a new _pendingIndicator //listViewIndicatorTypes_SelectedIndexChanged(sender, e); // Select the newly created indicator. if (listViewIndicators.Items.Count > 0) { listViewIndicators.Items[listViewIndicators.Items.Count - 1].Selected = true; } listViewIndicators.Focus(); }
private void listViewIndicatorTypes_SelectedIndexChanged(object sender, EventArgs e) { if (listViewIndicatorTypes.SelectedItems.Count > 0) { string name = listViewIndicatorTypes.SelectedItems[0].Tag as string; // Just create the indicator, no need to set it up, this will be handled by the session itself. _pendingIndicator = (PlatformIndicator)IndicatorFactory.Instance.GetIndicatorCloneByName(name); foreach (string setName in GeneralHelper.EnumerableToArray<string>(_pendingIndicator.ChartSeries.OutputResultSetsPens.Keys)) { _pendingIndicator.ChartSeries.OutputResultSetsPens[setName] = Pens.WhiteSmoke; } indicatorControl1.IsReadOnly = true; indicatorControl1.SelectedObject = _pendingIndicator.ChartSeries; } else { indicatorControl1.SelectedObject = null; _pendingIndicator = null; } UpdateUI(); }
/// <summary> /// /// </summary> public bool Initialize(PlatformIndicator indicator) { lock (this) { _indicator = indicator; _indicator.IndicatorCalculatedEvent += new Indicator.IndicatorCalculatedDelegate(_indicator_IndicatorCalculatedEvent); _indicator.Parameters.ParameterUpdatedValueEvent += new IndicatorParameters.ParameterUpdatedValueDelegate(Parameters_ParameterUpdatedValueEvent); foreach (string setName in indicator.Results.SetsNamesUnsafe) { if (_outputResultSetsPens.ContainsKey(setName) == false) {// For newly added names, initialize with default pen color. _outputResultSetsPens.Add(setName, DefaultPen); } } } return true; }
void control_RemoveIndicatorEvent(PlatformIndicator indicator) { }
void control_AddIndicatorEvent(PlatformIndicator indicator, ChartPane pane) { if (pane == null) { pane = chartControl.CreateSlavePane(indicator.Name, SlaveChartPane.MasterPaneSynchronizationModeEnum.XAxis, this.Height / 4); pane.RightMouseButtonSelectionMode = ChartPane.SelectionModeEnum.HorizontalZoom; pane.Add(indicator.ChartSeries); // Establish proper Y axis values. //pane.FitDrawingSpaceToScreen(true, true); } else { pane.Add(indicator.ChartSeries); } }