diff --git a/NewWorldCompanion.Entities/NwmarketpriceJson.cs b/NewWorldCompanion.Entities/NwmarketpriceJson.cs index 9c46eed..b5094ae 100644 --- a/NewWorldCompanion.Entities/NwmarketpriceJson.cs +++ b/NewWorldCompanion.Entities/NwmarketpriceJson.cs @@ -16,7 +16,7 @@ public class NwmarketpriceJson public string last_checked { get; set; } = string.Empty; //public string recent_lowest_price { get; set; } = string.Empty; public double recent_lowest_price { get; set; } = 0.0; - public List avg_graph_data { get; set; } = new List(); + public List avg_graph_data { get; set; } = new List(); [JsonIgnore] public string RecentLowestPriceAvg @@ -30,16 +30,8 @@ public string RecentLowestPriceAvg { if (avg_graph_data.Count() > 0) { - JsonElement priceData = (JsonElement)avg_graph_data.Last(); - switch (priceData.ValueKind) - { - case JsonValueKind.Number: - price = decimal.Parse(priceData.ToString(), style, CultureInfo.InvariantCulture).ToString("F2"); - break; - case JsonValueKind.Array: - price = decimal.Parse(priceData[1].ToString(), style, CultureInfo.InvariantCulture).ToString("F2"); - break; - } + AvgGraph priceData = avg_graph_data.Last(); + price = priceData.price.ToString("F2"); } } catch (Exception){} @@ -48,4 +40,10 @@ public string RecentLowestPriceAvg } } } + + public class AvgGraph + { + public DateTime datetime { get; set; } + public double price { get; set; } + } } diff --git a/NewWorldCompanion.Services/OverlayHandler.cs b/NewWorldCompanion.Services/OverlayHandler.cs index e22f644..5497056 100644 --- a/NewWorldCompanion.Services/OverlayHandler.cs +++ b/NewWorldCompanion.Services/OverlayHandler.cs @@ -144,7 +144,7 @@ private void DrawGraphicsItem(DrawGraphicsEventArgs e, string itemName) // $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; infoPrice = nwmarketpriceJson.recent_lowest_price.Equals(nwmarketpriceJson.last_checked) ? decimal.Parse(nwmarketpriceJson.recent_lowest_price.ToString(), style, CultureInfo.InvariantCulture).ToString("F2"): - $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; + $"{nwmarketpriceJson.recent_lowest_price.ToString("F2")} lowest ({nwmarketpriceJson.last_checked})"; infoPriceAvg = string.IsNullOrWhiteSpace(recentLowestPriceAvgList) ? infoPriceAvg : $"{recentLowestPriceAvgList} lowest avg ({nwmarketpriceJson.last_checked})"; @@ -186,7 +186,7 @@ private void DrawGraphicsRecipe(DrawGraphicsEventArgs e, CraftingRecipe crafting // $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; infoPrice = nwmarketpriceJson.recent_lowest_price.Equals(nwmarketpriceJson.last_checked) ? decimal.Parse(nwmarketpriceJson.recent_lowest_price.ToString(), style, CultureInfo.InvariantCulture).ToString("F2") : - $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; + $"{nwmarketpriceJson.recent_lowest_price.ToString("F2")} lowest ({nwmarketpriceJson.last_checked})"; infoPriceAvg = string.IsNullOrWhiteSpace(recentLowestPriceAvgList) ? infoPriceAvg : $"{recentLowestPriceAvgList} lowest avg ({nwmarketpriceJson.last_checked})"; diff --git a/NewWorldCompanion/ViewModels/Tabs/CraftingViewModel.cs b/NewWorldCompanion/ViewModels/Tabs/CraftingViewModel.cs index 646f15b..3902da1 100644 --- a/NewWorldCompanion/ViewModels/Tabs/CraftingViewModel.cs +++ b/NewWorldCompanion/ViewModels/Tabs/CraftingViewModel.cs @@ -274,7 +274,7 @@ public string SelectedCraftingRecipePrice // $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; _selectedCraftingRecipePrice = nwmarketpriceJson.recent_lowest_price.Equals(nwmarketpriceJson.last_checked) ? decimal.Parse(nwmarketpriceJson.recent_lowest_price.ToString(), style, CultureInfo.InvariantCulture).ToString("F2") : - $"{nwmarketpriceJson.recent_lowest_price} lowest ({nwmarketpriceJson.last_checked})"; + $"{nwmarketpriceJson.recent_lowest_price.ToString("F2")} lowest ({nwmarketpriceJson.last_checked})"; } } return _selectedCraftingRecipePrice; diff --git a/NewWorldCompanion/common.props b/NewWorldCompanion/common.props index 5f7b5db..fe40c9c 100644 --- a/NewWorldCompanion/common.props +++ b/NewWorldCompanion/common.props @@ -1,7 +1,7 @@ - 1.0.6.0 - 1.0.6.0 + 1.0.6.1 + 1.0.6.1 Copyright © 2022 net6.0-windows