Ejemplo n.º 1
0
        /// <summary>
        /// load parameter settings from file /
        /// загрузить настройки параметра из файла
        /// </summary>
        private void GetValueParameterSaveByUser(IndicatorParameter parameter)
        {
            if (Name == "")
            {
                return;
            }

            if (!File.Exists(@"Engine\" + Name + @"Parametrs.txt"))
            {
                return;
            }
            try
            {
                using (StreamReader reader = new StreamReader(@"Engine\" + Name + @"Parametrs.txt"))
                {
                    while (!reader.EndOfStream)
                    {
                        string[] save = reader.ReadLine().Split('#');

                        if (save[0] == parameter.Name)
                        {
                            parameter.LoadParamFromString(save);
                        }
                    }
                    reader.Close();
                }
            }
            catch (Exception)
            {
                // ignore
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// load parameter settings /
        /// загрузить настройки параметра
        /// </summary>
        /// <param name="newParameter">setting parameter you want to load / параметр настройки которого нужно загрузить</param>
        private IndicatorParameter LoadParameterValues(IndicatorParameter newParameter)
        {
            GetValueParameterSaveByUser(newParameter);

            newParameter.ValueChange += Parameter_ValueChange;

            _parameters.Add(newParameter);

            return(newParameter);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// create bool type parameter /
        /// создать параметр типа Bool
        /// </summary>
        /// <param name="name">param name / Имя параметра</param>
        /// <param name="value">default value / Значение по умолчанию</param>
        public IndicatorParameterBool CreateParameterBool(string name, bool value)
        {
            IndicatorParameter newParameter = _parameters.Find(p => p.Name == name);

            if (newParameter != null)
            {
                return((IndicatorParameterBool)newParameter);
            }

            newParameter = new IndicatorParameterBool(name, value);
            return((IndicatorParameterBool)LoadParameterValues(newParameter));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// create string parameter /
        /// создать параметр типа String
        /// </summary>
        /// <param name="name">param name / Имя параметра</param>
        /// <param name="value">default value / Значение по умолчанию</param>
        /// <param name="collection">values / Возможные значения для параметра</param>
        public IndicatorParameterString CreateParameterStringCollection(string name, string value, List <string> collection)
        {
            IndicatorParameter newParameter = _parameters.Find(p => p.Name == name);

            if (newParameter != null)
            {
                return((IndicatorParameterString)newParameter);
            }

            newParameter = new IndicatorParameterString(name, value, collection);

            return((IndicatorParameterString)LoadParameterValues(newParameter));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// create int parameter /
        /// создать параметр типа Int
        /// </summary>
        /// <param name="name">param name / Имя параметра</param>
        /// <param name="value">default value / Значение по умолчанию</param>
        public IndicatorParameterInt CreateParameterInt(string name, int value)
        {
            IndicatorParameter newParameter = _parameters.Find(p => p.Name == name);

            if (newParameter != null)
            {
                return((IndicatorParameterInt)newParameter);
            }

            newParameter = new IndicatorParameterInt(name, value);

            ParameterDigit param = new ParameterDigit(newParameter);

            ParametersDigit.Add(param);

            return((IndicatorParameterInt)LoadParameterValues(newParameter));
        }
Ejemplo n.º 6
0
        public void Bind(IndicatorParameter param)
        {
            if (param.Type != Type)
            {
                throw new Exception("Can`t bind param with not equals types");
            }

            if (param.Type == IndicatorParameterType.Bool)
            {
                ((IndicatorParameterBool)this).ValueBool = ((IndicatorParameterBool)param).ValueBool;
            }
            if (param.Type == IndicatorParameterType.Decimal)
            {
                ((IndicatorParameterDecimal)this).ValueDecimal = ((IndicatorParameterDecimal)param).ValueDecimal;
            }
            if (param.Type == IndicatorParameterType.Int)
            {
                ((IndicatorParameterInt)this).ValueInt = ((IndicatorParameterInt)param).ValueInt;
            }
            if (param.Type == IndicatorParameterType.String)
            {
                ((IndicatorParameterString)this).ValueString = ((IndicatorParameterString)param).ValueString;
            }

            param.ValueChange += delegate
            {
                if (param.Type == IndicatorParameterType.Bool)
                {
                    ((IndicatorParameterBool)this).ValueBool = ((IndicatorParameterBool)param).ValueBool;
                }
                if (param.Type == IndicatorParameterType.Decimal)
                {
                    ((IndicatorParameterDecimal)this).ValueDecimal = ((IndicatorParameterDecimal)param).ValueDecimal;
                }
                if (param.Type == IndicatorParameterType.Int)
                {
                    ((IndicatorParameterInt)this).ValueInt = ((IndicatorParameterInt)param).ValueInt;
                }
                if (param.Type == IndicatorParameterType.String)
                {
                    ((IndicatorParameterString)this).ValueString = ((IndicatorParameterString)param).ValueString;
                }
            };

            this.ValueChange += delegate
            {
                if (param.Type == IndicatorParameterType.Bool)
                {
                    ((IndicatorParameterBool)param)._valueBool = ((IndicatorParameterBool)this).ValueBool;
                }
                if (param.Type == IndicatorParameterType.Decimal)
                {
                    ((IndicatorParameterDecimal)param)._valueDecimal = ((IndicatorParameterDecimal)this).ValueDecimal;
                }
                if (param.Type == IndicatorParameterType.Int)
                {
                    ((IndicatorParameterInt)param)._valueInt = ((IndicatorParameterInt)this).ValueInt;
                }
                if (param.Type == IndicatorParameterType.String)
                {
                    ((IndicatorParameterString)param)._valueString = ((IndicatorParameterString)this).ValueString;
                }
            };
        }
Ejemplo n.º 7
0
 public ParameterDigit(IndicatorParameter param)
 {
     _parameter = param;
 }