Example #1
0
        public void OpenPacks(IEnumerable <Guid> packs)
        {
            StopListenningForFilterValueChanges();

            foreach (Pack pack in packs.Select(Database.GetPackById))
            {
                if (pack == null)
                {
                    Program.TraceWarning("Received pack is missing from the database. Pack is ignored.");
                    continue;
                }
                Pack.PackContent content = pack.CrackOpen();
                foreach (CardModel c in content.LimitedCards)
                {
                    CardPool.Add(c);
                }
                foreach (CardModel c in content.UnlimitedCards)
                {
                    UnlimitedPool.Add(c);
                }
            }

            UpdateFilters();

            ListenForFilterValueChanges();
        }
Example #2
0
        public void OpenPacks(IEnumerable <Guid> packs)
        {
            new Task(
                () =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    TabControlMain.IsEnabled           = false;
                    ProgressBarLoading.Visibility      = Visibility.Visible;
                    ProgressBarLoading.IsIndeterminate = true;
                    ProgressBarLoading.Maximum         = packs.Count();
                }));
                this.StopListenningForFilterValueChanges();

                foreach (Pack pack in packs.Select(Database.GetPackById))
                {
                    if (pack == null)
                    {
                        Program.TraceWarning("Received pack is missing from the database. Pack is ignored.");
                        continue;
                    }

                    Pack.PackContent content = pack.CrackOpen();
                    foreach (CardModel c in content.LimitedCards)
                    {
                        Dispatcher.Invoke(new Action(() => { this.CardPool.Add(c); }));
                    }

                    foreach (CardModel c in content.UnlimitedCards)
                    {
                        Dispatcher.Invoke(new Action(() => { this.UnlimitedPool.Add(c); }));
                    }

                    Dispatcher.Invoke(new Action(() =>
                    {
                        ProgressBarLoading.IsIndeterminate = false;
                        ProgressBarLoading.Value          += 1;
                    }));
                }

                Dispatcher.Invoke(
                    new Action(() =>
                {
                    this.UpdateFilters();

                    this.ListenForFilterValueChanges();
                    ProgressBarLoading.Visibility = Visibility.Hidden;
                    TabControlMain.IsEnabled      = true;
                }));
            }).Start();
        }