Ejemplo n.º 1
0
        async Task <RecoveryOptionResult> NotLoggedInDialog(NotLoggedInUserError notLoggedInUserError)
        {
            string action = null; // toDO;
            await _specialDialogManager.ShowPopup(new RequirementsPopupViewModel(UiTaskHandlerExtensions.ToCommand(
                                                                                     () => Cheat.PublishEvent(new DoLogin()))) {
                DisplayName  = "Action '" + action + "' requires login",
                Message      = "Please login first to perform this action",
                CommandTitle = "Login"
            });

            // TODO: Login and retry options
            return(RecoveryOptionResult.CancelOperation);
        }
        public ServerLibraryViewModel(Game game, Lazy <ServersViewModel> serversVm, IContentManager contentList,
                                      IServerList serverList, LaunchManager launchManager, IDialogManager dialogManager, ISpecialDialogManager specialDialogManager)
        {
            _serversVm            = serversVm;
            _contentList          = contentList;
            Settings              = DomainEvilGlobal.Settings;
            _launchManager        = launchManager;
            ServerList            = serverList;
            _dialogManager        = dialogManager;
            _specialDialogManager = specialDialogManager;

            SearchItem = new SearchServerLibraryItemViewModel(this, new CleanServerFilter());

            this.SetCommand(x => x.JoinServ);
            JoinServ.RegisterAsyncTask(
                x => JoinServer((Server)x))
            .Subscribe();

            this.SetCommand(x => x.ServerInfoCommand).Cast <Server>().Subscribe(ServerInfo);
            UpdateCommand = UiTaskHandlerExtensions.CreateCommand("UpdateCommand", true, true);
            UpdateCommand.RegisterAsyncTaskVoid <Server>(UpdateServer).Subscribe();
            this.SetCommand(x => x.ResetFiltersCommand).Subscribe(RefreshFilter);
            this.SetCommand(x => x.Note).Cast <Server>().Subscribe(ShowNotes);

            ViewType = Settings.ServerOptions.ViewType;
            this.ObservableForProperty(x => x.ViewType)
            .Select(x => x.Value)
            .BindTo(Settings, s => s.ServerOptions.ViewType);

            this.WhenAnyValue(x => x.ActiveItem)
            .Skip(1)
            .Subscribe(x => game.CalculatedSettings.Server = x);

            DomainEvilGlobal.SelectedGame.WhenAnyValue(x => x.ActiveGame.CalculatedSettings.Server)
            .Subscribe(x => ActiveItem = x);

            var playerSortDescriptions =
                new[] {
                new SortDescription("Score", ListSortDirection.Descending),
                new SortDescription("Deaths", ListSortDirection.Ascending)
            };

            Players = new ReactiveList <Player>();
            Players.EnableCollectionSynchronization(_playersLock);
            PlayersView = Players.SetupDefaultCollectionView(playerSortDescriptions, null, null, null, true);

            this.WhenAnyValue(x => x.SelectedItem.SelectedItem)
            .OfType <Server>()
            .BindTo(this, x => x.SelectedServer);

            this.WhenAnyValue(x => x.SelectedServer.Players)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(UpdatePlayers);

            this.WhenAnyValue(x => x.SelectedItem.SelectedItem)
            .Subscribe(x => {
                if (x == null)
                {
                    Players.Clear();
                }
            });

            IsLoading = true;
        }