예제 #1
0
        private void InitMarketAnalysis()
        {
            Task.Run(async() =>
            {
                Dispatcher.Invoke(() =>
                {
                    InitLanguage();
                    TxtSearch.IsEnabled   = false;
                    FaLoadIcon.Visibility = Visibility.Visible;
                    InitUi();
                });

                #region Load ItemList source url

                if (_iniFile.SectionKeyExists("Settings", "ItemListSourceUrl"))
                {
                    StatisticsAnalysisManager.ItemListSourceUrl = _iniFile.ReadValue("Settings", "ItemListSourceUrl");
                }

                #endregion

                var isItemListLoaded = await StatisticsAnalysisManager.GetItemsFromJsonAsync();
                if (!isItemListLoaded)
                {
                    MessageBox.Show(LanguageController.Translation("ITEM_LIST_CAN_NOT_BE_LOADED"),
                                    LanguageController.Translation("ERROR"));
                }

                #region Refrash rate

                if (_iniFile.SectionKeyExists("Settings", "RefreshRate") &&
                    int.TryParse(_iniFile.ReadValue("Settings", "RefreshRate"), out var refrashrate))
                {
                    StatisticsAnalysisManager.RefreshRate = refrashrate;
                }

                #endregion

                #region Update item list by days

                if (_iniFile.SectionKeyExists("Settings", "UpdateItemListByDays") &&
                    int.TryParse(_iniFile.ReadValue("Settings", "UpdateItemListByDays"), out var updateItemListByDays))
                {
                    StatisticsAnalysisManager.UpdateItemListByDays = updateItemListByDays;
                }

                #endregion

                Dispatcher.Invoke(() =>
                {
                    if (isItemListLoaded)
                    {
                        FaLoadIcon.Visibility = Visibility.Hidden;
                        TxtSearch.IsEnabled   = true;
                    }
                });
            });
        }
        private void InitMarketAnalysis()
        {
            Task.Run(async() =>
            {
                Dispatcher?.Invoke(() =>
                {
                    TxtSearch.IsEnabled   = false;
                    FaLoadIcon.Visibility = Visibility.Visible;
                    InitUi();
                });

                #region Set MainWindow height and width and center window

                Dispatcher?.Invoke(() =>
                {
                    Height = Settings.Default.MainWindowHeight;
                    Width  = Settings.Default.MainWindowWidth;
                    if (Settings.Default.MainWindowMaximized)
                    {
                        WindowState = WindowState.Maximized;
                    }

                    CenterWindowOnScreen();
                });

                #endregion

                Dispatcher?.Invoke(() =>
                {
                    TxtBoxPlayerModeUsername.Text = Settings.Default.SavedPlayerInformationName;
                });

                var isItemListLoaded = await StatisticsAnalysisManager.GetItemListFromJsonAsync();
                if (!isItemListLoaded)
                {
                    MessageBox.Show(LanguageController.Translation("ITEM_LIST_CAN_NOT_BE_LOADED"),
                                    LanguageController.Translation("ERROR"));
                }

                Dispatcher?.Invoke(() =>
                {
                    if (isItemListLoaded)
                    {
                        FaLoadIcon.Visibility = Visibility.Hidden;
                        TxtSearch.IsEnabled   = true;
                        TxtSearch.Focus();
                    }
                });
            });
        }
        public void LoadLvItems(string searchText)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                return;
            }

            Dispatcher.InvokeAsync(async() =>
            {
                var items              = await StatisticsAnalysisManager.FindItemsAsync(searchText);
                LvItems.ItemsSource    = items;
                LblItemCounter.Content = $"{items.Count}/{StatisticsAnalysisManager.Items.Count}";
            });
        }
예제 #4
0
        private async void InitializeItemData(Item item)
        {
            if (item == null)
            {
                return;
            }

            _uniqueName = item.UniqueName;

            await Dispatcher.InvokeAsync(() =>
            {
                FaLoadIcon.Visibility = Visibility.Visible;

                Icon = item.Icon;
            });

            StartAutoUpdater();

            var itemDataTaskResult = await StatisticsAnalysisManager.GetItemDataFromJsonAsync(item);

            if (itemDataTaskResult == null)
            {
                LblItemName.Content = LanguageController.Translation("ERROR_PRICES_CAN_NOT_BE_LOADED");
                Dispatcher.Invoke(() =>
                {
                    FaLoadIcon.Visibility = Visibility.Hidden;
                });
                return;
            }

            _itemData = itemDataTaskResult;

            await Dispatcher.InvokeAsync(() =>
            {
                Title = $"{_itemData.LocalizedName} (T{_itemData.Tier})";
                LblItemName.Content = $"{_itemData.LocalizedName} (T{_itemData.Tier})";
                LblItemId.Content   = _itemData.UniqueName;
                ImgItemImage.Source = item.Icon;

                FaLoadIcon.Visibility = Visibility.Hidden;
            });
        }
        private void InitMarketAnalysis()
        {
            Task.Run(async() =>
            {
                Dispatcher.Invoke(() =>
                {
                    InitLanguage();
                    TxtSearch.IsEnabled   = false;
                    FaLoadIcon.Visibility = Visibility.Visible;
                    InitUi();
                });

                await StatisticsAnalysisManager.GetItemsFromJsonAsync();

                #region Refrash rate

                if (_iniFile.SectionKeyExists("Settings", "RefreshRate") &&
                    int.TryParse(_iniFile.ReadValue("Settings", "RefreshRate"), out var refrashrate))
                {
                    StatisticsAnalysisManager.RefreshRate = refrashrate;
                }

                #endregion

                #region Update item list by days

                if (_iniFile.SectionKeyExists("Settings", "UpdateItemListByDays") &&
                    int.TryParse(_iniFile.ReadValue("Settings", "UpdateItemListByDays"), out var updateItemListByDays))
                {
                    StatisticsAnalysisManager.UpdateItemListByDays = updateItemListByDays;
                }

                #endregion

                Dispatcher.Invoke(() =>
                {
                    FaLoadIcon.Visibility = Visibility.Hidden;
                    TxtSearch.IsEnabled   = true;
                });
            });
        }
예제 #6
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);
                });
            });
        }