public frmAddPublicAddress()
        {
            InitializeComponent();

            if (File.Exists(Application.StartupPath + @"\images\c3.ico"))
                this.Icon = new Icon(Application.StartupPath + @"\images\c3.ico");

            cAddress = new AddressCall();

            Coins clist = new Coins();
            cbxCoins.DataSource = clist.CoinList;
        }
Exemplo n.º 2
0
        public void RefreshAddressControls()
        {
            string strError = string.Empty;
            lblAddressStatus.SetThreadSafeProperty(() => lblAddressStatus.Text, "Refreshing addresses...");
            picRefreshAddresses.Image = Properties.Resources.loading;

            try
            {
                NotificationCall call = new NotificationCall();
                AddressCall AddrCall = new AddressCall();

                foreach (PublicAddress address in SettingsManager.PublicAddresses)
                {
                    strError = string.Empty;

                    lblAddressStatus.SetThreadSafeProperty(() => lblAddressStatus.Text, "Getting address data for " + address.CoinName.ToString() + "...");
                    AddressControl addrControl = addr.GetPublicAddressControl(address, ref strError);
                    if (strError != string.Empty)
                        this.InvokeThreadSafeMethod(() => Notify.ShowMessage(this, Notify.MessageType.Error, "There was an error with " + addrControl.AddressObject.CoinName.ToString() + ": " + strError));
                    else
                        flpControls.InvokeThreadSafeMethod(() => UpdateExistingAddress(addrControl));

                    if (address.Notify)
                    {
                        string notificationMessage = string.Empty;
                        if (address.Condition == ">")
                            if (Convert.ToDecimal(address.Balance) > Convert.ToDecimal(address.Price))
                                notificationMessage = address.CoinName + " is above your notification price. Current Balance: " + address.Balance + ", Notification Price: " + address.Price;
                        if (address.Condition == "<")
                            if (Convert.ToDecimal(address.Balance) < Convert.ToDecimal(address.Price))
                                notificationMessage = address.CoinName + " is below your notification price. Current Balance: " + address.Balance + ", Notification Price: " + address.Price;
                        if (address.Condition == "=")
                            if (Convert.ToDecimal(address.Balance) == Convert.ToDecimal(address.Price))
                                notificationMessage = address.CoinName + " is the same as your notification price. Current Balance: " + address.Balance + ", Notification Price: " + address.Price;

                        if (notificationMessage != string.Empty)
                        {
                            lblAddressStatus.SetThreadSafeProperty(() => lblAddressStatus.Text, "Notification enabled and condition met... Sending notification for " + address.CoinName);
                            call.SendNotification(SettingsManager.AppSettings.NotificationData, notificationMessage, ref strError);

                            address.Notify = false;
                            foreach (AddressControl ctrl in flpControls.Controls)
                                if (ctrl.AddressObject.PublicAddressPK == address.PublicAddressPK)
                                    ctrl.txtNotify.SetThreadSafeProperty(() => ctrl.txtNotify.Text, "N/A");

                            if (!string.IsNullOrEmpty(strError))
                                this.InvokeThreadSafeMethod(() => Notify.ShowMessage(this, Notify.MessageType.Error, "An error occurred while trying to send the notification: " + strError));

                            AddrCall.UpdateAddressNotification(address, ref strError);
                            if (!string.IsNullOrEmpty(strError))
                                this.InvokeThreadSafeMethod(() => Notify.ShowMessage(this, Notify.MessageType.Error, "An error occurred while trying to update the address notification: " + strError));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.InvokeThreadSafeMethod(() => Notify.ShowMessage(this, Notify.MessageType.Error, "There was an error while enumerting address list: " + ex.Message));
            }

            picRefreshAddresses.SetThreadSafeProperty(() => picRefreshAddresses.Image, Properties.Resources.refresh);
            flpControls.InvokeThreadSafeMethod(() => flpControls.Focus());
            SettingsManager.AppSettings.AddressCheckData.IsRunning = false;
            SettingsManager.AppSettings.AddressCheckData.RefreshRateTemp = SettingsManager.AppSettings.AddressCheckData.RefreshRate; //Set the temp interval so that when the time is changed, it can be refreshed here
        }
Exemplo n.º 3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            if (File.Exists(Application.StartupPath + @"\images\c3.ico"))
                this.Icon = new Icon(Application.StartupPath + @"\images\c3.ico");

            string strError = string.Empty;
            log = new Logger();
            addr = new AddressCall();

            if (!File.Exists(SettingsManager.DatabaseFile))
            {
                MessageBox.Show("The database, C3DB, wasn't found in the same location as C3. C3 cannot continue without it."
                        + Environment.NewLine + Environment.NewLine + strError, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(Environment.ExitCode);
            }
            SettingsManager.SetApplicationSettings(ref strError);

            if (!string.IsNullOrEmpty(strError))
                Notify.ShowMessage(this, Notify.MessageType.Error, "There was an error setting up the application settings: " + strError);

            if (SettingsManager.PublicAddresses.Count == 0)
                Notify.ShowMessage(this, Notify.MessageType.Warn, "You don't have any addresses setup. Go to Settings --> Options to add addresses.");
        }
Exemplo n.º 4
0
        private void Buttons_Click(object sender, EventArgs e)
        {
            string strError = string.Empty;

            if (sender == btnOK)
                this.Close();
            else if (sender == btnAddPublicAddress)
            {
                frmAddPublicAddress add = new frmAddPublicAddress();
                add.ShowDialog();
            }
            else if (sender == btnDeleteAddress)
            {
                if (lvAddresses.SelectedItems.Count > 0)
                {
                    PublicAddress address = SettingsManager.PublicAddresses.Single(x => x.Address == lvAddresses.SelectedItems[0].SubItems[2].Text);

                    AddressCall cAddress = new AddressCall();
                    cAddress.DeletePublicAddress(address.PublicAddressPK, ref strError);

                    if (!string.IsNullOrEmpty(strError))
                    {
                        MessageBox.Show("An error occurred while trying to delete that address from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        SettingsManager.PublicAddresses.Remove(address);
                        lvAddresses.Items.Remove(lvAddresses.SelectedItems[0]);

                        frmMain main = null;
                        foreach (Form form in Application.OpenForms)
                            if (form.Name == "frmMain")
                                main = (frmMain)form;
                        main.RemoveAddressControl(address);
                    }
                }
                else
                    MessageBox.Show("Please select an item", "No Item Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (sender == btnEditAddress)
            {
                if (lvAddresses.SelectedItems.Count > 0)
                {
                    frmEditPublicAddress edit = new frmEditPublicAddress(SettingsManager.PublicAddresses.Single(x => x.Address == lvAddresses.SelectedItems[0].SubItems[2].Text));
                    edit.ShowDialog();
                }
                else
                    MessageBox.Show("Please select an item", "No Item Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (sender == btnSaveNotificationSettings)
            {
                NotificationCall call = new NotificationCall();
                Notification notification = new Notification()
                {
                    EmailAddress = txtEmailAddress.Text,
                    PhoneNumber = txtPhoneNumber.Text,
                    NotificationType = cbxNotificationType.SelectedIndex == -1 ? "" : cbxNotificationType.SelectedItem.ToString(),
                    Carrier = cbxCarrier.SelectedItem.ToString(),
                    CarrierGateway = cbxCarrier.SelectedValue.ToString()
                };
                call.UpdatePublicAddress(notification, ref strError);

                if (!string.IsNullOrEmpty(strError))
                    MessageBox.Show("An error occurred while trying to save the notification data.\n\r\n\r" + strError, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                {
                    SettingsManager.AppSettings.NotificationData = notification;
                    MessageBox.Show("Those notification settings have been saved successfully!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (sender == btnAddMarketCapNotification)
            {
                frmAddMarketCapNotification notifcation = new frmAddMarketCapNotification();
                notifcation.ShowDialog();
            }
            else if (sender == btnEditMarketCapNotification)
            {
                if (lvMarketCapNotifications.SelectedItems.Count > 0)
                {
                    frmEditMarketCapNotification edit = new frmEditMarketCapNotification(
                    SettingsManager.AppSettings.MarketCapNotificationList.Single(x => x.CoinName.ToUpper() == lvMarketCapNotifications.SelectedItems[0].Text.ToUpper()));
                    edit.ShowDialog();
                }
                else
                    MessageBox.Show("Please select an item", "No Item Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (sender == btnDeleteMarketCapNotification)
            {
                if (lvMarketCapNotifications.SelectedItems.Count > 0)
                {
                    MarketCapitalizationCall call = new MarketCapitalizationCall();
                    call.DeleteMarketCapNotification(lvMarketCapNotifications.SelectedItems[0].Text, ref strError);
                    if (!string.IsNullOrEmpty(strError))
                        MessageBox.Show("An error occurred while trying to delete that notification: " + strError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        lvMarketCapNotifications.Items.Remove(lvMarketCapNotifications.SelectedItems[0]);
                        SettingsManager.AppSettings.MarketCapNotificationList = call.GetMarketCapNotificationList(ref strError);
                        if (!string.IsNullOrEmpty(strError))
                            MessageBox.Show("An error occurred while trying to get the market cap notifcation list: " + strError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                    MessageBox.Show("Please select an item", "No Item Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void Buttons_Click(object sender, EventArgs e)
        {
            if (sender == btnUpdate)
            {
                if (txtAddress.Text == string.Empty)
                {
                    MessageBox.Show("Please enter an address", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (chkNotify.Checked)
                {
                    if (cbxCondition.SelectedIndex == -1)
                    {
                        MessageBox.Show("if you want a notification, you must specify a condition.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (txtPrice.Text == string.Empty)
                    {
                        MessageBox.Show("if you want a notification, you must enter a price.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                foreach (PublicAddress editAddress in SettingsManager.PublicAddresses)
                {
                    if (editAddress.Address == publicAddress.Address)
                    {
                        editAddress.Address = txtAddress.Text;
                        editAddress.AddressDescription = txtDescription.Text;
                        editAddress.Notify = chkNotify.Checked;
                        editAddress.Price = Convert.ToInt32(txtPrice.Text);
                        editAddress.Condition = cbxCondition.SelectedIndex == -1 ? "" : cbxCondition.SelectedItem.ToString();

                        string strError = string.Empty;

                        AddressCall cAddress = new AddressCall();
                        cAddress.UpdatePublicAddress(editAddress, ref strError);
                        if (!string.IsNullOrEmpty(strError))
                        {
                            MessageBox.Show("An error occurred while trying to update that address." + Environment.NewLine + Environment.NewLine + strError, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            frmSettings settings = null;
                            foreach (Form form in Application.OpenForms)
                                if (form.Name == "frmSettings")
                                    settings = (frmSettings)form;
                            settings.RefreshAddresses();

                            this.Close();
                        }
                    }
                }
            }
            else if (sender == btnCancel)
            {
                this.Close();
            }
        }