public UserSettingsViewModel( IScreen hostScreen, ILogger <UserSettingsViewModel> logger, Config config, BilibiliApiClient apiClient) { HostScreen = hostScreen; _logger = logger; Config = config; _apiClient = apiClient; QrCodeLoginCommand = ReactiveCommand.CreateFromTask(QrCodeLoginAsync); CheckLoginCommand = ReactiveCommand.CreateFromTask(CheckLoginAsync); }
public QrCodeLoginDialog(GetLoginUrlData data) { _logger = DI.GetRequiredService <ILogger <QrCodeLoginDialog> >(); _apiClient = DI.GetRequiredService <BilibiliApiClient>(); _data = data; InitializeComponent(); using var qrGenerator = new QRCodeGenerator(); using var qrCodeData = qrGenerator.CreateQrCode(data.url, QRCodeGenerator.ECCLevel.H, true); using var qrCode = new XamlQRCode(qrCodeData); QrCodeImage.Source = qrCode.GetGraphic(20); _loginInfoMonitor = CreateMonitor(); PrimaryButtonCommand = ReactiveCommand.CreateFromTask(GetLoginInfoAsync); }
public LiveRecordListViewModel( IScreen hostScreen, ILogger <LiveRecordListViewModel> logger, Config config, SourceList <LiveRecordList> liveRecordSourceList, TaskListViewModel taskList, BilibiliApiClient apiClient) { HostScreen = hostScreen; _logger = logger; Config = config; _taskList = taskList; _liveRecordSourceList = liveRecordSourceList; _apiClient = apiClient; _roomIdMonitor = this .WhenAnyValue(x => x.Config.RoomId, x => x.TriggerLiveRecordListQuery) .Throttle(TimeSpan.FromMilliseconds(800), RxApp.MainThreadScheduler) .DistinctUntilChanged() .Where(i => i.Item1 > 0) .Select(i => i.Item1) .Subscribe(i => { GetAnchorInfoAsync(i).Forget(); GetRecordListAsync(i).Forget(); }); _liveRecordSourceList.Connect() .Transform(x => new LiveRecordViewModel(x)) .ObserveOnDispatcher() .Bind(out LiveRecordList) .DisposeMany() .Subscribe(); CopyLiveRecordDownloadUrlCommand = ReactiveCommand.CreateFromTask <object?>(CopyLiveRecordDownloadUrlAsync); OpenLiveRecordUrlCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(OpenLiveRecordUrl); OpenDirCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(OpenDir); DownLoadVideoCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(DownloadVideo); DownLoadDanmuCommand = ReactiveCommand.CreateFromObservable <object?, Unit>(DownloadDanmu); }