Ejemplo n.º 1
0
        public ToastWindowViewModel(Func<IChatDocument> chatDocumentCreator, IMessageBus bus, IApplicationActivator activator)
        {
            _chatDocumentCreator = chatDocumentCreator;
            _bus = bus;
            _activator = activator;

            Toasts = new ReactiveCollection<ToastViewModel>();

            Subscribe(() => bus.Listen<ShowToastMessage>().SubscribeUI(OnShowToast));
        }
Ejemplo n.º 2
0
        public ToastWindowViewModel(Func <IChatDocument> chatDocumentCreator, IMessageBus bus, IApplicationActivator activator)
        {
            _chatDocumentCreator = chatDocumentCreator;
            _bus       = bus;
            _activator = activator;

            Toasts = new ReactiveCollection <ToastViewModel>();

            Subscribe(() => bus.Listen <ShowToastMessage>().SubscribeUI(OnShowToast));
        }
Ejemplo n.º 3
0
        public ToastViewModel(ShowToastMessage showToastMessage, IChatDocument document, IMessageBus bus, IApplicationActivator activator)
        {
            _document = document;
            _document.FontSize = 14;
            IsVisible = true;
            RoomName = showToastMessage.Message.Room.Name;
            _document.AddMessage(showToastMessage.Message.Message, showToastMessage.Message.User, null);

            CloseCommand = new ReactiveCommand();
            ActivateCommand = new ReactiveCommand();

            Closed = Observable.Timer(TimeSpan.FromSeconds(showToastMessage.Action.SecondsVisible), RxApp.TaskpoolScheduler)
                 .Do(_ => IsClosing = true).Delay(TimeSpan.FromSeconds(2), RxApp.TaskpoolScheduler)
                 .Select(_ => Unit.Default)
                 .Merge(CloseCommand.Select(_ => Unit.Default))
                 .Merge(ActivateCommand.Select(_ => Unit.Default));

            Subscribe(() =>bus.RegisterMessageSource(
                ActivateCommand.Select(
                    _ => new ActivateModuleByIdMessage(ModuleNames.MainCampfireView, showToastMessage.Message.Room.Id))
                    .Do(_ => activator.Activate())));
        }
Ejemplo n.º 4
0
        public ToastViewModel(ShowToastMessage showToastMessage, IChatDocument document, IMessageBus bus, IApplicationActivator activator)
        {
            _document          = document;
            _document.FontSize = 14;
            IsVisible          = true;
            RoomName           = showToastMessage.Message.Room.Name;
            _document.AddMessage(showToastMessage.Message.Message, showToastMessage.Message.User, null);

            CloseCommand    = new ReactiveCommand();
            ActivateCommand = new ReactiveCommand();

            Closed = Observable.Timer(TimeSpan.FromSeconds(showToastMessage.Action.SecondsVisible), RxApp.TaskpoolScheduler)
                     .Do(_ => IsClosing = true).Delay(TimeSpan.FromSeconds(2), RxApp.TaskpoolScheduler)
                     .Select(_ => Unit.Default)
                     .Merge(CloseCommand.Select(_ => Unit.Default))
                     .Merge(ActivateCommand.Select(_ => Unit.Default));

            Subscribe(() => bus.RegisterMessageSource(
                          ActivateCommand.Select(
                              _ => new ActivateModuleByIdMessage(ModuleNames.MainCampfireView, showToastMessage.Message.Room.Id))
                          .Do(_ => activator.Activate())));
        }