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 }
private void UpdateMarketCapControl(Result rslt) { string strError = string.Empty; bool alreadyThere = false; foreach (MarketCapControl ctrl in flpMarketCap.Controls) { if (ctrl.MarketCapResult.Name[0].ToUpper() == rslt.Name[0].ToString().ToUpper()) { alreadyThere = true; ctrl.MarketCapResult = rslt; ctrl.RefreshUI(); } } if (!alreadyThere) { MarketCapControl mcc = new MarketCapControl(); mcc.MarketCapResult = rslt; mcc.RefreshUI(); flpMarketCap.Controls.Add(mcc); } foreach (var notifcation in SettingsManager.AppSettings.MarketCapNotificationList) { if (notifcation.Enabled && (notifcation.CoinName.ToUpper() == rslt.Name[0].ToUpper())) { NotificationCall call = new NotificationCall(); string notificationMessage = string.Empty; if (notifcation.Condition == ">") if (Convert.ToDecimal(rslt.Price.Replace("$ ", "")) > Convert.ToDecimal(notifcation.Price)) notificationMessage = "MarketCap Notification: " + notifcation.CoinName + " is above your notification price. Current Price: " + rslt.Price + ", Notification Price: " + notifcation.Price; if (notifcation.Condition == "<") if (Convert.ToDecimal(rslt.Price.Replace("$ ", "")) < Convert.ToDecimal(notifcation.Price)) notificationMessage = "MarketCap Notification: " + notifcation.CoinName + " is below your notification price. Current Price: " + rslt.Price + ", Notification Price: " + notifcation.Price; if (notifcation.Condition == "=") if (Convert.ToDecimal(rslt.Price.Replace("$ ", "")) == Convert.ToDecimal(notifcation.Price)) notificationMessage = "MarketCap Notification: " + notifcation.CoinName + " is the same as your notification price. Current Price: " + rslt.Price + ", Notification Price: " + notifcation.Price; if (notificationMessage != string.Empty) { lblMarketCapStatus.SetThreadSafeProperty(() => lblMarketCapStatus.Text, "Notification enabled and condition met... Sending notification for " + notifcation.CoinName); call.SendNotification(SettingsManager.AppSettings.NotificationData, notificationMessage, ref strError); if (!string.IsNullOrEmpty(strError)) this.InvokeThreadSafeMethod(() => Notify.ShowMessage(this, Notify.MessageType.Error, "Error occurred while trying to send the notification: " + strError)); } } } }