public IChatModel Create(IChatModel model) { // Validate model BusinessWorkflowBase.ValidateIDIsNull(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Search for an Existing Record (Don't allow Duplicates var results = Search(ChatMapper.MapToSearchModel(model)); if (results.Any()) { return(results.First()); } // Return the first that matches // Map model to a new entity var newEntity = ChatMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it ChatsRepository.Add(newEntity); // Try to Save Changes ChatsRepository.SaveChanges(); // Return the new value return(Get(newEntity.Id)); }
protected ChatViewModel(IChatModel model) { Model = model; Messages = new ObservableCollection<string>(); Model.NewMessage += (sender, args) => InsertMessage(args.UserName, args.Message); }
public GlobalTabViewModel( IChatModel cm, IUnityContainer contain, IRegionManager regman, IEventAggregator eventagg, ICharacterManager manager) : base(contain, regman, eventagg, cm, manager) { Container.RegisterType<object, GlobalTabView>(GlobalTabView); genderSettings = new GenderSettingsModel(); SearchSettings.Updated += (s, e) => { OnPropertyChanged("SortedUsers"); OnPropertyChanged("SearchSettings"); }; GenderSettings.Updated += (s, e) => { OnPropertyChanged("GenderSettings"); OnPropertyChanged("SortedUsers"); }; Events.GetEvent<NewUpdateEvent>().Subscribe( args => { var thisNotification = args as CharacterUpdateModel; if (thisNotification == null) return; if (thisNotification.Arguments is CharacterUpdateModel.ListChangedEventArgs || thisNotification.Arguments is CharacterUpdateModel.LoginStateChangedEventArgs) OnPropertyChanged("SortedUsers"); }); }
public ChannelbarViewModel( IChatModel cm, IUnityContainer contain, IRegionManager regman, IEventAggregator events, ICharacterManager manager) : base(contain, regman, events, cm, manager) { 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>(); ChatModel.Notifications.CollectionChanged += (s, e) => { if (!IsExpanded) { // removed checking logic, allow the notifications daemon to worry about that HasUpdate = true; } }; } catch (Exception ex) { ex.Source = "Channelbar ViewModel, init"; Exceptions.HandleException(ex); } }
public IChatModel Update(IChatModel model) { // Validate model BusinessWorkflowBase.ValidateRequiredNullableID(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Find existing entity // ReSharper disable once PossibleInvalidOperationException var existingEntity = ChatsRepository.Get(model.Id.Value); // Check if we would be applying identical information, if we are, just return the original // ReSharper disable once SuspiciousTypeConversion.Global if (ChatMapper.AreEqual(model, existingEntity)) { return(ChatMapper.MapToModel(existingEntity)); } // Map model to an existing entity ChatMapper.MapToEntity(model, ref existingEntity); existingEntity.UpdatedDate = BusinessWorkflowBase.GenDateTime; // Update it ChatsRepository.Update(ChatMapper.MapToEntity(model)); // Try to Save Changes ChatsRepository.SaveChanges(); // Return the new value return(Get(existingEntity.Id)); }
protected ChannelbarViewModelCommon( IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager lists) : base(contain, regman, events, cm, lists) { cm.SelectedChannelChanged += (s, e) => OnPropertyChanged("HasUsers"); }
public virtual bool AreEqual(IChatModel model, IChat entity) { return NameableEntityMapper.AreEqual(model, entity) // Chat Properties && model.ChannelName == entity.ChannelName && model.PasswordHash == entity.PasswordHash // Related Objects && model.ImageFileId == entity.ImageFileId ; }
public Presenter() { Status = "Offline"; Roster = new ObservableCollection<string>(); Messages = new ObservableCollection<string>(); MessageToSend = string.Empty; _chatModel = new ChatModel();//new EchoChatModel(); ConnectToChatModel(_chatModel); }
public virtual bool AreEqual(IChatModel model, IChat entity) { return(NameableEntityMapper.AreEqual(model, entity) // Chat Properties && model.ChannelName == entity.ChannelName && model.PasswordHash == entity.PasswordHash // Related Objects && model.ImageFileId == entity.ImageFileId ); }
protected override void Dispose(bool isManaged) { if (isManaged) { cm = null; complaint = null; events = null; } base.Dispose(isManaged); }
public UtilityChannelViewModel( string name, IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager manager, IAutomationService automation) : base(contain, regman, events, cm, manager) { this.automation = automation; try { Model = Container.Resolve<GeneralChannelModel>(name); ConnectTime = 0; flavorText = new StringBuilder("Connecting"); connectDotDot = new StringBuilder(); Container.RegisterType<object, UtilityChannelView>(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"); OnPropertyChanged("IsConnecting"); }; updateTimer.Elapsed += UpdateConnectText; Events.GetEvent<NewUpdateEvent>().Subscribe( param => { if (!(param is CharacterUpdateModel)) return; var temp = param as CharacterUpdateModel; if (!(temp.Arguments is CharacterUpdateModel.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); } catch (Exception ex) { ex.Source = "Utility Channel ViewModel, init"; Exceptions.HandleException(ex); } }
public ServerHandler(IChatModel chatModel, TcpClient client) { this.chatModel = chatModel; this.chatModel.AddHandler(this); this.client = client; stream = client.GetStream(); userId = "Unknown"; connect = false; sending = false; receiving = false; new Thread(async() => await AfterConnect()).Start(); }
/// <summary> /// ChatItem objects are generated dynamically from IChatModel. By default, a ChatItem is allowed to be resized up to 60% of the entire screen. /// I've thought about it being editable from outside, but there's no real need to. /// </summary> /// <param name="message"></param> public void AddMessage(IChatModel message) { var chatItem = new ChatItem(message); chatItem.Name = "chatItem" + itemsPanel.Controls.Count; chatItem.Dock = DockStyle.Top; itemsPanel.Controls.Add(chatItem); chatItem.BringToFront(); chatItem.ResizeBubbles((int)(itemsPanel.Width * 0.6)); itemsPanel.ScrollControlIntoView(chatItem); }
public ChannelsTabViewModel( IChatModel cm, IUnityContainer contain, IRegionManager reggman, IEventAggregator events, ICharacterManager manager) : base(contain, reggman, events, cm, manager) { Container.RegisterType<object, ChannelTabView>(ChannelsTabView); SearchSettings.Updated += (s, e) => { OnPropertyChanged("SearchSettings"); OnPropertyChanged("SortedChannels"); }; }
public virtual void MapToEntity(IChatModel model, ref IChat entity, int currentDepth = 1) { currentDepth++; // Assign Base properties NameableEntityMapper.MapToEntity(model, ref entity); // Chat Properties entity.ChannelName = model.ChannelName; entity.PasswordHash = model.PasswordHash; // Related Objects entity.ImageFileId = model.ImageFileId; entity.ImageFile = (ImageFile)model.ImageFile?.MapToEntity(); // Associated Objects // <None> }
public AutomationService(IEventAggregator events, ICharacterManager manager, IChatModel cm) { this.events = events; this.manager = manager; this.cm = cm; 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); }
private bool requestIsSent; // used for determining Login UI state #endregion Fields #region Constructors public LoginViewModel( IUnityContainer contain, IRegionManager regman, IAccount acc, IEventAggregator events, IChatModel cm, ICharacterManager lists) : base(contain, regman, events, cm, lists) { try { model = acc.ThrowIfNull("acc"); } 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 virtual IChat MapToEntity(IChatModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity<Chat, IChatModel>(model); // Chat Properties entity.ChannelName = model.ChannelName; entity.PasswordHash = model.PasswordHash; // Related Objects entity.ImageFileId = model.ImageFileId; entity.ImageFile = (ImageFile)model.ImageFile?.MapToEntity(); // Associated Objects // <None> // Return Entity return entity; }
public virtual IChatSearchModel MapToSearchModel(IChatModel model) { var searchModel = NameableEntityMapper.MapToSearchModel <IChatModel, ChatSearchModel>(model); // Search Properties searchModel.ImageFileId = model.ImageFileId; searchModel.ImageFileCustomKey = model.ImageFile?.CustomKey; searchModel.ImageFileApiDetailUrl = model.ImageFile?.ApiDetailUrl; searchModel.ImageFileSiteDetailUrl = model.ImageFile?.SiteDetailUrl; searchModel.ImageFileName = model.ImageFile?.Name; searchModel.ImageFileShortDescription = model.ImageFile?.ShortDescription; searchModel.ImageFileDescription = model.ImageFile?.Description; searchModel.ChannelName = model.ChannelName; // Return Search Model return(searchModel); }
public virtual IChat MapToEntity(IChatModel model, int currentDepth = 1) { currentDepth++; var entity = NameableEntityMapper.MapToEntity <Chat, IChatModel>(model); // Chat Properties entity.ChannelName = model.ChannelName; entity.PasswordHash = model.PasswordHash; // Related Objects entity.ImageFileId = model.ImageFileId; entity.ImageFile = (ImageFile)model.ImageFile?.MapToEntity(); // Associated Objects // <None> // Return Entity return(entity); }
public ChatWrapperViewModel( IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager lists) : base(contain, regman, events, cm, lists) { try { Events.GetEvent<CharacterSelectedLoginEvent>() .Subscribe(HandleCurrentCharacter, ThreadOption.UIThread, true); } catch (Exception ex) { ex.Source = "Chat Wrapper 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 ChatState( IUnityContainer container, IRegionManager regionManager, IEventAggregator eventAggregator, IChatModel chatModel, ICharacterManager characterManager, IHandleChatConnection connection, IAccount account) { Connection = connection; Container = container; RegionManager = regionManager; EventAggregator = eventAggregator; ChatModel = chatModel; CharacterManager = characterManager; Account = account; }
public NotificationsTabViewModel( IChatModel cm, IUnityContainer contain, IRegionManager regman, IEventAggregator eventagg, ICharacterManager manager) : base(contain, regman, eventagg, cm, manager) { Container.RegisterType<object, NotificationsTabView>(NotificationsTabView); notificationManager = new FilteredCollection<NotificationModel, IViewableObject>( ChatModel.Notifications, MeetsFilter, true); notificationManager.Collection.CollectionChanged += (sender, args) => { OnPropertyChanged("HasNoNotifications"); OnPropertyChanged("NeedsAttention"); }; }
protected ChannelViewModelBase( IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager manager) : base(contain, regman, events, cm, manager) { Events.GetEvent<ErrorEvent>().Subscribe(UpdateError); PropertyChanged += OnThisPropertyChanged; if (errorRemoveTimer != null) return; errorRemoveTimer = new Timer(5000); errorRemoveTimer.Elapsed += (s, e) => { Error = null; }; errorRemoveTimer.AutoReset = false; }
public CharacterSelectViewModel( IUnityContainer contain, IRegionManager regman, IEventAggregator events, IAccount acc, IChatModel cm, ICharacterManager manager) : base(contain, regman, events, cm, manager) { try { model = acc.ThrowIfNull("acc"); Events.GetEvent<LoginCompleteEvent>() .Subscribe(HandleLoginComplete, ThreadOption.UIThread, true); } catch (Exception ex) { ex.Source = "Character Select ViewModel, init"; Exceptions.HandleException(ex); } }
public void Verify_Update_WithDuplicateData_Should_NotAddAndReturnOriginal() { // Arrange var entity = ChatsMockingSetup.DoMockingSetupForChat(1); var mockChatsRepository = ChatsMockingSetup.DoMockingSetupForRepository(); mockChatsRepository.Setup(m => m.Get(It.IsAny <int>())).Returns(() => entity.Object); var businessWorkflow = new ChatsBusinessWorkflow(mockChatsRepository.Object, new ChatMapper()); var model = ChatsMockingSetup.DoMockingSetupForChatModel(1); IChatModel result = null; // Act try { result = businessWorkflow.Update(model.Object); } catch { /* ignored, the Get call at the end doesn't work because don't get a real entity with id on it */ } // Assert Assert.NotNull(result); Assert.Equal("/TEST/KING-STEPHEN", result.ApiDetailUrl); Assert.Null(result.UpdatedDate); }
public UsersTabViewModel( IChatModel cm, IUnityContainer contain, IRegionManager regman, IEventAggregator eventagg, ICharacterManager manager) : base(contain, regman, eventagg, cm, manager) { Container.RegisterType<object, UsersTabView>(UsersTabView); genderSettings = new GenderSettingsModel(); SearchSettings.Updated += (s, e) => { OnPropertyChanged("SortedUsers"); OnPropertyChanged("SearchSettings"); }; GenderSettings.Updated += (s, e) => { OnPropertyChanged("GenderSettings"); OnPropertyChanged("SortedUsers"); }; 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 CharacterUpdateModel.PromoteDemoteEventArgs) OnPropertyChanged("HasPermissions"); else if (thisNotification.Arguments is CharacterUpdateModel.JoinLeaveEventArgs || thisNotification.Arguments is CharacterUpdateModel.ListChangedEventArgs) OnPropertyChanged("SortedUsers"); }); }
public IChatModel Create(IChatModel model) { // Validate model BusinessWorkflowBase.ValidateIDIsNull(model.Id); //BusinessWorkflowBase.ValidateRequiredString(model.Name, nameof(model.Name)); // Search for an Existing Record (Don't allow Duplicates var results = Search(ChatMapper.MapToSearchModel(model)); if (results.Any()) { return results.First(); } // Return the first that matches // Map model to a new entity var newEntity = ChatMapper.MapToEntity(model); newEntity.CreatedDate = BusinessWorkflowBase.GenDateTime; newEntity.UpdatedDate = null; newEntity.Active = true; // Add it ChatsRepository.Add(newEntity); // Try to Save Changes ChatsRepository.SaveChanges(); // Return the new value return Get(newEntity.Id); }
public CommandService( IChatModel cm, IChatConnection conn, IChannelManager manager, IUnityContainer contain, IRegionManager regman, IEventAggregator eventagg, ICharacterManager characterManager, IAutomationService automation) : base(contain, regman, eventagg, cm, characterManager) { connection = conn; this.manager = manager; this.automation = automation; Events.GetEvent<CharacterSelectedLoginEvent>() .Subscribe(GetCharacter, ThreadOption.BackgroundThread, true); Events.GetEvent<ChatCommandEvent>().Subscribe(EnqueAction, ThreadOption.BackgroundThread, true); Events.GetEvent<ConnectionClosedEvent>().Subscribe(WipeState, ThreadOption.PublisherThread, true); ChatModel.CurrentAccount = connection.Account; }
protected ViewModelBase(IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager manager) { try { Container = contain.ThrowIfNull("contain"); RegionManager = regman.ThrowIfNull("regman"); Events = events.ThrowIfNull("events"); ChatModel = cm.ThrowIfNull("cm"); CharacterManager = manager.ThrowIfNull("manager"); RightClickMenuViewModel = new RightClickMenuViewModel(ChatModel.IsGlobalModerator, CharacterManager); 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 static IChat MapToEntity(this IChatModel model, int currentDepth = 1) { return(Mapper.MapToEntity(model, currentDepth)); }
//Cross-tested this with the Twilio API and the RingCentral API, and async messaging is the way to go. async void SendMessage(object sender, EventArgs e) { string tonumber = phoneLabel.Text; string chatmessage = chatTextbox.Text; IChatModel chatModel = null; TextChatModel textModel = null; //Each IChatModel is specifically built for a single purpose. For that reason, if you want to display a text item AND and image, you'd make two IChatModels for //their respective purposes. AttachmentChatModel and ImageChatModel, however, can really be used interchangeably. if (attachment != null && attachmenttype.Contains("image")) { chatModel = new ImageChatModel() { Author = user, Image = Image.FromStream(new MemoryStream(attachment)), ImageName = attachmentname, Inbound = false, Read = true, Time = DateTime.Now, }; } else if (attachment != null) { chatModel = new AttachmentChatModel() { Author = user, Attachment = attachment, Filename = attachmentname, Read = true, Inbound = false, Time = DateTime.Now }; } if (!string.IsNullOrWhiteSpace(chatmessage) && chatmessage != chatplaceholder) { textModel = new TextChatModel() { Author = user, Body = chatmessage, Inbound = false, Read = true, Time = DateTime.Now }; } try { /* * * INSERT SENDING LOGIC HERE. Again, this is just a UserControl, not a complete app. For the Ringcentral API, I was able to reduce this section * down to a single method. * */ if (chatModel != null) { AddMessage(chatModel); CancelAttachment(null, null); } if (textModel != null) { AddMessage(textModel); chatTextbox.Text = string.Empty; } } catch (Exception exc) { //If any exception is found, then it is printed on the screen. Feel free to change this method if you don't want people to see exceptions. textModel = new TextChatModel() { Author = user, Body = "The message could not be processed. Please see the reason below.\r\n" + exc.Message, Inbound = false, Read = true, Time = DateTime.Now }; AddMessage(textModel); } }
public ServerConnector(IChatModel chatModel, int port = 3010, string host = "127.0.0.1") { this.chatModel = chatModel; this.port = port; this.host = host; }
public static bool AreEqual(this IChatModel model, IChat entity) { return(Mapper.AreEqual(model, entity)); }
public PermissionService(IChatModel cm, ICharacterManager manager) { this.cm = cm; this.manager = manager; }
public PermissionService(IChatState chatState) { cm = chatState.ChatModel; characters = chatState.CharacterManager; }
public ChatItem(IChatModel chatModel) { InitializeComponent(); if (chatModel == null) { chatModel = new TextChatModel() { Author = "System", Body = "No chat messages were found regarding this client.", Inbound = true, Time = DateTime.Now }; } ChatModel = chatModel; if (chatModel.Inbound) { bodyPanel.Dock = DockStyle.Left; authorLabel.Dock = DockStyle.Left; bodyPanel.BackColor = Color.FromArgb(100, 101, 165); bodyTextBox.BackColor = Color.FromArgb(100, 101, 165); } else { bodyPanel.Dock = DockStyle.Right; authorLabel.Dock = DockStyle.Right; bodyTextBox.TextAlign = HorizontalAlignment.Right; } //Fills in the label. if (chatModel.Time > DateTime.Today) { authorLabel.Text = $"{chatModel.Author ?? "System"}, {chatModel.Time.ToShortTimeString()}"; } else { authorLabel.Text = $"{chatModel.Author ?? "System"}, {chatModel.Time.ToShortDateString()}"; } switch (chatModel.Type) { case "text": var textmodel = chatModel as TextChatModel; bodyTextBox.Text = textmodel.Body.Trim(); break; case "image": var imagemodel = chatModel as ImageChatModel; bodyTextBox.Visible = false; bodyPanel.BackgroundImage = imagemodel.Image; bodyPanel.BackColor = Color.GhostWhite; bodyPanel.BackgroundImageLayout = ImageLayout.Stretch; break; case "attachment": var attachmentmodel = chatModel as AttachmentChatModel; bodyPanel.BackColor = Color.OrangeRed; bodyTextBox.BackColor = Color.OrangeRed; bodyTextBox.Text = "Click to download: " + attachmentmodel.Filename; bodyTextBox.Click += DownloadAttachment; break; default: break; } }
public MessageService( IRegionManager regman, IUnityContainer contain, IEventAggregator events, IChatModel model, IChatConnection connection, IListConnection api, ICharacterManager manager, ILoggingService logger, IAutomationService automation) { this.logger = logger; this.automation = automation; try { region = regman.ThrowIfNull("regman"); container = contain.ThrowIfNull("contain"); this.events = events.ThrowIfNull("events"); this.model = model.ThrowIfNull("model"); this.connection = connection.ThrowIfNull("connection"); this.api = api.ThrowIfNull("api"); characterManager = manager.ThrowIfNull("characterManager"); this.model.SelectedChannelChanged += (s, e) => RequestNavigate(this.model.CurrentChannel.Id); this.events.GetEvent<ChatOnDisplayEvent>() .Subscribe(BuildHomeChannel, ThreadOption.UIThread, true); this.events.GetEvent<RequestChangeTabEvent>() .Subscribe(RequestNavigate, ThreadOption.UIThread, true); this.events.GetEvent<UserCommandEvent>().Subscribe(CommandRecieved, ThreadOption.UIThread, true); commands = new Dictionary<string, CommandHandler> { {"priv", OnPrivRequested}, {Commands.UserMessage, OnPriRequested}, {Commands.ChannelMessage, OnMsgRequested}, {Commands.ChannelAd, OnLrpRequested}, {Commands.UserStatus, OnStatusChangeRequested}, {"close", OnCloseRequested}, {"join", OnJoinRequested}, {Commands.UserIgnore, OnIgnoreRequested}, {"clear", OnClearRequested}, {"clearall", OnClearAllRequested}, {"_logger_open_log", OnOpenLogRequested}, {"_logger_open_folder", OnOpenLogFolderRequested}, {"code", OnChannelCodeRequested}, {"_snap_to_last_update", OnNotificationFocusRequested}, {Commands.UserInvite, OnInviteToChannelRequested}, {"who", OnWhoInformationRequested}, {"getdescription", OnChannelDescripionRequested}, {"interesting", OnMarkInterestedRequested}, {"notinteresting", OnMarkNotInterestedRequested}, {"ignoreUpdates", OnIgnoreUpdatesRequested}, {Commands.AdminAlert, OnReportRequested}, {"tempignore", OnTemporaryIgnoreRequested}, {"tempunignore", OnTemporaryIgnoreRequested}, {"tempinteresting", OnTemporaryInterestingRequested}, {"tempnotinteresting", OnTemporaryInterestingRequested}, {"handlelatest", OnHandleLatestReportRequested}, {"handlereport", OnHandleLatestReportByUserRequested} }; } catch (Exception ex) { ex.Source = "Message Daemon, init"; Exceptions.HandleException(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="NotificationService" /> class. /// </summary> /// <param name="eventagg"> /// The eventagg. /// </param> /// <param name="cm"> /// The cm. /// </param> /// <param name="manager"></param> public NotificationService(IEventAggregator eventagg, IChatModel cm, ICharacterManager manager) { events = eventagg; this.cm = cm; this.manager = manager; toast = new ToastNotificationsViewModel(events); events.GetEvent<NewMessageEvent>().Subscribe(HandleNewChannelMessage, true); events.GetEvent<NewPmEvent>().Subscribe(HandleNewMessage, true); events.GetEvent<NewUpdateEvent>().Subscribe(HandleNotification, true); events.GetEvent<CharacterSelectedLoginEvent>().Subscribe( args => { Application.Current.MainWindow.Closing += (s, e) => { e.Cancel = true; HideWindow(); }; Application.Current.MainWindow.MouseLeave += (s, e) => events.GetEvent<ErrorEvent>().Publish(null); this.cm.SelectedChannelChanged += (s, e) => events.GetEvent<ErrorEvent>().Publish(null); icon.Icon = new Icon(Environment.CurrentDirectory + @"\icons\catIcon.ico"); icon.DoubleClick += (s, e) => ShowWindow(); icon.BalloonTipClicked += (s, e) => { Settings.Default.ShowStillRunning = false; Settings.Default.Save(); }; var iconMenu = new ContextMenu(); iconMenu.MenuItems.Add( new MenuItem( string.Format( "{0} {1} ({2}) - {3}", Constants.ClientId, Constants.ClientName, Constants.ClientVer, args)) { Enabled = false }); iconMenu.MenuItems.Add(new MenuItem("-")); iconMenu.MenuItems.Add( new MenuItem("Sounds Enabled", ToggleSound) { Checked = ApplicationSettings.Volume > 0.0, }); iconMenu.MenuItems.Add( new MenuItem("Toasts Enabled", ToggleToast) { Checked = ApplicationSettings .ShowNotificationsGlobal }); iconMenu.MenuItems.Add(new MenuItem("-")); iconMenu.MenuItems.Add("Show", (s, e) => ShowWindow()); iconMenu.MenuItems.Add("Exit", (s, e) => ShutDown()); icon.Text = string.Format("{0} - {1}", Constants.ClientId, args); icon.ContextMenu = iconMenu; icon.Visible = true; }); }
public GeneralChannelViewModel( string name, IUnityContainer contain, IRegionManager regman, IEventAggregator events, IChatModel cm, ICharacterManager manager) : base(contain, regman, events, cm, manager) { try { Model = ChatModel.CurrentChannels.FirstOrDefault(chan => chan.Id == name) ?? ChatModel.AllChannels.First(chan => chan.Id == name); Model.ThrowIfNull("this.Model"); var safeName = HelperConverter.EscapeSpaces(name); Container.RegisterType<object, GeneralChannelView>(safeName, new InjectionConstructor(this)); isDisplayingChat = ShouldDisplayChat; ChannelManagementViewModel = new ChannelManagementViewModel(Events, Model as GeneralChannelModel); // instance our management vm Model.Messages.CollectionChanged += OnMessagesChanged; Model.Ads.CollectionChanged += OnAdsChanged; Model.PropertyChanged += OnModelPropertyChanged; searchSettings = new GenericSearchSettingsModel(); genderSettings = new GenderSettingsModel(); messageManager = new FilteredMessageCollection( isDisplayingChat ? Model.Messages : Model.Ads, MeetsFilter, ConstantFilter, IsDisplayingAds); genderSettings.Updated += (s, e) => OnPropertyChanged("GenderSettings"); SearchSettings.Updated += (s, e) => OnPropertyChanged("SearchSettings"); messageFlood.Elapsed += (s, e) => { isInCoolDownMessage = false; messageFlood.Enabled = false; OnPropertyChanged("CanPost"); }; adFlood.Elapsed += (s, e) => { isInCoolDownAd = false; adFlood.Enabled = false; OnPropertyChanged("CanPost"); OnPropertyChanged("CannotPost"); OnPropertyChanged("ShouldShowAutoPost"); if (autoPostAds) SendAutoAd(); }; update.Elapsed += (s, e) => { if (!Model.IsSelected) return; if (CannotPost) OnPropertyChanged("TimeLeft"); OnPropertyChanged("StatusString"); }; ChannelManagementViewModel.PropertyChanged += (s, e) => OnPropertyChanged("ChannelManagementViewModel"); update.Enabled = true; var newSettings = SettingsService.GetChannelSettings( cm.CurrentCharacter.Name, Model.Title, Model.Id, Model.Type); Model.Settings = newSettings; ChannelSettings.Updated += (s, e) => { OnPropertyChanged("ChannelSettings"); OnPropertyChanged("HasNotifyTerms"); if (!ChannelSettings.IsChangingSettings) { SettingsService.UpdateSettingsFile( ChannelSettings, cm.CurrentCharacter.Name, Model.Title, Model.Id); } }; PropertyChanged += OnPropertyChanged; Events.GetEvent<NewUpdateEvent>().Subscribe(UpdateChat); } catch (Exception ex) { ex.Source = "General Channel ViewModel, init"; Exceptions.HandleException(ex); } }
public ForegroundBrushConverter(IChatModel cm, IThemeLocator locator) { this.cm = cm; this.locator = locator; }
protected BbCodeBaseConverter(IChatState chatState, IThemeLocator locator) { characters = chatState.CharacterManager; Locator = locator; ChatModel = chatState.ChatModel; }
public static IChatSearchModel MapToSearchModel(this IChatModel model) { return(Mapper.MapToSearchModel(model)); }
private void ConnectToChatModel(IChatModel chatModel) { chatModel.StatusUpdate += OnStatusUpdate; chatModel.ErrorMessage += OnErrorMessage; chatModel.RosterChanged += OnRosterChanged; chatModel.MessageReceived += OnMessageReceived; chatModel.MessageTransmitted += OnMessageTransmitted; }
public static void MapToEntity(this IChatModel model, ref IChat entity, int currentDepth = 1) { Mapper.MapToEntity(model, ref entity, currentDepth); }
public CreateReportViewModel(IEventAggregator eventagg, IChatModel cm) { events = eventagg; this.cm = cm; }