Пример #1
0
 public MailListViewModel(IMailService mailService, IRegionDialogService regionDialogService)
 {
     _mailService         = mailService;
     _regionDialogService = regionDialogService;
 }
Пример #2
0
 public MailListViewModel(IMailService mailService, IRegionDialogService regionDialogService) :
     base(mailService, regionDialogService)
 {
 }
Пример #3
0
 public MessageReadOnlyViewModel(IMailService mailService, IRegionDialogService regionDialogService) :
     base(mailService, regionDialogService)
 {
 }
 public MessageViewModelBase(IMailService mailService, IRegionDialogService regionDialogService)
 {
     MailService         = mailService;
     RegionDialogService = regionDialogService;
 }
Пример #5
0
        public ShellViewModel(IRegionManager regionManager, IRegionDialogService dialogService,
                              IConnectionService connectionService)
        {
            _regionManager     = regionManager;
            _dialogService     = dialogService;
            _connectionService = connectionService;

            // Page load command
            LoadCommand = new DelegateCommand(async() =>
            {
                // Get all connections from json configuration file
                var connection = await _connectionService.GetAllAsync();

                if (connection != null && connection.Count > 0)
                {
                    DispatcherService.BeginInvoke(() => Connections = connection);
                }
            });

            // Treeview item selection command
            NavCommand = new DelegateCommand <object>(async(item) =>
            {
                // Connection
                if (item is ConnectionInfo connection)
                {
                    // If connection is un-connecting or disconnected, start connection
                    if (!connection.IsConnecting && !connection.IsConnected)
                    {
                        await connection.ConnectAsync();
                    }
                    return;
                }

                // Database
                if (item is DatabaseInfo database)
                {
                    if (!database.IsInitialized)
                    {
                        await database.LoadKeyAsync(); // load all keys
                    }
                    return;
                }

                // Key
                if (item is KeyInfo key)
                {
                    _regionManager.ShowKeyViewer(key); // show key detail view
                    return;
                }
            });

            // New key view command
            NewKeyCommand = new DelegateCommand <DatabaseInfo>((database) =>
            {
                // Show new key view
                _dialogService.ShowNewKey(database, c =>
                {
                    // If add new key success, append the KeyInfo to the Treeview, not need reload the Treeview
                    if (c.Result == ButtonResult.OK)
                    {
                    }
                });
            });

            // New connection view command
            NewConnectionCommand = new DelegateCommand(() =>
            {
                // Show new connection view
                _dialogService.ShowNewConnection(c =>
                {
                    // If add new connection success, append the ConnectionInfo to the Treeview, not need reload the Treeview
                    if (c.Result == ButtonResult.OK &&
                        c.Parameters.TryGetValue <ConnectionInfo>("connection_info", out var connection) && connection != null)
                    {
                        // Maybe Treeview is null
                        if (Connections == null)
                        {
                            Connections = new ConnectionCollection();
                        }

                        Connections.Add(connection);
                    }
                });
            });
        }
Пример #6
0
 public static void ShowNewConnection(this IRegionDialogService dialogService, Action <IDialogResult> callback)
 {
     dialogService.ShowDialog(nameof(NewConnectionView), null, callback);
 }
Пример #7
0
 public static void ShowNewKey(this IRegionDialogService dialogService, DatabaseInfo database, Action <IDialogResult> callback)
 {
     //dialogService.ShowDialog(nameof(NewKeyView), new DialogParameters { { "database_info", database } }, callback);
 }