コード例 #1
0
        /// <summary>
        /// Find all dig games with cards
        /// </summary>
        /// <param name="textItemValue"> string to parse </param>
        private void FindCardGames(string textItemValue)
        {
            var updatedResult = string.Join(" ", textItemValue.Replace("Buy key", string.Empty).Split().Where(x => x != ""));

            updatedResult = updatedResult.Remove(0, updatedResult.IndexOf(' ') + 1);
            _page.Dispatcher.Invoke(() => DigGamesWithCrads.Add(updatedResult));

            var price = updatedResult.Remove(0, updatedResult.IndexOf("$") + 1).Replace(".", ",");

            PricesOnlyCards.Add(Convert.ToDouble(price));
        }
コード例 #2
0
        /// <summary>
        /// Get information abount all available games with cards
        /// </summary>
        public void GetAvailableGamesCardsInfo()
        {
            var isContinueGames = _parseService.GetUserGamesInfo();

            _page.Dispatcher.Invoke(() =>
            {
                if (UserName is null)
                {
                    MessageBox.Show("No entered user", "No user error");
                    return;
                }

                if (ViewModelHelper.DigGames.Count != 0)
                {
                    var tempList = ViewModelHelper.DigGamesWithCards
                                   .Where(item => !UserGames.Contains(item))
                                   .ToList();

                    TempList = tempList;

                    var twmpList = new int[ViewModelHelper.DigGamesWithCards.Count];

                    for (int i = 0; i < ViewModelHelper.DigGamesWithCards.Count; i++)
                    {
                        if (!UserGames.Any(x => x == ViewModelHelper.DigGamesWithCards[i]))
                        {
                            twmpList[i] = i;
                        }
                        else
                        {
                            twmpList[i] = 0;
                        }
                    }

                    PricesOnlyCards.Clear();
                    PricesOnlyCards.Add(0.1);
                    for (int i = 0; i < twmpList.Length; i++)
                    {
                        if (twmpList[i] != 0)
                        {
                            PricesOnlyCards.Add(ViewModelHelper.PricesWithCards[i]);
                        }
                    }

                    GamesWithCardsSumm = Math.Round(PricesOnlyCards.Sum(), 3);

                    AmountGamesWithCards = TempList.Distinct().Count();

                    /// write user cards info into helper class

                    ViewModelHelper.AllGamesCardsUserHelper      = AmountGamesWithCards;
                    ViewModelHelper.AllGamesPriceCardsUserHelper = GamesWithCardsSumm;

                    for (var i = 0; i < TempList.Count; i++)
                    {
                        if (!UserCardGamesDict.ContainsKey(TempList[i]))
                        {
                            UserCardGamesDict.Add(TempList[i], PricesOnlyCards[i]);
                        }
                    }

                    TempList.Clear();
                    ListViewSourse.Clear();

                    foreach (var item in UserCardGamesDict)
                    {
                        ListViewSourse.Add($"Game: {item.Key} | Price: ${item.Value}");
                    }

                    CanCloseSaveCards = true;
                }

                else
                {
                    MessageBox.Show("No games from DIG", "No dig games error");
                    return;
                }
            });
        }