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); } }
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"; }
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); }
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"; }
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")); }
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); }
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")); }
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); }
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; }
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); } }
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); }
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); } }
public HomeSettingsViewModel(IChatState chatState, IAutomateThings automationService, IconService iconService, ICharacterManager characterManager) : base(chatState) { automation = automationService; this.iconService = iconService; this.characterManager = characterManager; }
public NoteService(IChatState chatstate, IBrowseThings browser) { this.browser = browser; characters = chatstate.CharacterManager; cm = chatstate.ChatModel; events = chatstate.EventAggregator; container = chatstate.Container; }
public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager) { if (ListArgument == ListKind.NotInterested) { return; } DoNormalToast(toastsManager); }
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); } }
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); }
private void Chatstate_Loaded(object sender, RoutedEventArgs e) { Unloaded += Chatstate_Unloaded; _chatBase = (IChatState)DataContext; _chatBase.PropertyChanged += _contactChat_PropertyChanged; HandleChatState(); }
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"); }
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"); }
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); }
public virtual void DisplayNewToast(IChatState chatState, IManageToasts toastsManager) { if (!Model.TargetChannel.Settings.AlertAboutUpdates) { return; } SetToastData(toastsManager.Toast); toastsManager.AddNotification(Model); toastsManager.ShowToast(); }
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")); }
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); }
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")); }
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(); }
public YODAHub( IChatState chatState, IRoomService roomService, IMessageService messageService, IFileService fileService, UserManager <User> userManager) { _roomService = roomService; _userManager = userManager; _messageService = messageService; _fileService = fileService; _chatState = chatState; }
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(); }
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(); }
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); }
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); }
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); }
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(); }
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"); }; }
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"); }; }
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); } }
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(); }
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); } }
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); } }
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); } }
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; } } } }
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); } }
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); } }
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)); }
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); } }
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); } }
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")); }
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); } }
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(); }
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); }
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); } }
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")); }
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); }
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); } }
public override void DisplayNewToast(IChatState chatState, IManageToasts toastsManager) { Arguments.DisplayNewToast(chatState, toastsManager); }
public override void Navigate(IChatState chatState) { Arguments.NavigateTo(chatState); }
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); }
public override void NavigateTo(IChatState chatState) { chatState.EventAggregator.GetEvent<RequestChangeTabEvent>().Publish(TargetChannelId); NotificationService.ShowWindow(); }