/// <summary>
        /// Initializes a new instance of the <see cref="InfoWindow"/> class.
        /// </summary>
        /// <param name="apiInfo">The apiInfo<see cref="ApiInfo"/></param>
        /// <param name="asset">The asset<see cref="Asset"/></param>
        public InfoWindow(ApiInfo apiInfo, Asset asset)
        {
            // TODO: ADD FEATURE: longer-term percent changes
            this.InitializeComponent();
            this.Title = asset.Name;
            this.textblock_Symbol.Text = asset.Symbol;
            this.textblock_Rank.Text   = asset.Rank.ToString();

            this.label_Price.Text     = asset.ConvertCurrency + " Price:";
            this.textblock_Price.Text = TileHelpers.GetValueString(asset.Price, false);

            this.label_MarketCap.Text           = asset.ConvertCurrency + " Market Cap:";
            this.textblock_MarketCap.Text       = asset.MarketCap >= 0 ? TileHelpers.GetValueString(asset.MarketCap, false) : "-";
            this.textblock_AvailableSupply.Text = asset.SupplyAvailable >= 0 ?  TileHelpers.GetValueString(asset.SupplyAvailable, false) : "-";
            this.textblock_TotalSupply.Text     = asset.SupplyTotal >= 0 ? TileHelpers.GetValueString(asset.SupplyTotal, false) : "-";

            this.textblock_PercentChange24h.Text = asset.PercentChange24h > -101 ? TileHelpers.GetValueString(asset.PercentChange24h, true) + "%" : "-";

            if (apiInfo.AssetUrl != string.Empty)
            {
                this.hyperlink_Asset.NavigateUri = new Uri(apiInfo.AssetUrl
                                                           .Replace("#NAME#", asset.Name)
                                                           .Replace("#SYMBOL#", asset.Symbol)
                                                           .Replace("#ID#", asset.AssetId));

                this.hyperlink_Asset.Inlines.Add(apiInfo.AssetUrlName);
            }
        }
 /// <summary>
 /// The RefreshAssetTextblocks
 /// </summary>
 private void RefreshAssetTextblocks()
 {
     this.label_AssetPrice.Text       = this.AssetTileData.Asset.ConvertCurrency + "/" + this.AssetTileData.Asset.Symbol;
     this.textBlock_AssetPrice.Text   = TileHelpers.GetValueString(this.AssetTileData.Asset.Price, false);
     this.label_Worth.Text            = this.AssetTileData.Asset.ConvertCurrency;
     this.textBlock_AssetSymbol.Text  = this.AssetTileData.Asset.Symbol;
     this.textBlock_last_Refresh.Text = "@" + this.AssetTileData.Asset.LastUpdated.ToString("HH:mm");
 }
        /// <summary>
        /// The RefreshTileDataTextblocks
        /// </summary>
        private void RefreshTileDataTextblocks()
        {
            this.label_WalletName.Text      = this.AssetTileData.AssetTileName;
            this.textBlock_Worth.Text       = TileHelpers.GetValueString(this.currentWorth, false);
            this.textBlock_AssetAmount.Text = TileHelpers.GetValueString(this.AssetTileData.HoldingsCount, false);
            string textBoxWinText = TileHelpers.GetValueString(this.profitLoss, true) + " " + this.AssetTileData.Asset.ConvertCurrency;

            this.textBlock_Win.Text = textBoxWinText;
        }
Exemple #4
0
        /// <summary>
        /// The UpdateTextBlocks
        /// </summary>
        /// <param name="updateTime">The updateTime<see cref="DateTime?"/></param>
        private void UpdateTextBlocks(DateTime?updateTime)
        {
            List <AssetTileData> assignedAssetTileDatas = this.appData.AssetTileDataSet
                                                          .Where(ass => this.PortfolioTileData.AssignedAssetTileIds.Contains(ass.AssetTileId))
                                                          .ToList();

            double investTotal = TileHelpers.CalculateInvest(assignedAssetTileDatas);
            double worthTotal  = TileHelpers.CalculateWorth(assignedAssetTileDatas);

            this.winTotal = worthTotal - investTotal;

            bool   percentage24hValid = TileHelpers.Calculate24hPercentage(assignedAssetTileDatas, worthTotal, out this.percentage24h);
            double win24h             = TileHelpers.CalculateWinLoss(this.percentage24h, worthTotal);

            bool   percentage7dValid = TileHelpers.Calculate7dPercentage(assignedAssetTileDatas, worthTotal, out this.percentage7d);
            double win1W             = TileHelpers.CalculateWinLoss(this.percentage7d, worthTotal);

            string convertCurrency = string.Empty;

            if (assignedAssetTileDatas.Count > 0)
            {
                convertCurrency = " " + assignedAssetTileDatas[0].Asset.ConvertCurrency;
            }

            this.Dispatcher.Invoke(() =>
            {
                this.textBlock_PortfolioName.Text = this.PortfolioTileData.PortfolioTileName;

                if (updateTime != null)
                {
                    this.textBlock_last_Refresh.Text = "@" + ((DateTime)updateTime).ToString("HH:mm");
                }

                this.textBlock_Invest.Text = TileHelpers.GetValueString(investTotal, false) + convertCurrency;
                this.textBlock_Worth.Text  = TileHelpers.GetValueString(worthTotal, false) + convertCurrency;

                this.AdjustPercentageAreas(percentage24hValid, percentage7dValid);

                this.textBlock_24hPercentage.Text = percentage24hValid ? TileHelpers.GetValueString(Math.Round(this.percentage24h, 2), true) + " %" : "-";
                this.textBlock_24hWin.Text        = percentage24hValid ? TileHelpers.GetValueString(win24h, true) + convertCurrency : "-";

                this.textBlock_7dPercentage.Text = percentage7dValid ? TileHelpers.GetValueString(Math.Round(this.percentage7d, 2), true) + " %" : "-";
                this.textBlock_7dWin.Text        = percentage7dValid ? TileHelpers.GetValueString(win1W, true) + convertCurrency : "-";

                this.textBlock_ATWin.Text = TileHelpers.GetValueString(this.winTotal, true) + convertCurrency;
            });
        }