public ServerEntryViewModel(ServerStatusCache cache, ConfigurationManager cfg, Updater updater, string address)
        {
            _cache     = cache;
            _cacheData = cache.GetStatusFor(address);
            _cfg       = cfg;
            _updater   = updater;

            this.WhenAnyValue(x => x.IsAltBackground)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(BackgroundColor)));

            this.WhenAnyValue(x => x._cacheData.PlayerCount)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(ServerStatusString)));

            this.WhenAnyValue(x => x._cacheData.Status)
            .Subscribe(_ =>
            {
                this.RaisePropertyChanged(nameof(IsOnline));
                this.RaisePropertyChanged(nameof(ServerStatusString));
            });

            this.WhenAnyValue(x => x._cacheData.Name)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(Name)));

            this.WhenAnyValue(x => x._cacheData.Ping)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(PingText)));

            _cfg.FavoriteServers.Connect()
            .Subscribe(_ => { this.RaisePropertyChanged(nameof(FavoriteButtonText)); });
        }
Exemplo n.º 2
0
        public ServerEntryViewModel(MainWindowViewModel windowVm, string address)
        {
            _cache     = Locator.Current.GetService <ServerStatusCache>();
            _cfg       = Locator.Current.GetService <DataManager>();
            _windowVm  = windowVm;
            _cacheData = _cache.GetStatusFor(address);

            this.WhenAnyValue(x => x.IsAltBackground)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(BackgroundColor)));

            this.WhenAnyValue(x => x._cacheData.PlayerCount)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(ServerStatusString)));

            this.WhenAnyValue(x => x._cacheData.Status)
            .Subscribe(_ =>
            {
                this.RaisePropertyChanged(nameof(IsOnline));
                this.RaisePropertyChanged(nameof(ServerStatusString));
            });

            this.WhenAnyValue(x => x._cacheData.Name)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(Name)));

            this.WhenAnyValue(x => x._cacheData.Ping)
            .Subscribe(_ => this.RaisePropertyChanged(nameof(PingText)));

            _cfg.FavoriteServers.Connect()
            .Subscribe(_ => { this.RaisePropertyChanged(nameof(FavoriteButtonText)); });
        }