Esempio n. 1
0
        /// <summary> Добавить сигнал </summary>
        /// <param name="newSignal"></param>
        public void AddSignal(SignalMarket newSignal)
        {
            if (newSignal.IsNull())
            {
                return;
            }
            var oldEl = this.Signals.FirstOrDefault(s =>
                                                    s.Comment == newSignal.Comment &&
                                                    s.Condition == newSignal.Condition &&
                                                    s.DateTime == newSignal.DateTime &&
                                                    s.Infinity == newSignal.Infinity &&
                                                    s.Price == newSignal.Price &&
                                                    s.SecClass == newSignal.SecClass &&
                                                    s.TimeFrame == newSignal.TimeFrame &&
                                                    s.Type == newSignal.Type &&
                                                    s.Volume == newSignal.Volume
                                                    );

            lock (syncObj)
            {
                if (oldEl.NotIsNull())
                {
                    this.Signals.Remove(oldEl);
                }
                this.Signals.Add(newSignal);
            }
            if (this.OnAdd.NotIsNull())
            {
                this.OnAdd(newSignal);
            }
            this.SaveSignals();
        }
Esempio n. 2
0
 /// <summary>
 /// Получить индекс в коллекции
 /// </summary>
 /// <param name="signal"></param>
 /// <returns></returns>
 public int GetIndex(SignalMarket signal)
 {
     lock (syncObj)
     {
         return(Signals.Count > 0 ? Signals.IndexOf(signal) : 0);
     }
 }
Esempio n. 3
0
        /// <summary> Удалить сигнал </summary>
        /// <param name="newSignal"></param>
        public bool RemoveSignal(SignalMarket remSignal)
        {
            if (remSignal.IsNull())
            {
                return(false);
            }
            bool res = false;

            lock (syncObj)
            {
                res = Signals.Remove(remSignal);
            }
            if (this.OnRemove.NotIsNull() && res)
            {
                this.OnRemove(remSignal);
            }
            this.SaveSignals();
            return(res);
        }
Esempio n. 4
0
        public bool MoveDown(SignalMarket signal)
        {
            if (signal.IsNull())
            {
                return(false);
            }
            var index = this.Signals.IndexOf(signal);

            if (index >= 0 && index < this.Signals.Count - 1)
            {
                lock (syncObj)
                {
                    this.Signals.Remove(signal);
                    this.Signals.Insert(index + 1, signal);
                    this.SaveSignals();
                }
                return(true);
            }
            return(false);
        }