本文整理汇总了C#中ISettingsManager.WhenAnyValue方法的典型用法代码示例。如果您正苦于以下问题:C# ISettingsManager.WhenAnyValue方法的具体用法?C# ISettingsManager.WhenAnyValue怎么用?C# ISettingsManager.WhenAnyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISettingsManager
的用法示例。
在下文中一共展示了ISettingsManager.WhenAnyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainViewModel
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(); });
}
示例2: SettingsViewModel
public SettingsViewModel(IScreen screen, ISettingsManager settingsManager, IVersionManager versionManager, IGameManager gameManager)
{
HostScreen = screen;
_settingsManager = settingsManager;
_versionManager = versionManager;
_gameManager = gameManager;
ApiKey = _settingsManager.Settings.ApiKey;
AuthUser = _settingsManager.Settings.AuthUser;
AuthPass = _settingsManager.Settings.AuthPass;
Endpoint = _settingsManager.Settings.Endpoint;
PbxFolder = _settingsManager.Settings.PbxFolder;
SyncStarred = _settingsManager.Settings.SyncStarred;
DownloadOnStartup = _settingsManager.Settings.DownloadOnStartup;
PatchTableScripts = _settingsManager.Settings.PatchTableScripts;
MinimizeToTray = _settingsManager.Settings.MinimizeToTray;
ReformatXml = _settingsManager.Settings.ReformatXml;
XmlFileVP = _settingsManager.Settings.XmlFile[Platform.PlatformType.VP];
StartWithWindows = _settingsManager.Settings.StartWithWindows;
DownloadOrientation = _settingsManager.Settings.DownloadOrientation;
DownloadOrientationFallback = _settingsManager.Settings.DownloadOrientationFallback;
DownloadLighting = _settingsManager.Settings.DownloadLighting;
DownloadLightingFallback = _settingsManager.Settings.DownloadLightingFallback;
SaveSettings = ReactiveCommand.CreateAsyncTask(_ => Save());
SaveSettings.IsExecuting.ToProperty(this, vm => vm.IsValidating, out _isValidating);
SaveSettings.ThrownExceptions.Subscribe(e =>
{
// todo either remove or treat correctly.
Console.WriteLine("Exception while saving settings.");
});
ChooseFolder.Subscribe(_ => OpenFolderDialog());
CloseSettings.InvokeCommand(HostScreen.Router, r => r.NavigateBack);
_settingsManager.WhenAnyValue(sm => sm.Settings.IsFirstRun).ToProperty(this, vm => vm.IsFirstRun, out _isFirstRun);
_settingsManager.WhenAnyValue(sm => sm.CanCancel)
.CombineLatest(screen.Router.NavigationStack.Changed, (canCancel, _) => canCancel || screen.Router.NavigationStack.Count > 1)
.DistinctUntilChanged()
.StartWith(true)
.ToProperty(this, vm => vm.CanCancel, out _canCancel);
OrientationSettings.Add(new OrientationSetting("Portrait", SettingsManager.Orientation.Portrait));
OrientationSettings.Add(new OrientationSetting("Landscape", SettingsManager.Orientation.Landscape));
OrientationSettings.Add(new OrientationSetting("Universal (VP10)", SettingsManager.Orientation.Universal));
LightingSettings.Add(new LightingSetting("Day", SettingsManager.Lighting.Day));
LightingSettings.Add(new LightingSetting("Night", SettingsManager.Lighting.Night));
LightingSettings.Add(new LightingSetting("Universal (VP10)", SettingsManager.Lighting.Universal));
XmlFilesVP.Add("Visual Pinball");
XmlFilesVP.Add("Vpdb");
OrientationFallbackSettings.Add(new OrientationSetting("Same *", SettingsManager.Orientation.Same));
OrientationFallbackSettings.Add(new OrientationSetting("Portrait", SettingsManager.Orientation.Portrait));
OrientationFallbackSettings.Add(new OrientationSetting("Landscape", SettingsManager.Orientation.Landscape));
OrientationFallbackSettings.Add(new OrientationSetting("Any", SettingsManager.Orientation.Any));
LightingFallbackSettings.Add(new LightingSetting("Same *", SettingsManager.Lighting.Same));
LightingFallbackSettings.Add(new LightingSetting("Day", SettingsManager.Lighting.Day));
LightingFallbackSettings.Add(new LightingSetting("Night", SettingsManager.Lighting.Night));
LightingFallbackSettings.Add(new LightingSetting("Any", SettingsManager.Lighting.Any));
}