using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using TradeIdeas.XML;
namespace TradeIdeas.TIProGUI.Charting
{
public class IndicatorParameter
{
public string Name { get; set; }
public string ReferenceId { get; set; }
public string Format { get; set; }
public string Description { get; set; }
public double Minimum { get; set; }
public double Maximum { get; set; }
///
/// The server generated id for the chart indicator that this parameter belongs to.
///
public int ColumnId { get; set; }
///
/// The default value of the parameter.
///
public double DefaultValue { get; set; }
///
/// The current value of the parameter.
///
public double Value { get; set; }
public IndicatorParameter() { }
public void SaveLayout(XmlNode parent)
{
parent.SetProperty("NAME", Name);
parent.SetProperty("REFERENCE_ID", ReferenceId);
parent.SetProperty("DESCRIPTION", Description);
parent.SetProperty("FORMAT", Format);
parent.SetProperty("MINIMUM", Minimum);
parent.SetProperty("MAXIMUM", Maximum);
parent.SetProperty("DEFAULT_VALUE", DefaultValue);
parent.SetProperty("VALUE", Value);
}
public void Restore(XmlNode description, int? index = null)
{
string propertySuffix = "";
if (index.HasValue)
propertySuffix = index.Value.ToString();
Name = description.Property("NAME" + propertySuffix, "");
ReferenceId = description.Property("REFERENCE_ID" + propertySuffix, "");
Description = description.Property("DESCRIPTION" + propertySuffix, "");
Format = description.Property("FORMAT" + propertySuffix, "");
Minimum = description.Property("MINIMUM" + propertySuffix, 1.0);
Maximum = description.Property("MAXIMUM" + propertySuffix, 100);
DefaultValue = description.Property("DEFAULT_VALUE" + propertySuffix, 0.00);
ColumnId = description.Property("COLUMN_ID" + propertySuffix, 0);
Value = description.Property("VALUE" + propertySuffix, double.NaN);
if (double.IsNaN(Value))
Value = DefaultValue;
}
public IndicatorParameter DeepCopy()
{
IndicatorParameter copy = new IndicatorParameter();
copy.Name = Name;
copy.ReferenceId = ReferenceId;
copy.Description = Description;
copy.Format = Format;
copy.Minimum = Minimum;
copy.Maximum = Maximum;
copy.DefaultValue = DefaultValue;
copy.ColumnId = ColumnId;
copy.Value = Value;
return copy;
}
}
}