コード例 #1
0
        public MainViewModel()
        {
            _mailController             = DummyTrivialSingleton.GetMailControllerService();
            ThemeColorToggleBaseCommand = new AnotherCommandImplementation(o => SetAppColor((bool)o));

            SetAppColor(true);

            // ToDo: Move menu creation to better place or add it in xaml or generate base on some other data.
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Inbox   ", NumberOfEmails = 3, Content = new MailBoxView("Inbox"), IconContent = new PackIcon {
                    Kind = PackIconKind.Inbox
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Drafts", IconContent = new PackIcon {
                    Kind = PackIconKind.Draft
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Sent", IconContent = new PackIcon {
                    Kind = PackIconKind.Send
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Archived", IconContent = new PackIcon {
                    Kind = PackIconKind.Archive
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Important", IconContent = new PackIcon {
                    Kind = PackIconKind.ImportantDevices
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Spam   ", NumberOfEmails = 99, IconContent = new PackIcon {
                    Kind = PackIconKind.Adb
                }
            });
            _testBurgerMenuItems.Add(new MailMenuItem()
            {
                Name = "Trash", IconContent = new PackIcon {
                    Kind = PackIconKind.Trash
                }
            });

            // Subscribe for controller state updates.
            _mailController.ControllerStateStream.ObserveOnDispatcher().Subscribe(state => ConnectionState = state);
        }
コード例 #2
0
        public LoginViewModel()
        {
            // Connect command invokes MailController Start method.
            Connect = ReactiveCommand.Create(() =>
            {
                _mailController.Start(MailServerType, MailServerEncryption, ServerHost, Login, Password);
            });

            // Disconnect command invokes MailController Stop method.
            Disconnect = ReactiveCommand.Create(() =>
            {
                _mailController.Stop();
            });

            _mailController = DummyTrivialSingleton.GetMailControllerService();

            // Subscribe for controller state updates.
            _mailController.ControllerStateStream.ObserveOnDispatcher().Subscribe(state => ConnectionState = state);
        }
コード例 #3
0
        public MailBoxViewModel()
        {
            // Get MailController object.
            _mailController = DummyTrivialSingleton.GetMailControllerService();

            _mailController.LoadAllExistingMailHeaders();

            // Subscribe to MailHeader stream.Add published MailHeaders to the MailHeaders list.
            _mailController.MailHeaderStream.ObserveOnDispatcher().Subscribe(content =>
            {
                if (content != null)
                {
                    MailHeaders.Add(content);
                }
            });

            // Subscribe to MailContent stream.
            _mailController.MailContentStream.ObserveOnDispatcher().Subscribe(content =>
            {
                if (SelectedMailHeader == null || SelectedMailHeader.Uid != content.Uid)
                {
                    return;
                }
                MailContent = content;
            });

            // When selection changes, send requested to the mail controller for the email content.
            this.WhenAnyValue(x => x.SelectedMailHeader).Subscribe(selection =>
            {
                if (selection != null)
                {
                    MailContent = null;
                    _mailController.EmailContentRequestByUidStream.OnNext(selection.Uid);
                }
            });
        }