コード例 #1
0
        private void CreateGridElement(MarketResponseTotal stats)
        {
            var textColor = new SolidColorBrush(Colors.Gainsboro);

            var bestPriceLabelStyle = FindResource("BestPriceLabel") as Style;

            var grid = new Grid
            {
                VerticalAlignment = VerticalAlignment.Top, Height = 30, Margin = new Thickness(0, 0, 0, 0)
            };

            var lblCity = new Label
            {
                Content             = stats.City,
                Foreground          = textColor,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width  = 150,
                Height = 28,
                Margin = new Thickness(10, 0, 0, 0)
            };

            switch (stats.City)
            {
            case Location.Caerleon:
                lblCity.Style = FindResource("CaerleonStyle") as Style;
                break;

            case Location.Thetford:
                lblCity.Style = FindResource("ThetfordStyle") as Style;
                break;

            case Location.Bridgewatch:
                lblCity.Style = FindResource("BridgewatchStyle") as Style;
                break;

            case Location.Martlock:
                lblCity.Style = FindResource("MartlockStyle") as Style;
                break;

            case Location.Lymhurst:
                lblCity.Style = FindResource("LymhurstStyle") as Style;
                break;

            case Location.FortSterling:
                lblCity.Style = FindResource("FortSterlingStyle") as Style;
                break;

            default:
                lblCity.Style = FindResource("DefaultCityStyle") as Style;
                break;
            }

            List <Image> silverImages = new List <Image>();

            var lblSellPriceMin = new Label
            {
                Content                    = string.Format(LanguageController.DefaultCultureInfo, "{0:n0}", stats.SellPriceMin),
                Foreground                 = DateTimeToOld(stats.SellPriceMinDate),
                HorizontalAlignment        = HorizontalAlignment.Left,
                VerticalAlignment          = VerticalAlignment.Top,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Width  = 85,
                Height = 28,
                Margin = new Thickness(194, 0, 0, 0)
            };

            lblSellPriceMin.Style = (stats.BestSellMinPrice && stats.SellPriceMin != 0) ? bestPriceLabelStyle : lblSellPriceMin.Style;
            silverImages.Add(new Image
            {
                Margin = new Thickness(168, 0, 0, 0),
                Style  = FindResource("Image.Price.Silver") as Style
            });

            var lblSellPriceMax = new Label
            {
                Content                    = string.Format(LanguageController.DefaultCultureInfo, "{0:n0}", stats.SellPriceMax),
                Foreground                 = DateTimeToOld(stats.SellPriceMaxDate),
                HorizontalAlignment        = HorizontalAlignment.Left,
                VerticalAlignment          = VerticalAlignment.Top,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Width  = 85,
                Height = 28,
                Margin = new Thickness(444, 0, 0, 0)
            };

            silverImages.Add(new Image
            {
                Margin = new Thickness(418, 0, 0, 0),
                Style  = FindResource("Image.Price.Silver") as Style
            });

            var lblBuyPriceMin = new Label
            {
                Content                    = string.Format(LanguageController.DefaultCultureInfo, "{0:n0}", stats.BuyPriceMin),
                Foreground                 = DateTimeToOld(stats.BuyPriceMinDate),
                HorizontalAlignment        = HorizontalAlignment.Left,
                VerticalAlignment          = VerticalAlignment.Top,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Width  = 85,
                Height = 28,
                Margin = new Thickness(694, 0, 0, 0)
            };

            silverImages.Add(new Image
            {
                Margin = new Thickness(668, 0, 0, 0),
                Style  = FindResource("Image.Price.Silver") as Style
            });

            var lblBuyPriceMax = new Label
            {
                Content                    = string.Format(LanguageController.DefaultCultureInfo, "{0:n0}", stats.BuyPriceMax),
                Foreground                 = DateTimeToOld(stats.BuyPriceMaxDate),
                HorizontalAlignment        = HorizontalAlignment.Left,
                VerticalAlignment          = VerticalAlignment.Top,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                Width  = 85,
                Height = 28,
                Margin = new Thickness(944, 0, 0, 0)
            };

            lblBuyPriceMax.Style = (stats.BestBuyMaxPrice && stats.BuyPriceMax != 0) ? bestPriceLabelStyle : lblBuyPriceMax.Style;
            silverImages.Add(new Image
            {
                Margin = new Thickness(918, 0, 0, 0),
                Style  = FindResource("Image.Price.Silver") as Style
            });

            var lblSellPriceMinDate = new Label
            {
                Content             = Utility.DateFormat(stats.SellPriceMinDate, 2),
                Foreground          = DateTimeToOld(stats.SellPriceMinDate),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width  = 120,
                Height = 28,
                Margin = new Thickness(293, 0, 0, 0)
            };

            var lblSellPriceMaxDate = new Label
            {
                Content             = Utility.DateFormat(stats.SellPriceMaxDate, 2),
                Foreground          = DateTimeToOld(stats.SellPriceMaxDate),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width  = 120,
                Height = 28,
                Margin = new Thickness(543, 0, 0, 0)
            };

            var lblBuyPriceMinDate = new Label
            {
                Content             = Utility.DateFormat(stats.BuyPriceMinDate, 2),
                Foreground          = DateTimeToOld(stats.BuyPriceMinDate),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width  = 120,
                Height = 28,
                Margin = new Thickness(793, 0, 0, 0)
            };

            var lblBuyPriceMaxDate = new Label
            {
                Content             = Utility.DateFormat(stats.BuyPriceMaxDate, 2),
                Foreground          = DateTimeToOld(stats.BuyPriceMaxDate),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Width  = 120,
                Height = 28,
                Margin = new Thickness(1043, 0, 0, 0)
            };

            SpStats.Children.Add(grid);
            grid.Children.Add(lblCity);
            grid.Children.Add(lblSellPriceMin);
            grid.Children.Add(lblSellPriceMax);
            grid.Children.Add(lblBuyPriceMin);
            grid.Children.Add(lblBuyPriceMax);
            grid.Children.Add(lblSellPriceMinDate);
            grid.Children.Add(lblSellPriceMaxDate);
            grid.Children.Add(lblBuyPriceMinDate);
            grid.Children.Add(lblBuyPriceMaxDate);
            foreach (var image in silverImages)
            {
                grid.Children.Add(image);
            }
        }
