Ejemplo n.º 1
0
 public LoginService(
     IShell shell,
     IAuthenticationContext domain0AuthenticationContext,
     IAppConfigStorage appConfigStorage)
 {
     _shell            = shell;
     _domain0Context   = domain0AuthenticationContext;
     _appConfigStorage = appConfigStorage;
 }
        public ColorData(IAppConfigStorage storage, Action <AppConfig, string> action)
        {
            _changeAccentCommand = new Lazy <ReactiveCommand <Unit, Unit> >(() =>
                                                                            ReactiveCommand.Create(() =>
            {
                var config = storage.Load();
                action(config, Name);
                storage.Save(config);

                ThemeManager.ChangeTheme(Application.Current, config.AppTheme, config.AccentColor);
            }));
        }
        public ManageToolsViewModel(
            IShell shell,
            IDomain0Service domain0,
            IAuthenticationContext authContext,
            IAppConfigStorage appConfigStorage)
        {
            _shell            = shell;
            _domain0          = domain0;
            _authContext      = authContext;
            _appConfigStorage = appConfigStorage;

            LogoutCommand = ReactiveCommand
                            .Create(Logout)
                            .DisposeWith(Disposables);
            ReloadCommand = ReactiveCommand
                            .CreateFromTask(Reload)
                            .DisposeWith(Disposables);
            CopyTokenToClipboardCommand = ReactiveCommand
                                          .Create(CopyTokenToClipboard)
                                          .DisposeWith(Disposables);
            ChangePasswordCommand = ReactiveCommand
                                    .CreateFromTask(ChangePassword)
                                    .DisposeWith(Disposables);

            OpenUsersCommand = ReactiveCommand
                               .Create(shell.ShowUsers)
                               .DisposeWith(Disposables);
            OpenRolesCommand = ReactiveCommand
                               .Create(shell.ShowRoles)
                               .DisposeWith(Disposables);
            OpenPermissionsCommand = ReactiveCommand
                                     .Create(shell.ShowPermissions)
                                     .DisposeWith(Disposables);
            OpenApplicationsCommand = ReactiveCommand
                                      .Create(shell.ShowApplications)
                                      .DisposeWith(Disposables);
            OpenEnvironmentsCommand = ReactiveCommand
                                      .Create(shell.ShowEnvironments)
                                      .DisposeWith(Disposables);
            OpenMessagesCommand = ReactiveCommand
                                  .Create(shell.ShowMessages)
                                  .DisposeWith(Disposables);

            AccentColors = ThemeManager.ColorSchemes
                           .Select(a => new ColorData(_appConfigStorage,
                                                      (x, v) => x.AccentColor = v)
            {
                Name       = a.Name,
                ColorBrush = a.ShowcaseBrush,
            })
                           .ToList();
            AppThemes = ThemeManager.Themes
                        .GroupBy(x => x.Type)
                        .Select(x => x.First())
                        .Select(a => new ColorData(_appConfigStorage,
                                                   (x, v) => x.AppTheme = v)
            {
                Name             = a.BaseColorScheme,
                BorderColorBrush = a.Resources["MahApps.Brushes.Black"] as Brush,
                ColorBrush       = a.Resources["MahApps.Brushes.White"] as Brush,
            })
                        .ToList();
        }