public void ConfigTableRowGroup(TableRowGroup row, Collection.Messages message, ChatUIElements messagesContainer) { codeEditor = messagesContainer.codeEditor; var currentStamp = Collection.getField(message.data, "stamp"); var charMessageBody = jsonSerializer.Deserialize<ChatMessageBody>(Collection.getField(message.data,"body")); var containsKey = false; if (!charMessageBody.IsCode){ if (!messagesContainer.LastStamp.IsNullOrEmpty() && messagesContainer.MessagesList.ContainsKey(messagesContainer.LastStamp)) { messagesContainer.MessagesList[messagesContainer.LastStamp].MouseLeftButtonDown -= EditMessage; messagesContainer.MessagesList.Remove(messagesContainer.LastStamp); } containsKey = messagesContainer.MessagesList.ContainsKey(currentStamp); if (!containsKey) messagesContainer.MessagesList.Add(currentStamp,row); messagesContainer.LastStamp = currentStamp; } inputMethod = messagesContainer.InputBox; comboRooms = messagesContainer.ComboRooms; row.Dispatcher.Invoke(new Action(() =>{ if (row.Resources["originalMessage"] == null) { row.Resources.Add("originalMessage", message); } else { row.Resources["originalMessage"] = message; } if (!containsKey) row.MouseLeftButtonDown += EditMessage; })); }
public Chat(IProvideUser userProvider, IListenToMessages<Action<string, string>> roomInvitationsListener, IListenToMessages<Action<string, string>> messageListener, IServiceChatRoomsControl chatRoomControlService, IStoreGlobalState applicationGlobalState, ICreateDteHandler dteHandlerCreator, IStoreDTE dteStore, IHandleCodePaste codePasteEvents, IHandleToolWindowEvents toolWindowEvents, IHandleUserAccountEvents userAccountEvents, IHandleVisualStudioClipboard clipboardHandler, IHandleSocketIOEvents socketIOEvents, ILog logger, IHandleMixedEditorEvents mixedEditorEvents, IHandleUIEvents userInterfaceEvents)//, IHandleChatEvents chatEventsHandler) { chatIsEnabled = true; //chatEvents = chatEventsHandler; dteStore.dte = ((DTE)Package.GetGlobalService(typeof(DTE))); this.dteStore = dteStore; this.codePasteEvents = codePasteEvents; this.toolWindowEvents = toolWindowEvents; this.userAccountEvents = userAccountEvents; this.clipboardHandler = clipboardHandler; this.socketIOEvents = socketIOEvents; this.logger = logger; this.mixedEditorEvents = mixedEditorEvents; this.userInterfaceEvents = userInterfaceEvents; this.applicationGlobalState = applicationGlobalState; this.chatRoomControlService = chatRoomControlService; this.messageListener = messageListener; this.roomInvitationsListener = roomInvitationsListener; this.userProvider = userProvider; this.dteHandlerCreator = dteHandlerCreator; this.messagesList = new Dictionary<string, TableRowGroup>(); this.taskbarNotifierWindow = new TaskbarNotifierWindow(dteStore.dte) { OpeningMilliseconds = 500, HidingMilliseconds = 500, StayOpenMilliseconds = 2000 }; InitializeComponent(); var mce = new ModalCodeEditor { RefControl = this.mainGrid }; codeEditor = mce; var collection = chatRoomControlService.GetCollection(); var roomLinks = FormatRooms(collection.rooms); Resources.Add("rooms", roomLinks); comboRooms.SelectionChanged += OnRoomSelectionChanged; if(roomLinks.Count > 0) comboRooms.SelectedIndex = 0; Loaded += (s, e) => chatRoomControlService.HandleDock(GetChatUIElements()); this.mixedEditorEvents.DataWasPasted += MixedEditorDataWasPasted; lastStamp = ""; this.codePasteEvents.Clear(); this.codePasteEvents.CodePasteWasClicked += PasteCode; this.codePasteEvents.CodeQuotedWasClicked += GoToCode; this.toolWindowEvents.Clear(); this.toolWindowEvents.ToolWindowWasDocked += OnToolWindowWasDocked; this.userAccountEvents.Clear(); this.userAccountEvents.UserHasLogout += OnUserLogout; this.socketIOEvents.Clear(); this.socketIOEvents.SocketWasDisconnected += (s, e) => { currentChannel = ""; //var room = "/room/{0}/messages".FormatUsing(e.RoomId);// "chat " + e.RoomId; //subscribedChannels.Remove(room); Dispatcher.Invoke(new Action(() => btnReconnect.Visibility = Visibility.Visible)); }; roomInvitationChannel = "/user/" + userProvider.GetUser().id.ToString() + "/invitations"; roomInvitationsListener.ListenOnChannel(roomInvitationChannel,RoomInvitationMessage, () => { }, () => { }); }