Ejemplo n.º 1
0
        public ChannelService(
            IChatState chatState,
            ILogThings logger,
            IAutomateThings automation)
        {
            try
            {
                region = chatState.RegionManager;
                container = chatState.Container;
                events = chatState.EventAggregator;
                cm = chatState.ChatModel;
                connection = chatState.Connection;
                characters = chatState.CharacterManager;
                this.logger = logger.ThrowIfNull("logger");
                this.automation = automation.ThrowIfNull("automation");

                events.GetEvent<ChatOnDisplayEvent>().Subscribe(BuildHomeChannel, ThreadOption.UIThread, true);
                events.GetEvent<RequestChangeTabEvent>().Subscribe(RequestNavigate, ThreadOption.UIThread, true);
            }
            catch (Exception ex)
            {
                ex.Source = "Message Daemon, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 2
0
        public ServerCommandService(IChatState chatState,
            IAutomateThings automation,
            IManageNotes notes,
            IManageChannels channels,
            IFriendRequestService friendRequestService)
            : base(chatState)
        {
            this.channels = channels;
            this.automation = automation;
            this.notes = notes;
            this.friendRequestService = friendRequestService;

            Events.GetEvent<CharacterSelectedLoginEvent>()
                .Subscribe(GetCharacter, ThreadOption.BackgroundThread, true);
            Events.GetEvent<ChatCommandEvent>().Subscribe(EnqueueAction, ThreadOption.BackgroundThread, true);
            Events.GetEvent<ConnectionClosedEvent>().Subscribe(WipeState, ThreadOption.PublisherThread, true);

            ChatModel.CurrentAccount = ChatConnection.Account;

            noisyTypes = new[]
            {
                UserJoin,
                UserLeave,
                UserStatus,
                PublicChannelList,
                PrivateChannelList,
                UserList,
                ChannelAd,
                ChannelMessage
            };

            LoggingSection = "cmnd serv";
        }
Ejemplo n.º 3
0
        protected ChannelViewModelBase(IChatState chatState)
            : base(chatState)
        {
            Events.GetEvent <ErrorEvent>().Subscribe(UpdateError);

            PropertyChanged += OnThisPropertyChanged;

            if (errorRemoveTimer != null)
            {
                return;
            }

            errorRemoveTimer          = new Timer(5000);
            errorRemoveTimer.Elapsed += (s, e) => Error = null;

            errorRemoveTimer.AutoReset = false;

            saveMessageTimer = new Timer(10000)
            {
                AutoReset = false
            };

            entryBoxRowHeight = new GridLength(1, GridUnitType.Auto);
            headerRowHeight   = new GridLength(1, GridUnitType.Auto);


            Events.GetEvent <ConnectionClosedEvent>().Subscribe(OnDisconnect, ThreadOption.PublisherThread, true);
        }
Ejemplo n.º 4
0
        public ServerCommandService(IChatState chatState,
                                    IAutomateThings automation,
                                    IManageNotes notes,
                                    IManageChannels channels,
                                    IFriendRequestService friendRequestService)
            : base(chatState)
        {
            this.channels             = channels;
            this.automation           = automation;
            this.notes                = notes;
            this.friendRequestService = friendRequestService;

            Events.GetEvent <CharacterSelectedLoginEvent>()
            .Subscribe(GetCharacter, ThreadOption.BackgroundThread, true);
            Events.GetEvent <ChatCommandEvent>().Subscribe(EnqueueAction, ThreadOption.BackgroundThread, true);
            Events.GetEvent <ConnectionClosedEvent>().Subscribe(WipeState, ThreadOption.PublisherThread, true);

            ChatModel.CurrentAccount = ChatConnection.Account;

            noisyTypes = new[]
            {
                UserJoin,
                UserLeave,
                UserStatus,
                PublicChannelList,
                PrivateChannelList,
                UserList,
                ChannelAd,
                ChannelMessage
            };

            LoggingSection = "cmnd serv";
        }
Ejemplo n.º 5
0
        public UsersTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType<object, UsersTabView>(UsersTabView);
            GenderSettings = new GenderSettingsModel();

            SearchSettings.Updated += OnSearchSettingsUpdated;

            GenderSettings.Updated += OnSearchSettingsUpdated;

            ChatModel.SelectedChannelChanged += (s, e) =>
            {
                currentChan = null;
                OnPropertyChanged("SortContentString");
                OnPropertyChanged("SortedUsers");
            };

            Events.GetEvent<NewUpdateEvent>().Subscribe(
                args =>
                {
                    var thisNotification = args as CharacterUpdateModel;
                    if (thisNotification == null)
                        return;

                    if (thisNotification.Arguments is PromoteDemoteEventArgs)
                        OnPropertyChanged("HasPermissions");


                    else if (thisNotification.Arguments is JoinLeaveEventArgs
                             || thisNotification.Arguments is CharacterListChangedEventArgs)
                        OnPropertyChanged("SortedUsers");
                });

            updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers"));
        }
Ejemplo n.º 6
0
        public SearchTabViewModel(IChatState chatState, IBrowseThings browser)
            : base(chatState)
        {
            this.browser = browser;
            Container.RegisterType <object, SearchTabView>(SearchTabView);

            chatSearchCooldownTimer.Elapsed += (sender, args) =>
            {
                isInSearchCoolDown = false;
                OnPropertyChanged("CanStartSearch");
                chatSearchCooldownTimer.Stop();
            };

            saveTerms =
                DeferredAction.Create(
                    () => SettingsService.SaveSearchTerms(ChatModel.CurrentCharacter.Name, new SearchTermsModel
            {
                AvailableTerms = availableSearchTerms.ToList(),
                SelectedTerms  = selectedSearchTerms.ToList()
            }));

            if (ChatModel.CurrentCharacter == null)
            {
                return;
            }
            GetSearchTerms(ChatModel.CurrentCharacter.Name);
        }
Ejemplo n.º 7
0
        public GlobalTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType <object, GlobalTabView>(GlobalTabView);
            GenderSettings = new GenderSettingsModel();

            SearchSettings.Updated += OnSearchSettingsUpdated;
            GenderSettings.Updated += OnSearchSettingsUpdated;

            Events.GetEvent <NewUpdateEvent>().Subscribe(
                args =>
            {
                var thisNotification = args as CharacterUpdateModel;
                if (thisNotification == null)
                {
                    return;
                }

                if (thisNotification.Arguments is CharacterListChangedEventArgs ||
                    thisNotification.Arguments is LoginStateChangedEventArgs)
                {
                    OnPropertyChanged("SortedUsers");
                }
            });


            updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers"));
        }
