コード例 #1
0
        public AccountModel()
        {
            _pricesUpdater          = new PricesUpdater();
            _updater                = new AccountUpdater(this, _pricesUpdater);
            _idler                  = new IdleManager(this);
            _showcaseManager        = new ShowcaseManager();
            _updater.BadgeListSync += SyncShowcases;

            AllBadges       = new ObservableCollection <BadgeModel>();
            IdleQueueBadges = new ObservableCollection <BadgeModel>();
            Games           = new ObservableCollection <BadgeModel> {
                new BadgeModel("-1", "new", "0", "0")
            };
            AllShowcases = new ObservableCollection <BadgeShowcase>();

            #region Commands
            LoginCmd  = new BaseCommand(_ => Login());
            LogoutCmd = new BaseCommand(_ => Logout());

            StartBadgeIdleCmd = new BaseCommand(StartBadgeIdle, CanStartBadgeIdle);
            StopBadgeIdleCmd  = new BaseCommand(StopBadgeIdle, CanStopBadgeIdle);
            BlacklistBadgeCmd = new BaseCommand(BlacklistBadge);
            ForceSyncCmd      = new BaseCommand(ForceSync);

            EnqueueAllCmd        = new BaseCommand(EnqueueAll);
            DequeueAllCmd        = new BaseCommand(_ => DequeueAll());
            SetHigherPriorityCmd = new BaseCommand(SetHigherPriority, CanSetHigherPriority);
            SetLowerPriorityCmd  = new BaseCommand(SetLowerPriority, CanSetLowerPriority);

            EnqueueBadgeHighCmd = new BaseCommand(EnqueueBadgeHigh, CanEnqueueBadge);
            EnqueueBadgeLowCmd  = new BaseCommand(EnqueueBadgeLow, CanEnqueueBadge);
            DequeueBadgeCmd     = new BaseCommand(DequeueBadge, b => !CanEnqueueBadge(b));

            IdleCmd = new BaseCommand(Idle, CanIdle);

            AddGameCmd    = new BaseCommand(o => AddGame());
            RemoveGameCmd = new BaseCommand(RemoveGame);

            BookmarkShowcaseCmd = new BaseCommand(BookmarkShowcase);
            #endregion

            _badges = CollectionViewSource.GetDefaultView(AllBadges);
            var quick = (ICollectionViewLiveShaping)_badges;
            quick.LiveFilteringProperties.Add("IsBlacklisted");
            quick.LiveFilteringProperties.Add("HasTrial");
            quick.LiveFilteringProperties.Add("CardIdleActive");
            quick.LiveFilteringProperties.Add("IsInQueue");
            quick.IsLiveFiltering = true;

            BadgePropertiesFilters = FilterStatesCollection.Create <BadgeProperty>().SetNotifier(SetFilter);

            _showcases = CollectionViewSource.GetDefaultView(AllShowcases);
            quick      = (ICollectionViewLiveShaping)_showcases;
            quick.LiveFilteringProperties.Add("IsCompleted");
            quick.LiveFilteringProperties.Add("IsBookmarked");
            quick.IsLiveFiltering = true;

            ShowcasePropertiesFilters = FilterStatesCollection.Create <ShowcaseProperty>().SetNotifier(SetShowcaseFilter);
        }
