Ejemplo n.º 1
0
 public UserInterfaceHandler(IHandleUIEvents userInterfaceEvents)
 {
     this.userInterfaceEvents = userInterfaceEvents;
 }
Ejemplo n.º 2
0
        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,
                                                    () => { }, () => { });

        }