コード例 #2
0
        private async void GetPriceStats(string uniqueName, bool showVillages = false)
        {
            if (uniqueName == null)
            {
                return;
            }

            await Task.Run(async() =>
            {
                _statsPricesTotalList.Clear();
                var statPricesList = await StatisticsAnalysisManager.GetItemPricesFromJsonAsync(uniqueName, showVillages);

                if (statPricesList == null)
                {
                    return;
                }

                Dispatcher.Invoke(() =>
                {
                    foreach (var stats in statPricesList)
                    {
                        if (_statsPricesTotalList.Exists(s => Locations.GetName(s.City) == stats.City))
                        {
                            var spt = _statsPricesTotalList.Find(s => Locations.GetName(s.City) == stats.City);
                            if (stats.SellPriceMin < spt.SellPriceMin)
                            {
                                spt.SellPriceMin = stats.SellPriceMin;
                            }

                            if (stats.SellPriceMax > spt.SellPriceMax)
                            {
                                spt.SellPriceMax = stats.SellPriceMax;
                            }

                            if (stats.BuyPriceMin < spt.BuyPriceMin)
                            {
                                spt.BuyPriceMin = stats.BuyPriceMin;
                            }

                            if (stats.BuyPriceMax > spt.BuyPriceMax)
                            {
                                spt.BuyPriceMax = stats.BuyPriceMax;
                            }
                        }
                        else
                        {
                            var newSpt = new MarketResponseTotal()
                            {
                                City             = Locations.GetName(stats.City),
                                SellPriceMin     = stats.SellPriceMin,
                                SellPriceMax     = stats.SellPriceMax,
                                BuyPriceMin      = stats.BuyPriceMin,
                                BuyPriceMax      = stats.BuyPriceMax,
                                SellPriceMinDate = stats.SellPriceMinDate,
                                SellPriceMaxDate = stats.SellPriceMaxDate,
                                BuyPriceMinDate  = stats.BuyPriceMinDate,
                                BuyPriceMaxDate  = stats.BuyPriceMaxDate,
                            };

                            _statsPricesTotalList.Add(newSpt);
                        }
                    }

                    FindBestPrice(ref _statsPricesTotalList);

                    SpStats.Children.Clear();
                    foreach (var spt in _statsPricesTotalList)
                    {
                        CreateGridElement(spt);
                    }

                    SetDifferenceCalculationText(_statsPricesTotalList);

                    LblLastUpdate.Content = Utility.DateFormat(DateTime.Now, 0);
                });
            });
        }