Ejemplo n.º 1
0
        public MainViewModel(IScreen screen, ISettingsManager settingsManager, IVersionManager versionManager)
        {
            HostScreen = screen;

            Games = new GamesViewModel(Locator.Current);
            Downloads = new DownloadsViewModel(Locator.Current.GetService<IJobManager>());
            Messsages = new MessagesViewModel(Locator.Current.GetService<IDatabaseManager>(), Locator.Current.GetService<IMessageManager>());
            GotoSettings = ReactiveCommand.CreateAsyncObservable(_ => screen.Router.Navigate.ExecuteAsync(new SettingsViewModel(screen, settingsManager, versionManager, Locator.Current.GetService<IGameManager>())));

            // login status
            settingsManager.WhenAnyValue(sm => sm.AuthenticatedUser)
                .Select(u => u == null ? "Not logged." : $"Logged as {u.Name}")
                .ToProperty(this, x => x.LoginStatus, out _loginStatus);

            // show notice when new version arrives but hide when button was clicked
            versionManager.NewVersionAvailable
                .Where(release => release != null)
                .Subscribe(newRelease => {
                    ShowUpdateNotice = true;
                });
            CloseUpdateNotice.Subscribe(_ => {
                ShowUpdateNotice = false;
            });

            // restart button
            RestartApp.Subscribe(_ => { UpdateManager.RestartApp(); });
        }
Ejemplo n.º 2
0
        public SystemItemViewModel(GamesViewModel parent, PinballXSystem system)
        {
            _parent       = parent;
            System        = system;
            ToggleDetails = ReactiveCommand.Create(() => { IsExpanded = !IsExpanded; });

            this.WhenAnyValue(vm => vm.IsExpanded).Select(expanded => expanded ? 180d : 0d).ToProperty(this, vm => vm.ExpanderRotation, out _expanderRotation);
        }