public CustomAlertForm()
 {
     _coinList = AbstractAPI.CryptoCompareAPI.GetCoinList();
     PopulateSymbols();
     InitializeComponent();
     cboxCondition.Items.AddRange(AbstractAlert.CreateChildClasses());
     AbstractAlert.OnSubscribeFail += AbstractAlert_OnSubscribeFail;
 }
        private void btnAddAlert_Click(object sender, EventArgs e)
        {
            AlertData    alertData;
            Notification ntfy;

            // user input checking
            // creating notification
            if (!GetNotification(out ntfy))
            {
                MessageBox.Show("Something is wrong in interval section.");
                return;
            }

            if (cboxMarket.Items.Count == 0 || cboxExchange.Items.Count == 0)
            {
                MessageBox.Show("Please populate required fields.");
                return;
            }

            alertData = new AlertData(_baseSymbol, cboxMarket.Text.ToUpper(), _baseName, cboxExchange.Text);

            if (_editedAlertId != -1)
            {
                AbstractAlert.Alerts[_editedAlertId].Unsubscribe();
                AbstractAlert.Alerts[_editedAlertId].StopNotifying(false, true);
                MainForm.RemoveNotification(_editedAlertId);
                // Alert type changed
                if (AbstractAlert.Alerts[_editedAlertId].GetType() != ((AbstractAlert)cboxCondition.SelectedItem).GetType())
                {
                    if (!AbstractAlert.Alerts[_editedAlertId].CreateAlert(alertData, ntfy, (MetroPanel)tabCondition.Controls["panel"], true, (AbstractAlert)cboxCondition.SelectedItem))
                    {
                        _editedAlertId = -1;
                        return;
                    }
                    AbstractAlert.Alerts[_editedAlertId] = (AbstractAlert)cboxCondition.SelectedItem;
                }
                if (!AbstractAlert.Alerts[_editedAlertId].CreateAlert(alertData, ntfy, (MetroPanel)tabCondition.Controls["panel"], true))
                {
                    _editedAlertId = -1;
                    return;
                }
            }
            else
            {
                // value in custom alert is not valid
                if (!((AbstractAlert)(cboxCondition.SelectedItem)).CreateAlert(alertData, ntfy, (MetroPanel)tabCondition.Controls["panel"]))
                {
                    return;
                }
            }

            MainForm.AddAlertToGridView(_editedAlertId);
            _editedAlertId = -1;
            // creating new alert to replace the old one
            cboxCondition.Items[cboxCondition.SelectedIndex] = AbstractAlert.CreateChildClass(((AbstractAlert)cboxCondition.SelectedItem).GetType());
            Close();
        }
Beispiel #3
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            await AbstractAlert.LoadAlertsAsync();

            for (int i = 0; i < AbstractAlert.Alerts.Count; i++)
            {
                grdAlerts.Rows.Add(AbstractAlert.Alerts[i].Row);
                grdAlerts.Rows[i].Cells["IndicatorValue"].ToolTipText = AbstractAlert.Alerts[i].IndicatorValueToolTip;
            }

            grdAlerts.ClearSelection();
        }
Beispiel #4
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     AbstractAlert.UnsubscribeAll();
 }