From d81677ed041301517096d4b343cfb0ddbcf4d043 Mon Sep 17 00:00:00 2001 From: Anton H Date: Mon, 16 Dec 2019 17:39:03 -0500 Subject: [PATCH] :rocket: Version 1.2 Fixed issue where .NET Core 3 application port made getting results slower. Changed the names of certain elements to make the use of them clearer. Cleaned up code. Minor UI Changes --- MarketStalker/MainWindow.xaml | 18 ++++++-------- MarketStalker/MainWindow.xaml.cs | 38 ++++++++++++----------------- MarketStalker/RecentListingsTask.cs | 16 +++++------- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/MarketStalker/MainWindow.xaml b/MarketStalker/MainWindow.xaml index df487a1..f7cde4d 100644 --- a/MarketStalker/MainWindow.xaml +++ b/MarketStalker/MainWindow.xaml @@ -16,8 +16,6 @@ WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Loaded="MetroWindow_Loaded" - d:DesignHeight="500" - d:DesignWidth="1300" KeyDown="Application_KeyDown"> @@ -101,9 +99,9 @@ @@ -124,7 +122,7 @@ @@ -146,7 +144,7 @@ - + @@ -155,7 +153,7 @@ - + @@ -182,9 +180,9 @@ - - - \ No newline at end of file diff --git a/MarketStalker/MainWindow.xaml.cs b/MarketStalker/MainWindow.xaml.cs index a85a2c9..c3fdd65 100644 --- a/MarketStalker/MainWindow.xaml.cs +++ b/MarketStalker/MainWindow.xaml.cs @@ -31,18 +31,10 @@ public partial class MainWindow : MetroWindow public MainWindow() { InitializeComponent(); - main = this; _warframeApiPoller.SellOrdersAvailable += ProcessSellOrders; } - internal static MainWindow main; - - internal string ConsoleLogNew - { - set { Dispatcher.Invoke(new Action(() => { ConsoleOutput.Text += "\n" + value; })); } - } - private void PullData(string method) { string data; @@ -59,11 +51,11 @@ private void PullData(string method) items = rootobject.Payload.Items.Select(a => new ItemEntireList { Item = a.ItemName, IsChecked = false, Id = a.Id }).ToList(); - ItemsIDCheckList.Items.SortDescriptions.Add( + ItemsIdCheckList.Items.SortDescriptions.Add( new SortDescription( "Item", ListSortDirection.Ascending)); - ItemsIDCheckList.ItemsSource = items; + ItemsIdCheckList.ItemsSource = items; TotalItemsText.Text = rootobject.Payload.Items.Count().ToString(); ConsoleOutput.Text += "\nUpdated Item List Using " + method; @@ -72,7 +64,7 @@ private void PullData(string method) public void UserFilter() { - ICollectionView view = CollectionViewSource.GetDefaultView(ItemsIDCheckList.ItemsSource); + ICollectionView view = CollectionViewSource.GetDefaultView(ItemsIdCheckList.ItemsSource); if (view != null) { switch (TextFilter.Text.ToLower()) @@ -107,25 +99,25 @@ private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) PullData("API"); - loadingImage.Visibility = Visibility.Visible; + LoadingLogo.Visibility = Visibility.Visible; for (double i = 1.00; i > 0; i = i - .01) { - loadingImage.Opacity = i; - loadingText.Opacity = i; + LoadingLogo.Opacity = i; + LoadingText.Opacity = i; await Task.Delay(2); } for (double i = 1.00; i > 0; i = i - .01) { - loadinGrid.Opacity = i; + LoadingGrid.Opacity = i; await Task.Delay(1); } - loadinGrid.Visibility = Visibility.Hidden; + LoadingGrid.Visibility = Visibility.Hidden; } async void IntialStart_Click(object sender, RoutedEventArgs e) { - var myItems = ItemsIDCheckList.ItemsSource as IEnumerable; + var myItems = ItemsIdCheckList.ItemsSource as IEnumerable; if (!_isPulling) { @@ -162,7 +154,7 @@ await _warframeApiPoller.GetSellOrdersAsnyc(currentListings.Payload.SellOrders, async void RunningTask_Click(object sender, RoutedEventArgs e) { - var myItems = ItemsIDCheckList.ItemsSource as IEnumerable; + var myItems = ItemsIdCheckList.ItemsSource as IEnumerable; if (!_isPolling) { @@ -200,8 +192,8 @@ void ProcessSellOrders(object minPrices, MostRecentListing.SellOrder sellOrder) var newlistingprice = sellOrder.Platinum; var priceDifference = newlistingprice - thirdlistingprice; - ConsoleLogNew = - "Item: " + sellOrder.Item.En.ItemName + " Price: " + newlistingprice + + ConsoleOutput.Text += + "\nItem: " + sellOrder.Item.En.ItemName + " Price: " + newlistingprice + " Difference: " + priceDifference; if (RandomHelpers.IsNegative(priceDifference)) @@ -212,10 +204,10 @@ void ProcessSellOrders(object minPrices, MostRecentListing.SellOrder sellOrder) bool matches = Convert.ToDouble(priceDifference.ToString().Replace("-", "")) >= - minPrice.Value && - Convert.ToDouble(priceDifference.ToString().Replace("-", "")) <= maxPrice.Value; + MinimumDiscount.Value && + Convert.ToDouble(priceDifference.ToString().Replace("-", "")) <= MaximumDiscount.Value; - if (showNonMatching.IsChecked == true) + if (ShowNonMatching.IsChecked == true) { var data = new Items.DataGrid { diff --git a/MarketStalker/RecentListingsTask.cs b/MarketStalker/RecentListingsTask.cs index c2f2694..7688344 100644 --- a/MarketStalker/RecentListingsTask.cs +++ b/MarketStalker/RecentListingsTask.cs @@ -29,20 +29,20 @@ public async Task StartPolling(CancellationToken cancellationToken, IEnumerable< MostRecentListing.RootObject currentListings = await GetRecentListingsAsync(); MostRecentListing.RootObject outdatedListings = null; - var joe = currentListings.Payload.SellOrders.Take(25).ToList(); + var ListingsToCheck = currentListings.Payload.SellOrders.Take(25).ToList(); await Task.Delay(1000); while (!cancellationToken.IsCancellationRequested) { - await GetSellOrdersAsnyc(joe, selectedItems, cancellationToken); + await GetSellOrdersAsnyc(ListingsToCheck, selectedItems, cancellationToken); await Task.Delay(_pollDelay); outdatedListings = currentListings; currentListings = await GetRecentListingsAsync(); - joe = currentListings.Payload.SellOrders + ListingsToCheck = currentListings.Payload.SellOrders .Take(300) .Where(d => outdatedListings.Payload.SellOrders .Take(300) @@ -54,9 +54,8 @@ public async Task StartPolling(CancellationToken cancellationToken, IEnumerable< public async Task GetSellOrdersAsnyc( List currentListings, IEnumerable selectedItems, CancellationToken cancellationToken) { - foreach (MostRecentListing.SellOrder sellOrder in currentListings.Where(a => - selectedItems.Contains(a.Item.Id))) - { + foreach (MostRecentListing.SellOrder sellOrder in currentListings.Where(a => selectedItems.Contains(a.Item.Id))) + { try { await Task.Delay(350, cancellationToken).ConfigureAwait(false); @@ -103,10 +102,7 @@ public async Task GetSellOrdersAsnyc( } SellOrdersAvailable?.Invoke(minPrice, sellOrder); - - //await UpdateUI(minPrice, sellOrder); - - } + } } public async Task GetRecentListingsAsync()