public SettingsViewModel( IMediator mediator, IAppContext context, IPropertyGridViewModel propertyGridViewModel, ITelemetry telemetry) { PropertyGridViewModel = propertyGridViewModel; PropertyGridViewModel.Target = context.UserSettings; Commands.Add("Save", new Command(async _ => { if (await mediator.Send(new SaveUserSettings.Request())) { if (context.UserSettings.SendAnonymousUsageStatistics) { telemetry.Enable(); } else { telemetry.Disable(); } await mediator.Send(new ChangeTheme.Request(context.UserSettings.Theme)); //todo: skip if not changed await mediator.Send(Page.Close()); } })); Commands.Add("Cancel", new Command(_ => mediator.Send(Page.Close()))); }
public WidgetViewModel(IAppContext context, IPropertyGridViewModel propertyGridViewModel) { Widget = context?.Session?.SelectedWidget ?? throw new InvalidOperationException("Widget not found."); PropertyGridViewModel = propertyGridViewModel; PropertyGridViewModel.Target = Widget; }
public EndpointViewModel(IMediator mediator, IPropertyGridViewModel propertyGridViewModel) { PropertyGridViewModel = propertyGridViewModel; Commands.Add("Save", new Command(async _ => { var success = await Task.Run(async() => await mediator.Send(new SaveEndpoint.Request(Endpoint))); if (success) { await mediator.Send(new ClosePage.Request()); } })); Commands.Add("Cancel", new Command(_ => mediator.Send(new ClosePage.Request()))); }
public OptionsViewModel(IMediator mediator, IAppContext context, IPropertyGridViewModel propertyGridViewModel) { PropertyGridViewModel = propertyGridViewModel; Commands.Add("Save", new Command(async _ => { var success = await mediator.Send(new SaveUserSettings.Request()); if (success) { //todo: skip if not changed await mediator.Send(new SwitchTheme.Request(context.UserSettings.Theme)); await mediator.Send(new ClosePage.Request()); } })); Commands.Add("Cancel", new Command(_ => mediator.Send(new ClosePage.Request()))); PropertyGridViewModel.Target = context.UserSettings; }