コード例 #2
0
ファイル: AccountModel.cs プロジェクト: anx13ty98/idle_master
        public AccountModel()
        {
            _pricesUpdater          = new PricesUpdater();
            _updater                = new AccountUpdater(this, _pricesUpdater);
            _idler                  = new IdleManager();
            _showcaseManager        = new ShowcaseManager(_pricesUpdater);
            _updater.BadgeListSync += SyncShowcases;

            AllBadges = new ObservableCollection <BadgeModel>();
            Games     = new ObservableCollection <BadgeModel>();

            #region Commands
            LoginCmd  = new BaseCommand(_ => Login());
            LogoutCmd = new BaseCommand(_ => Logout());

            StartBadgeIdleCmd = new BaseCommand(StartBadgeIdle, CanStartBadgeIdle);
            StopBadgeIdleCmd  = new BaseCommand(StopBadgeIdle, CanStopBadgeIdle);
            BlacklistBadgeCmd = new BaseCommand(BlacklistBadge);
            ForceSyncCmd      = new BaseCommand(ForceSync);

            EnqueueAllCmd        = new BaseCommand(EnqueueAll);
            DequeueAllCmd        = new BaseCommand(_ => DequeueAll());
            SetHigherPriorityCmd = new BaseCommand(SetHigherPriority, CanSetHigherPriority);
            SetLowerPriorityCmd  = new BaseCommand(SetLowerPriority, CanSetLowerPriority);

            EnqueueBadgeHighCmd = new BaseCommand(EnqueueBadgeHigh, CanEnqueueBadge);
            EnqueueBadgeLowCmd  = new BaseCommand(EnqueueBadgeLow, CanEnqueueBadge);
            DequeueBadgeCmd     = new BaseCommand(DequeueBadge, b => !CanEnqueueBadge(b));

            IdleCmd = new BaseCommand(Idle, CanIdle);

            AddGameCmd    = new BaseCommand(AddGame);
            RemoveGameCmd = new BaseCommand(RemoveGame);

            BookmarkShowcaseCmd = new BaseCommand(BookmarkShowcase);

            ShowSettingsFileCmd = new BaseCommand(ShowSettingsFile);
            #endregion

            BadgePropertiesFilters = FilterStatesCollection.Create <BadgeProperty>().SetNotifier(SetFilter);

            ShowcasePropertiesFilters = FilterStatesCollection.Create <ShowcaseProperty>().SetNotifier(SetShowcaseFilter);
        }
コード例 #3
0
        public AccountModel()
        {
            _updater = new AccountUpdater(this);
            _idler = new IdleManager(this);
            
            AllBadges = new ObservableCollection<BadgeModel>();
            IdleQueueBadges = new ObservableCollection<BadgeModel>();            
            Games = new ObservableCollection<BadgeModel> {new BadgeModel("-1", "new", "0", "0")};

            #region Commands
            LoginCmd = new BaseCommand(_ => Login());
            LogoutCmd = new BaseCommand(_ => Logout());

            StartBadgeIdleCmd = new BaseCommand(StartBadgeIdle, CanStartBadgeIdle);
            StopBadgeIdleCmd = new BaseCommand(StopBadgeIdle, CanStopBadgeIdle);
            BlacklistBadgeCmd = new BaseCommand(BlacklistBadge);

            EnqueueAllCmd = new BaseCommand(EnqueueAll);
            DequeueAllCmd = new BaseCommand(_ => DequeueAll());
            SetHigherPriorityCmd = new BaseCommand(SetHigherPriority, CanSetHigherPriority);
            SetLowerPriorityCmd = new BaseCommand(SetLowerPriority, CanSetLowerPriority);

            EnqueueBadgeHighCmd = new BaseCommand(EnqueueBadgeHigh, CanEnqueueBadge);
            EnqueueBadgeLowCmd = new BaseCommand(EnqueueBadgeLow, CanEnqueueBadge);
            DequeueBadgeCmd = new BaseCommand(DequeueBadge, b => !CanEnqueueBadge(b));

            IdleCmd = new BaseCommand(Idle, CanIdle);

            AddGameCmd = new BaseCommand(o => AddGame());
            RemoveGameCmd = new BaseCommand(RemoveGame);

            SettingsCmd = new BaseCommand(o=>SettingsDialog());
            #endregion
            
            _badges = CollectionViewSource.GetDefaultView(AllBadges);
            var quick = (ICollectionViewLiveShaping)_badges;
            quick.LiveFilteringProperties.Add("IsBlacklisted");
            quick.LiveFilteringProperties.Add("HasTrial");
            quick.LiveFilteringProperties.Add("CardIdleActive");
            quick.LiveFilteringProperties.Add("IsInQueue");
            quick.IsLiveFiltering = true;


            _badgePropertiesFilters = Enum.GetValues(typeof (BadgeProperty))
                .OfType<BadgeProperty>()
                .Select(p => new SelectionItemVm<FilterState>
                             {
                                 Key = p,
                                 Value = FilterState.Any
                             })
                .ToList();

            foreach (var item in _badgePropertiesFilters)
            {
                item.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName != "Value")
                        return;

                    SetFilter();
                };
            }
        }