Exemplo n.º 1
0
        // creates different alert types from line
        public static AbstractAlert FromLine(string data)
        {
            int id = int.Parse(Utility.GetSubstring(data, ';', 0));

            data = Utility.GetSubstring(data, ';', 1, false);

            AbstractAlert tmp = CreateChildClass(id);

            tmp.BaseFromLine(data);
            return(tmp);
        }
Exemplo n.º 2
0
        public static AbstractAlert[] CreateChildClasses()
        {
            if (_childClassTypes == null)
            {
                _childClassTypes = Assembly.GetAssembly(typeof(AbstractAlert)).GetTypes().Where(t => t.IsSubclassOf(typeof(AbstractAlert)));
            }

            AbstractAlert[] output = new AbstractAlert[_childClassTypes.Count()];
            for (int i = 0; i < output.Length; i++)
            {
                output[i] = (AbstractAlert)Activator.CreateInstance(_childClassTypes.ElementAt(i).UnderlyingSystemType);
            }

            return(output);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates alert from modified data that user specified when creating alert.
        /// </summary>
        /// <param name="panel">Panel with filled controls.</param>
        /// <param name="edited">If alert is edited don't add it to list (already in it).</param>
        /// <returns></returns>
        public bool CreateAlert(AlertData alertData, Notification notification, MetroPanel panel, bool edited = false, AbstractAlert newAlert = null)
        {
            // Alert type is changed
            if (newAlert != null)
            {
                newAlert.AlertData     = alertData;
                newAlert._notification = notification;
                if (newAlert.Create(panel))
                {
                    Alerts[Alerts.IndexOf(this)] = newAlert;
                    newAlert.Subscribe(newAlert.CandlesLength.MinLength, newAlert.CandlesLength.MaxLength);
                    SaveAlertsAsync();
                    return(true);
                }
            }

            AlertData     = alertData;
            _notification = notification;
            if (Create(panel))
            {
                // initializing alert
                if (!edited)
                {
                    Alerts.Add(this);
                }
                Subscribe(CandlesLength.MinLength, CandlesLength.MaxLength);
                SaveAlertsAsync();
                return(true);
            }
            return(false);
        }