Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessagesViewModel"/> class.
        /// </summary>
        public MessagesViewModel(
            IMessenger messenger,
            IDiscordService discordService,
            IDispatcherService dispatcherService,
            IClipboardService clipboardService,
            QuarrelClient quarrelClient)
        {
            _messenger         = messenger;
            _discordService    = discordService;
            _dispatcherService = dispatcherService;
            _clipboardService  = clipboardService;
            _quarrelClient     = quarrelClient;
            _semaphore         = new SemaphoreSlim(1, 1);

            Source    = new ObservableRangeCollection <BindableMessage>();
            IsLoading = false;

            _messenger.Register <ChannelSelectedMessage <IBindableSelectableChannel> >(this, (_, m) => SelectedChannel = m.Channel);
            _messenger.Register <MessageCreatedMessage>(this, (_, m) =>
            {
                if (SelectedChannel?.Id != m.Message.ChannelId)
                {
                    return;
                }
                _dispatcherService.RunOnUIThread(() => AppendMessage(m.Message));
            });
            _messenger.Register <MessageDeletedMessage>(this, (_, m) =>
            {
                if (SelectedChannel?.Id != m.ChannelId)
                {
                    return;
                }
                _dispatcherService.RunOnUIThread(() => RemoveMessage(m.MessageId));
            });
        }
Beispiel #2
0
        private async void OnLoggedIn(AccountInfo info)
        {
            _storageService.AccountInfoStorage.RegisterAccount(info);
            _storageService.AccountInfoStorage.SelectAccount(info.Id);
            await _storageService.AccountInfoStorage.SaveAsync();

            _dispatcherService.RunOnUIThread(() =>
            {
                WindowState = WindowHostState.LoggedIn;
            });
        }
Beispiel #3
0
        public Shell()
        {
            this.InitializeComponent();
            _messenger         = App.Current.Services.GetRequiredService <IMessenger>();
            _dispatcherService = App.Current.Services.GetRequiredService <IDispatcherService>();

            _messenger.Register <GuildSelectedMessage <IBindableSelectableGuildItem> >(this, (_, _) => _messenger.Send(new TogglePanelMessage(PanelSide.Left, PanelState.Open)));
            _messenger.Register <TogglePanelMessage>(this, (_, e) =>
            {
                _dispatcherService.RunOnUIThread(() =>
                {
                    GoToPanelState(e);
                });
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CurrentUserViewModel"/> class.
        /// </summary>
        public CurrentUserViewModel(ILoggingService loggingService, IMessenger messenger, IDiscordService discordService, QuarrelClient quarrelClient, IDispatcherService dispatcherService)
        {
            _loggingService    = loggingService;
            _messenger         = messenger;
            _discordService    = discordService;
            _quarrelClient     = quarrelClient;
            _dispatcherService = dispatcherService;

            NavigateToSettingsCommand = new RelayCommand(NavigateToSettings);
            SetStatusCommand          = new RelayCommand <UserStatus>(SetStatus);

            _messenger.Register <UserLoggedInMessage>(this, (_, _) =>
            {
                _dispatcherService.RunOnUIThread(() =>
                {
                    Me = new BindableSelfUser(_messenger, _discordService, _quarrelClient, _dispatcherService, _quarrelClient.Self.CurrentUser);
                });
            });
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VoiceControllerViewModel"/> class.
        /// </summary>
        public VoiceControllerViewModel(IMessenger messenger, IDiscordService discordService, QuarrelClient quarrelClient, IDispatcherService dispatcherService)
        {
            _messenger         = messenger;
            _discordService    = discordService;
            _quarrelClient     = quarrelClient;
            _dispatcherService = dispatcherService;

            _messenger.Register <MyVoiceStateUpdatedMessage>(this, (_, m) =>
            {
                var state = new BindableVoiceState(
                    _messenger,
                    _discordService,
                    _quarrelClient,
                    _dispatcherService,
                    m.VoiceState);

                _dispatcherService.RunOnUIThread(() => VoiceState = state);
            });

            HangupCommand = new RelayCommand(Hangup);
        }