Ejemplo n.º 8
0
        public NotificationService(IChatState chatState, LoggingService loggingService, IHandleIcons iconService)
        {
            ChatState = chatState;
            events = chatState.EventAggregator;
            cm = chatState.ChatModel;
            characters = chatState.CharacterManager;
            icon = iconService;
            toast = new ToastNotificationsViewModel(chatState);
            ToastManager = new ToastService
            {
                AddNotification = notification =>
                {
                    Dispatcher.Invoke(() => cm.Notifications.Backlog(notification, 100));
                    loggingService.LogMessage("!Notifications", notification);
                },
                ShowToast = toast.ShowNotifications,
                FlashWindow = () => Dispatcher.Invoke(FlashWindow),
                PlaySound = () => Dispatcher.Invoke(DingTheCrapOutOfTheUser),
                Toast = toast
            };

            events.GetEvent<NewMessageEvent>().Subscribe(HandleNewChannelMessage, true);
            events.GetEvent<NewPmEvent>().Subscribe(HandleNewMessage, true);
            events.GetEvent<NewUpdateEvent>().Subscribe(HandleNotification, true);
            events.GetEvent<UnreadUpdatesEvent>().Subscribe(HandleUnreadUpdates, true);
        }
Ejemplo n.º 9
0
 public BotHandler(IConverter <TModel> converter, ChatContext <TModel> context, IChatStateStorage <TModel> storage, IChatState <TModel> chatState)
 {
     this.converter = converter;
     this.context   = context;
     this.storage   = storage;
     this.chatState = chatState;
 }
Ejemplo n.º 10
0
        public ChannelService(
            IChatState chatState,
            ILogThings logger,
            IAutomateThings automation)
        {
            try
            {
                region          = chatState.RegionManager;
                container       = chatState.Container;
                events          = chatState.EventAggregator;
                cm              = chatState.ChatModel;
                connection      = chatState.Connection;
                characters      = chatState.CharacterManager;
                this.logger     = logger.ThrowIfNull("logger");
                this.automation = automation.ThrowIfNull("automation");

                events.GetEvent <ChatOnDisplayEvent>().Subscribe(BuildHomeChannel, ThreadOption.UIThread, true);
                events.GetEvent <RequestChangeTabEvent>().Subscribe(RequestNavigate, ThreadOption.UIThread, true);
            }
            catch (Exception ex)
            {
                ex.Source = "Message Daemon, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 11
0
        public NotificationService(IChatState chatState, LoggingService loggingService, IHandleIcons iconService)
        {
            ChatState    = chatState;
            events       = chatState.EventAggregator;
            cm           = chatState.ChatModel;
            characters   = chatState.CharacterManager;
            icon         = iconService;
            toast        = new ToastNotificationsViewModel(chatState);
            ToastManager = new ToastService
            {
                AddNotification = notification =>
                {
                    Dispatcher.Invoke(() => cm.Notifications.Backlog(notification, 100));
                    loggingService.LogMessage("!Notifications", notification);
                },
                ShowToast   = toast.ShowNotifications,
                FlashWindow = () => Dispatcher.Invoke(FlashWindow),
                PlaySound   = () => Dispatcher.Invoke(DingTheCrapOutOfTheUser),
                Toast       = toast
            };

            events.GetEvent <NewMessageEvent>().Subscribe(HandleNewChannelMessage, true);
            events.GetEvent <NewPmEvent>().Subscribe(HandleNewMessage, true);
            events.GetEvent <NewUpdateEvent>().Subscribe(HandleNotification, true);
            events.GetEvent <UnreadUpdatesEvent>().Subscribe(HandleUnreadUpdates, true);
        }
Ejemplo n.º 12
0
        public HomeChannelViewModel(string name, IChatState chatState, IAutomateThings automation, IBrowseThings browser,
                                    HomeSettingsViewModel settingsVm, HomeHelpViewModel helpVm, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                Model         = Container.Resolve <GeneralChannelModel>(name);
                ConnectTime   = 0;
                flavorText    = new StringBuilder("Connecting");
                connectDotDot = new StringBuilder();

                this.updateService = updateService;
                HelpVm             = helpVm;

                Container.RegisterType <object, HomeChannelView>(Model.Id, new InjectionConstructor(this));
                minuteOnlineCount = new CacheCount(OnlineCountPrime, 15, 1000 * 15);

                updateTimer.Enabled  = true;
                updateTimer.Elapsed += (s, e) =>
                {
                    OnPropertyChanged("RoughServerUpTime");
                    OnPropertyChanged("RoughClientUpTime");
                    OnPropertyChanged("LastMessageReceived");
                };

                updateTimer.Elapsed += UpdateConnectText;
                SettingsVm           = settingsVm;

                Events.GetEvent <NewUpdateEvent>().Subscribe(param =>
                {
                    var temp = param as CharacterUpdateModel;
                    if (!(temp?.Arguments is LoginStateChangedEventArgs))
                    {
                        return;
                    }

                    OnPropertyChanged("OnlineCount");
                    OnPropertyChanged("OnlineFriendsCount");
                    OnPropertyChanged("OnlineBookmarksCount");
                    OnPropertyChanged("OnlineCountChange");
                });

                Events.GetEvent <LoginAuthenticatedEvent>().Subscribe(LoggedInEvent);
                Events.GetEvent <LoginFailedEvent>().Subscribe(LoginFailedEvent);
                Events.GetEvent <ReconnectingEvent>().Subscribe(LoginReconnectingEvent);

                this.automation = automation;
                this.browser    = browser;

                LoggingSection = "utility channel vm";

                Themes = new ObservableCollection <ThemeModel>();
            }
            catch (Exception ex)
            {
                ex.Source = "Utility Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 13
0
 public HomeSettingsViewModel(IChatState chatState, IAutomateThings automationService, IconService iconService,
                              ICharacterManager characterManager)
     : base(chatState)
 {
     automation            = automationService;
     this.iconService      = iconService;
     this.characterManager = characterManager;
 }
Ejemplo n.º 14
0
 public HomeSettingsViewModel(IChatState chatState, IAutomateThings automationService, IconService iconService,
     ICharacterManager characterManager)
     : base(chatState)
 {
     automation = automationService;
     this.iconService = iconService;
     this.characterManager = characterManager;
 }
Ejemplo n.º 15
0
 public NoteService(IChatState chatstate, IBrowseThings browser)
 {
     this.browser = browser;
     characters   = chatstate.CharacterManager;
     cm           = chatstate.ChatModel;
     events       = chatstate.EventAggregator;
     container    = chatstate.Container;
 }
Ejemplo n.º 16
0
 public NoteService(IChatState chatstate, IBrowseThings browser)
 {
     this.browser = browser;
     characters = chatstate.CharacterManager;
     cm = chatstate.ChatModel;
     events = chatstate.EventAggregator;
     container = chatstate.Container;
 }
Ejemplo n.º 17
0
 public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
 {
     if (ListArgument == ListKind.NotInterested)
     {
         return;
     }
     DoNormalToast(toastsManager);
 }
Ejemplo n.º 18
0
        public HomeChannelViewModel(string name, IChatState chatState, IAutomateThings automation, IBrowseThings browser,
            HomeSettingsViewModel settingsVm, HomeHelpViewModel helpVm, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                Model = Container.Resolve<GeneralChannelModel>(name);
                ConnectTime = 0;
                flavorText = new StringBuilder("Connecting");
                connectDotDot = new StringBuilder();

                this.updateService = updateService;
                HelpVm = helpVm;

                Container.RegisterType<object, HomeChannelView>(Model.Id, new InjectionConstructor(this));
                minuteOnlineCount = new CacheCount(OnlineCountPrime, 15, 1000*15);

                updateTimer.Enabled = true;
                updateTimer.Elapsed += (s, e) =>
                {
                    OnPropertyChanged("RoughServerUpTime");
                    OnPropertyChanged("RoughClientUpTime");
                    OnPropertyChanged("LastMessageReceived");
                };

                updateTimer.Elapsed += UpdateConnectText;
                SettingsVm = settingsVm;

                Events.GetEvent<NewUpdateEvent>().Subscribe(param =>
                {
                    var temp = param as CharacterUpdateModel;
                    if (!(temp?.Arguments is LoginStateChangedEventArgs))
                        return;

                    OnPropertyChanged("OnlineCount");
                    OnPropertyChanged("OnlineFriendsCount");
                    OnPropertyChanged("OnlineBookmarksCount");
                    OnPropertyChanged("OnlineCountChange");
                });

                Events.GetEvent<LoginAuthenticatedEvent>().Subscribe(LoggedInEvent);
                Events.GetEvent<LoginFailedEvent>().Subscribe(LoginFailedEvent);
                Events.GetEvent<ReconnectingEvent>().Subscribe(LoginReconnectingEvent);

                this.automation = automation;
                this.browser = browser;

                LoggingSection = "utility channel vm";

                Themes = new ObservableCollection<ThemeModel>();
            }
            catch (Exception ex)
            {
                ex.Source = "Utility Channel ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 19
0
        public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
        {
            var settings = chatState.GetChannelSettingsById(TargetChannelId);
            if (settings == null) return;

            var setting = new ChannelSettingPair(settings.JoinLeaveNotifyLevel,
                settings.JoinLeaveNotifyOnlyForInteresting);
            DoToast(setting, toastsManager, chatState);
        }
Ejemplo n.º 20
0
        private void Chatstate_Loaded(object sender, RoutedEventArgs e)
        {
            Unloaded += Chatstate_Unloaded;

            _chatBase = (IChatState)DataContext;
            _chatBase.PropertyChanged += _contactChat_PropertyChanged;

            HandleChatState();
        }
Ejemplo n.º 21
0
        public IconService(IChatState chatState)
        {
            events = chatState.EventAggregator;
            cm = chatState.ChatModel;

            events.GetEvent<CharacterSelectedLoginEvent>().Subscribe(OnCharacterSelected);
            events.GetEvent<LoginAuthenticatedEvent>().Subscribe(OnLoginAuthenticated);
            catIcon = new Icon(Environment.CurrentDirectory + @"\icons\catIcon.ico");
            balloonIcon = new Icon(Environment.CurrentDirectory + @"\icons\balloonIcon.ico");
        }
Ejemplo n.º 22
0
        public IconService(IChatState chatState)
        {
            events = chatState.EventAggregator;
            cm     = chatState.ChatModel;

            events.GetEvent <CharacterSelectedLoginEvent>().Subscribe(OnCharacterSelected);
            events.GetEvent <LoginAuthenticatedEvent>().Subscribe(OnLoginAuthenticated);
            catIcon     = new Icon(Environment.CurrentDirectory + @"\icons\catIcon.ico");
            balloonIcon = new Icon(Environment.CurrentDirectory + @"\icons\balloonIcon.ico");
        }
Ejemplo n.º 23
0
        public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
        {
            if (!ApplicationSettings.ShowLoginToasts ||
                !chatState.IsInteresting(Model.TargetCharacter.Name) ||
                chatState.CharacterManager.IsOnList(Model.TargetCharacter.Name, ListKind.IgnoreUpdates, false))
            {
                return;
            }

            DoNormalToast(toastsManager);
        }
Ejemplo n.º 24
0
        public virtual void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
        {
            if (!Model.TargetChannel.Settings.AlertAboutUpdates)
            {
                return;
            }

            SetToastData(toastsManager.Toast);
            toastsManager.AddNotification(Model);
            toastsManager.ShowToast();
        }
Ejemplo n.º 25
0
        public ChannelsTabViewModel(IChatState chatState, IUpdateChannelLists updater)
            : base(chatState)
        {
            this.updater = updater;
            Container.RegisterType<object, ChannelTabView>(ChannelsTabView);

            SearchSettings.Updated += Update;

            ChatModel.AllChannels.CollectionChanged += Update;
            updateChannelList = DeferredAction.Create(() => OnPropertyChanged("SortedChannels"));
        }
Ejemplo n.º 26
0
            public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
            {
                if (!ApplicationSettings.ShowStatusToasts
                    || !chatState.IsInteresting(Model.TargetCharacter.Name)
                    || chatState.CharacterManager.IsOnList(Model.TargetCharacter.Name, ListKind.IgnoreUpdates, false))
                {
                    return;
                }

                DoNormalToast(toastsManager);
            }
Ejemplo n.º 27
0
        public ChannelsTabViewModel(IChatState chatState, IUpdateChannelLists updater)
            : base(chatState)
        {
            this.updater = updater;
            Container.RegisterType <object, ChannelTabView>(ChannelsTabView);

            SearchSettings.Updated += Update;

            ChatModel.AllChannels.CollectionChanged += Update;
            updateChannelList = DeferredAction.Create(() => OnPropertyChanged("SortedChannels"));
        }
Ejemplo n.º 28
0
        public ProfileService(IChatState chatState, IBrowseThings browser)
        {
            this.browser = browser;
            cm = chatState.ChatModel;
            state = chatState;

            chatState.EventAggregator.GetEvent<LoginAuthenticatedEvent>().Subscribe(GetProfileDataAsync);

            var worker = new BackgroundWorker();
            worker.DoWork += GetKinkDataAsync;
            worker.RunWorkerAsync();
        }
Ejemplo n.º 29
0
 public YODAHub(
     IChatState chatState,
     IRoomService roomService,
     IMessageService messageService,
     IFileService fileService,
     UserManager <User> userManager)
 {
     _roomService    = roomService;
     _userManager    = userManager;
     _messageService = messageService;
     _fileService    = fileService;
     _chatState      = chatState;
 }
Ejemplo n.º 30
0
        public async Task Handle(Message message)
        {
            if (message.Text?.StartsWith('/') ?? false)
            {
                _state = await _state.HandleCommand(message.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries).First(), message);
            }
            else
            {
                _state = await _state.Handle(message);
            }

            await _state.OnStateChanged();
        }
Ejemplo n.º 31
0
        public ProfileService(IChatState chatState, IBrowseThings browser)
        {
            this.browser = browser;
            cm           = chatState.ChatModel;
            state        = chatState;

            chatState.EventAggregator.GetEvent <LoginAuthenticatedEvent>().Subscribe(GetProfileDataAsync);

            var worker = new BackgroundWorker();

            worker.DoWork += GetKinkDataAsync;
            worker.RunWorkerAsync();
        }
Ejemplo n.º 32
0
        public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
        {
            var settings = chatState.GetChannelSettingsById(TargetChannelId);

            if (settings == null)
            {
                return;
            }

            var setting = new ChannelSettingPair(settings.PromoteDemoteNotifyLevel,
                                                 settings.PromoteDemoteNotifyOnlyForInteresting);

            DoToast(setting, toastsManager, chatState);
        }
Ejemplo n.º 33
0
        public AutomationService(IChatState chatState)
        {
            events = chatState.EventAggregator;
            characters = chatState.CharacterManager;
            cm = chatState.ChatModel;

            idleTimer = new Timer(ApplicationSettings.AutoIdleTime*OneMinute);
            awayTimer = new Timer(ApplicationSettings.AutoAwayTime*OneMinute);

            idleTimer.Elapsed += IdleTimerOnElapsed;
            awayTimer.Elapsed += AwayTimerOnElapsed;
            fullscreenTimer.Elapsed += FullscreenTimerOnElapsed;

            events.GetEvent<UserCommandEvent>().Subscribe(OnUserCommandSent);
        }
Ejemplo n.º 34
0
        public AutomationService(IChatState chatState)
        {
            events     = chatState.EventAggregator;
            characters = chatState.CharacterManager;
            cm         = chatState.ChatModel;

            idleTimer = new Timer(ApplicationSettings.AutoIdleTime * OneMinute);
            awayTimer = new Timer(ApplicationSettings.AutoAwayTime * OneMinute);

            idleTimer.Elapsed       += IdleTimerOnElapsed;
            awayTimer.Elapsed       += AwayTimerOnElapsed;
            fullscreenTimer.Elapsed += FullscreenTimerOnElapsed;

            events.GetEvent <UserCommandEvent>().Subscribe(OnUserCommandSent);
        }
Ejemplo n.º 35
0
        public ChannelListUpdaterService(IChatState chatState)
        {
            connection = chatState.Connection;
            cm = chatState.ChatModel;

            chatState.EventAggregator.GetEvent<ConnectionClosedEvent>().Subscribe(OnWipeState);

            var timer = new Timer(60*1000*1);
            timer.Elapsed += (s, e) =>
            {
                UpdateChannels();
                timer.Dispose();
            };
            timer.Start();
        }
Ejemplo n.º 36
0
        public NotificationsTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType<object, NotificationsTabView>(NotificationsTabView);

            notificationManager =
                new FilteredCollection<NotificationModel, IViewableObject>(
                    ChatModel.Notifications, MeetsFilter, true);

            notificationManager.Collection.CollectionChanged += (sender, args) =>
            {
                OnPropertyChanged("HasNoNotifications");
                OnPropertyChanged("NeedsAttention");
            };
        }
Ejemplo n.º 37
0
        public NotificationsTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType <object, NotificationsTabView>(NotificationsTabView);

            notificationManager =
                new FilteredCollection <NotificationModel, IViewableObject>(
                    ChatModel.Notifications, MeetsFilter, true);

            notificationManager.Collection.CollectionChanged += (sender, args) =>
            {
                OnPropertyChanged("HasNoNotifications");
                OnPropertyChanged("NeedsAttention");
            };
        }
Ejemplo n.º 38
0
        public LoginViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                model = chatState.Account;
                Container.RegisterType <object, LoginView>(LoginViewName);

                LoggingSection = "login vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Login ViewModel, Init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 39
0
        public ChannelListUpdaterService(IChatState chatState)
        {
            connection = chatState.Connection;
            cm         = chatState.ChatModel;

            chatState.EventAggregator.GetEvent <ConnectionClosedEvent>().Subscribe(OnWipeState);

            var timer = new Timer(60 * 1000 * 1);

            timer.Elapsed += (s, e) =>
            {
                UpdateChannels();
                timer.Dispose();
            };
            timer.Start();
        }
Ejemplo n.º 40
0
        public ChatWrapperViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                Events.GetEvent <CharacterSelectedLoginEvent>()
                .Subscribe(HandleCurrentCharacter, ThreadOption.UIThread, true);

                Container.RegisterType <object, ChatWrapperView>(ChatWrapperView);
                LoggingSection = "chat wrapper vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Chat Wrapper ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 41
0
        public ChatWrapperViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                Events.GetEvent<CharacterSelectedLoginEvent>()
                    .Subscribe(HandleCurrentCharacter, ThreadOption.UIThread, true);

                Container.RegisterType<object, ChatWrapperView>(ChatWrapperView);
                LoggingSection = "chat wrapper vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Chat Wrapper ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 42
0
        public ChannelbarViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                Events.GetEvent <ChatOnDisplayEvent>().Subscribe(RequestNavigate, ThreadOption.UIThread, true);

                // create the tabs
                Container.Resolve <ChannelsTabViewModel>();
                Container.Resolve <UsersTabViewModel>();
                Container.Resolve <NotificationsTabViewModel>();
                Container.Resolve <GlobalTabViewModel>();
                Container.Resolve <ManageListsTabView>();
                Container.Resolve <SearchTabViewModel>();
                Container.RegisterType <object, ChannelbarView>(ChannelbarView);

                ChatModel.Notifications.CollectionChanged += (s, e) => HasUpdate = ChatModel.Notifications.Any();

                Events.GetEvent <ChatSearchResultEvent>().Subscribe(success =>
                {
                    if (!success)
                    {
                        return;
                    }

                    if (!IsExpanded)
                    {
                        IsExpanded = true;
                    }

                    if (currentSelected != "ManageLists")
                    {
                        NavigateToTabEvent("ManageLists");
                    }

                    OnJumpToSearch?.Invoke(this, null);
                }, ThreadOption.UIThread);

                LoggingSection = "channel bar vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Channelbar ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 43
0
        public static async void OnNewMessage(object sender, MessageEventArgs args)
        {
            TelegramBotClient client = (TelegramBotClient)sender;

            Message message = args.Message;

            AppUser user = new AppUser();

            using (AppDbContext ctx = new AppDbContext())
            {
                user = ctx.AppUsers.Find(args.Message.Chat.Id);

                if (user is null)
                {
                    user = new AppUser()
                    {
                        Id       = args.Message.Chat.Id,
                        Name     = args.Message.Chat.FirstName,
                        LastName = args.Message.Chat.LastName,
                    };
                    ctx.AppUsers.Add(user);
                    ctx.SaveChangesAsync();
                }
            }

            // Получаем текущий стейт юзера
            IChatState     state    = StateCommandsFactory.Create(user);
            List <Command> commands = state.Commands;

            if (message.Text != null)
            {
                Console.WriteLine($"[Log]: New message \"{message.Text}\" from {message.From.FirstName}, phone {message.From.Id}");

                // Проверяем, соответствует ли сообщение, введенное юзером, какой-либо команде
                foreach (var c in commands)
                {
                    if (c.Match(message.Text))
                    {
                        await c.Execute(user, args, client);

                        break;
                    }
                }
            }
        }
Ejemplo n.º 44
0
        public LoginViewModel(IChatState chatState, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                model = chatState.Account;
                this.updateService = updateService;
                CheckForUpdates();
                Container.RegisterType<object, LoginView>(LoginViewName);

                LoggingSection = "login vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Login ViewModel, Init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 45
0
        public LoginViewModel(IChatState chatState, IUpdateMyself updateService)
            : base(chatState)
        {
            try
            {
                model = chatState.Account;
                this.updateService = updateService;
                CheckForUpdates();
                Container.RegisterType <object, LoginView>(LoginViewName);

                LoggingSection = "login vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Login ViewModel, Init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 46
0
        public override async Task <IChatState> HandleCallbackQuery(CallbackQuery callbackQuery)
        {
            IChatState nextState = null;
            var        httpCheckSettingsRepository = ServiceProvider.GetRequiredService <IHttpCheckSettingsRepository>();
            var        action = callbackQuery.Data.Split("::").FirstOrDefault();

            switch (action)
            {
            case "remove":
                await httpCheckSettingsRepository.Remove(Guid.Parse(callbackQuery.Data.Substring(callbackQuery.Data.IndexOf("::") + 2)), CancellationToken.None);

                nextState = this;
                break;
            }

            await base.HandleCallbackQuery(callbackQuery);

            return(nextState ?? new UndefinedChatState(Chat, TelegramBotClient, ServiceProvider));
        }
Ejemplo n.º 47
0
        public CharacterSelectViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                model = chatState.Account;

                Events.GetEvent<LoginCompleteEvent>()
                    .Subscribe(HandleLoginComplete, ThreadOption.UIThread, true);

                LoggingSection = "character select vm";

                Container.RegisterType<object, CharacterSelectView>(CharacterSelectViewName);
            }
            catch (Exception ex)
            {
                ex.Source = "Character Select ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 48
0
        public CharacterSelectViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                model = chatState.Account;

                Events.GetEvent <LoginCompleteEvent>()
                .Subscribe(HandleLoginComplete, ThreadOption.UIThread, true);

                LoggingSection = "character select vm";

                Container.RegisterType <object, CharacterSelectView>(CharacterSelectViewName);
            }
            catch (Exception ex)
            {
                ex.Source = "Character Select ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 49
0
        public UsersTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType <object, UsersTabView>(UsersTabView);
            GenderSettings = new GenderSettingsModel();

            SearchSettings.Updated += OnSearchSettingsUpdated;

            GenderSettings.Updated += OnSearchSettingsUpdated;

            ChatModel.SelectedChannelChanged += (s, e) =>
            {
                currentChan = null;
                OnPropertyChanged("SortContentString");
                OnPropertyChanged("SortedUsers");
            };

            Events.GetEvent <NewUpdateEvent>().Subscribe(
                args =>
            {
                var thisNotification = args as CharacterUpdateModel;
                if (thisNotification == null)
                {
                    return;
                }

                if (thisNotification.Arguments is PromoteDemoteEventArgs)
                {
                    OnPropertyChanged("HasPermissions");
                }


                else if (thisNotification.Arguments is JoinLeaveEventArgs ||
                         thisNotification.Arguments is CharacterListChangedEventArgs)
                {
                    OnPropertyChanged("SortedUsers");
                }
            });

            updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers"));
        }
Ejemplo n.º 50
0
        public ChannelbarViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                Events.GetEvent<ChatOnDisplayEvent>().Subscribe(RequestNavigate, ThreadOption.UIThread, true);

                // create the tabs
                Container.Resolve<ChannelsTabViewModel>();
                Container.Resolve<UsersTabViewModel>();
                Container.Resolve<NotificationsTabViewModel>();
                Container.Resolve<GlobalTabViewModel>();
                Container.Resolve<ManageListsTabView>();
                Container.Resolve<SearchTabViewModel>();
                Container.RegisterType<object, ChannelbarView>(ChannelbarView);

                ChatModel.Notifications.CollectionChanged += (s, e) => HasUpdate = ChatModel.Notifications.Any();

                Events.GetEvent<ChatSearchResultEvent>().Subscribe(success =>
                {
                    if (!success) return;

                    if (!IsExpanded)
                        IsExpanded = true;

                    if (currentSelected != "ManageLists")
                        NavigateToTabEvent("ManageLists");

                    OnJumpToSearch?.Invoke(this, null);
                }, ThreadOption.UIThread);

                LoggingSection = "channel bar vm";
            }
            catch (Exception ex)
            {
                ex.Source = "Channelbar ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 51
0
        public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
        {
            SetToastData(toastsManager.Toast);

            toastsManager.Toast.Title = Title;
            toastsManager.Toast.Navigator = new SimpleNavigator(chat =>
                chat.EventAggregator.GetEvent<RequestChangeTabEvent>().Publish(Channel.Id));
            toastsManager.Toast.Content = Context;

            toastsManager.AddNotification(Model);

            if (Channel.IsSelected)
            {
                if (ApplicationSettings.PlaySoundEvenWhenTabIsFocused)
                    toastsManager.PlaySound();
                return;
            }

            toastsManager.ShowToast();
            toastsManager.PlaySound();
            toastsManager.FlashWindow();
        }
Ejemplo n.º 52
0
        protected ChannelViewModelBase(IChatState chatState)
            : base(chatState)
        {
            Events.GetEvent<ErrorEvent>().Subscribe(UpdateError);

            PropertyChanged += OnThisPropertyChanged;

            if (errorRemoveTimer != null)
                return;

            errorRemoveTimer = new Timer(5000);
            errorRemoveTimer.Elapsed += (s, e) => Error = null;

            errorRemoveTimer.AutoReset = false;

            saveMessageTimer = new Timer(10000) {AutoReset = false};

            entryBoxRowHeight = new GridLength(1, GridUnitType.Auto);
            headerRowHeight = new GridLength(1, GridUnitType.Auto);


            Events.GetEvent<ConnectionClosedEvent>().Subscribe(OnDisconnect, ThreadOption.PublisherThread, true);
        }
Ejemplo n.º 53
0
        protected ViewModelBase(IChatState chatState)
        {
            try
            {
                Container = chatState.Container;
                RegionManager = chatState.RegionManager;
                Events = chatState.EventAggregator;
                ChatModel = chatState.ChatModel;
                CharacterManager = chatState.CharacterManager;
                ChatConnection = chatState.Connection;

                RightClickMenuViewModel = new RightClickMenuViewModel(ChatModel.IsGlobalModerator, CharacterManager,
                    Container.Resolve<IGetPermissions>());
                CreateReportViewModel = new CreateReportViewModel(Events, ChatModel);
                ChatModel.SelectedChannelChanged += OnSelectedChannelChanged;

                Events.GetEvent<NewUpdateEvent>().Subscribe(UpdateRightClickMenu);
            }
            catch (Exception ex)
            {
                ex.Source = "Generic ViewModel, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 54
0
        public GlobalTabViewModel(IChatState chatState)
            : base(chatState)
        {
            Container.RegisterType<object, GlobalTabView>(GlobalTabView);
            GenderSettings = new GenderSettingsModel();

            SearchSettings.Updated += OnSearchSettingsUpdated;
            GenderSettings.Updated += OnSearchSettingsUpdated;

            Events.GetEvent<NewUpdateEvent>().Subscribe(
                args =>
                {
                    var thisNotification = args as CharacterUpdateModel;
                    if (thisNotification == null)
                        return;

                    if (thisNotification.Arguments is CharacterListChangedEventArgs
                        || thisNotification.Arguments is LoginStateChangedEventArgs)
                        OnPropertyChanged("SortedUsers");
                });


            updateUserList = DeferredAction.Create(() => OnPropertyChanged("SortedUsers"));
        }
Ejemplo n.º 55
0
        public SearchTabViewModel(IChatState chatState, IBrowseThings browser)
            : base(chatState)
        {
            this.browser = browser;
            Container.RegisterType<object, SearchTabView>(SearchTabView);

            chatSearchCooldownTimer.Elapsed += (sender, args) =>
            {
                isInSearchCoolDown = false;
                OnPropertyChanged("CanStartSearch");
                chatSearchCooldownTimer.Stop();
            };

            saveTerms =
                DeferredAction.Create(
                    () => SettingsService.SaveSearchTerms(ChatModel.CurrentCharacter.Name, new SearchTermsModel
                    {
                        AvailableTerms = availableSearchTerms.ToList(),
                        SelectedTerms = selectedSearchTerms.ToList()
                    }));

            if (ChatModel.CurrentCharacter == null) return;
            GetSearchTerms(ChatModel.CurrentCharacter.Name);
        }
Ejemplo n.º 56
0
        public UserbarViewModel(IChatState chatState)
            : base(chatState)
        {
            try
            {
                ChatModel.CurrentPms.CollectionChanged += (s, e) => OnPropertyChanged("HasPms");

                // this checks if we need to hide/show the Pm tab
                Events.GetEvent<ChatOnDisplayEvent>().Subscribe(RequestNavigate, ThreadOption.UIThread, true);

                Events.GetEvent<NewPmEvent>()
                    .Subscribe(param => UpdateFlashingTabs(), ThreadOption.UIThread, true);

                Events.GetEvent<NewMessageEvent>()
                    .Subscribe(param => UpdateFlashingTabs(), ThreadOption.UIThread, true);

                Events.GetEvent<ConnectionClosedEvent>()
                    .Subscribe(param => UpdateFlashingTabs(), ThreadOption.UIThread, true);

                ChatModel.SelectedChannelChanged += (s, e) => UpdateFlashingTabs();

                updateTick.Enabled = true;
                updateTick.Elapsed += UpdateConnectionBars;

                Container.RegisterType<object, UserbarView>(UserbarView);

                LoggingSection = "userbar vm";
                IsDisconnected = true;
                OnPropertyChanged("IsDisconnected");
            }
            catch (Exception ex)
            {
                ex.Source = "Userbar vm, init";
                Exceptions.HandleException(ex);
            }
        }
Ejemplo n.º 57
0
 public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager)
 {
     Arguments.DisplayNewToast(chatState, toastsManager);
 }
Ejemplo n.º 58
0
 public override void Navigate(IChatState chatState)
 {
     Arguments.NavigateTo(chatState);
 }
Ejemplo n.º 59
0
        internal void DoToast(ChannelSettingPair setting, IManageToasts toastManager, IChatState chatState)
        {
            if (setting.OnlyForInteresting && !chatState.IsInteresting(Model.TargetCharacter.Name)) return;

            toastManager.NotifyWithSettings(Model, setting.NotifyLevel);

            if (setting.NotifyLevel >= ChannelSettingsModel.NotifyLevel.NotificationAndToast)
                SetToastData(toastManager.Toast);
        }
Ejemplo n.º 60
0
        public override void NavigateTo(IChatState chatState)
        {
            chatState.EventAggregator.GetEvent<RequestChangeTabEvent>().Publish(TargetChannelId);

            NotificationService.ShowWindow();
        }