コード例 #1
0
 public void HandleState(SlackState state)
 {
     if (_processors.Count > 0)
     {
         _processors.First().HandleState(state);
     }
 }
コード例 #2
0
 public void HandleState(SlackState state)
 {
     if (_processors.Count > 0)
     {
         _processors.First().HandleState(state);
     }
 }
コード例 #3
0
        protected override void OnMessage(MessageEventArgs e)
        {
            var        chatStateList = JsonConvert.DeserializeObject <List <ChatState> >(e.Data);
            SlackState slackState    = new SlackState(chatStateList);

            OnSlackStateChanged(this, slackState);
        }
コード例 #4
0
        private void SnoozeChat(SlackState lastSlackState, string chatName)
        {
            var snoozedChatState = new ChatState {
                name = chatName
            };
            var originalChatState = lastSlackState.ReplaceChatState(snoozedChatState);

            _snoozedChats[chatName] = originalChatState;
        }
コード例 #5
0
        private void SnoozeChat(SlackState lastSlackState, string chatName)
        {
            var snoozedChatState = new ChatState {
                Id = chatName, Unread = false, Mention = false
            };
            var originalChatState = lastSlackState.ReplaceChatState(snoozedChatState);

            _snoozedChannelStates[chatName] = originalChatState;
        }
コード例 #6
0
        private void ChangeSlackState(SlackState slackState)
        {
            _lastSlackState = slackState;
            // Change the icon and the tooltip
            slackTrayIcon.Text = slackState.TrayState.ToString();

            using (var stream = this.GetType().Assembly.GetManifestResourceStream("SlackWindowsTray.Icons." + slackState.TrayState + ".ico"))
            {
                slackTrayIcon.Icon = new Icon(stream);
            }
        }
コード例 #7
0
        private void ChangeSlackState(SlackState slackState)
        {
            _lastSlackState = slackState;
            // Change the icon and the tooltip
            slackTrayIcon.Text = slackState.TrayState.ToString();

            using (var stream = this.GetType().Assembly.GetManifestResourceStream("SlackWindowsTray.Icons." + slackState.TrayState + ".ico"))
            {
                slackTrayIcon.Icon = new Icon(stream);
            }
        }
コード例 #8
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _lastSlackState = slackState;
            _lastTrayState = slackState.TrayState;

            // Start the animation if possible and enabled
            var canAnimateIcon = SlackWindowsTray.Default.ToBlinkOnMention&& _lastTrayState == TrayStates.ImportantUnread;
            canAnimateIcon |= SlackWindowsTray.Default.ToBlinkOnUnread && _lastTrayState == TrayStates.Unread;
                                 
            _animationTimer.Enabled = canAnimateIcon;

            return true;
        }
コード例 #9
0
        private void HandleState(SlackState slackState, bool skipMyself)
        {
            var continueToNextProcessor = true;
            if (!skipMyself)
            {
                continueToNextProcessor = this.HandleStateRaw(slackState);
            }

            if (continueToNextProcessor && Next != null)
            {
                Next.HandleState(slackState.Clone());
            }
        }
コード例 #10
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _lastSlackState = slackState;
            _lastTrayState  = slackState.TrayState;

            // Start the animation if possible and enabled
            var canAnimateIcon = SlackWindowsTray.Default.ToBlinkOnMention && _lastTrayState == TrayStates.ImportantUnread;

            canAnimateIcon |= SlackWindowsTray.Default.ToBlinkOnUnread && _lastTrayState == TrayStates.Unread;

            _animationTimer.Enabled = canAnimateIcon;

            return(true);
        }
コード例 #11
0
        private void HandleState(SlackState slackState, bool skipMyself)
        {
            var continueToNextProcessor = true;

            if (!skipMyself)
            {
                continueToNextProcessor = this.HandleStateRaw(slackState);
            }

            if (continueToNextProcessor && Next != null)
            {
                Next.HandleState(slackState.Clone());
            }
        }
コード例 #12
0
        protected override void OnMessage(MessageEventArgs e)
        {
            dynamic message = JsonConvert.DeserializeObject(e.Data);

            if (message.command == "chat-state")
            {
                var        bodyString    = JsonConvert.SerializeObject(message.body);
                var        chatStateList = JsonConvert.DeserializeObject <List <ChatState> >(bodyString);
                SlackState slackState    = new SlackState(chatStateList);
                OnSlackStateChanged(this, slackState);
            }
            else if (message.command == "version")
            {
                var version = Assembly.GetExecutingAssembly().GetName().Version;

                message.body = string.Format("{0}.{1}", version.Major, version.Minor);
                this.Send(JsonConvert.SerializeObject(message));
            }
        }
コード例 #13
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _lastSlackState = slackState;

            if (_allSnoozed)
            {
                // Don't proceed with the state change if everything is snoozed - We don't want to show anything to the user anyway
                return(false);
            }
            else
            {
                foreach (var chatName in _snoozedChats.Keys)
                {
                    SnoozeChat(_lastSlackState, chatName);
                }

                return(true);
            }
        }
コード例 #14
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _lastSlackState = slackState;

            if (_snoozingService.IsDndMode)
            {
                // Don't proceed with the state change if everything is snoozed - We don't want to show anything to the user anyway
                return false;
            }
            else
            {
                List<string> channelIds = slackState.ChatStates.Select(chatState => chatState.Id).ToList();
                foreach (var channelId in channelIds)
                {
                    if (_snoozingService.IsChannelSnoozed(channelId))
                    {
                        SnoozeChat(slackState, channelId);
                    }
                }

                return true;
            }
        }
コード例 #15
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _lastSlackState = slackState;

            if (_snoozingService.IsDndMode)
            {
                // Don't proceed with the state change if everything is snoozed - We don't want to show anything to the user anyway
                return(false);
            }
            else
            {
                List <string> channelIds = slackState.ChatStates.Select(chatState => chatState.Id).ToList();
                foreach (var channelId in channelIds)
                {
                    if (_snoozingService.IsChannelSnoozed(channelId))
                    {
                        SnoozeChat(slackState, channelId);
                    }
                }

                return(true);
            }
        }
コード例 #16
0
        protected override void OnMessage(MessageEventArgs e)
        {
            dynamic message = JsonConvert.DeserializeObject(e.Data);
            if (message.command == "chat-state")
            {
                var bodyString = JsonConvert.SerializeObject(message.body);
                List<ChatState> chatStateList = JsonConvert.DeserializeObject<List<ChatState>>(bodyString);
                foreach (var state in chatStateList)
                {
                    state.Name = _slakApi.SlackIdToName(state.Id);
                }
                
                SlackState slackState = new SlackState(chatStateList);
                OnSlackStateChanged(this, slackState);
            }
            else if (message.command == "version")
            {
                var version = Assembly.GetExecutingAssembly().GetName().Version;

                message.body = string.Format("{0}.{1}", version.Major, version.Minor);
                this.Send(JsonConvert.SerializeObject(message));
            }
        }
コード例 #17
0
 private void SnoozeChat(SlackState lastSlackState, string chatName)
 {
     var snoozedChatState = new ChatState {Id = chatName, Unread = false, Mention = false};
     var originalChatState = lastSlackState.ReplaceChatState(snoozedChatState);
     _snoozedChannelStates[chatName] = originalChatState;
 }
コード例 #18
0
 protected abstract bool HandleStateRaw(SlackState slackState);
コード例 #19
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _callbackAction(slackState);

            return true;
        }
コード例 #20
0
 protected override bool HandleStateRaw(SlackState slackState)
 {
     return(true);
 }
コード例 #21
0
        private void UpdateState(SlackState state)
        {
            _lastSlackState = state;

            _processorsChain.HandleState(state);
        }
コード例 #22
0
 public void HandleState(SlackState slackState)
 {
     HandleState(slackState, skipMyself: false);
 }
コード例 #23
0
 public void HandleState(SlackState slackState)
 {
     HandleState(slackState, skipMyself: false);
 }
コード例 #24
0
 private void UpdateState(SlackState state)
 {
     _lastSlackState = state;
     _processorsChain.HandleState(state);
 }
コード例 #25
0
 protected abstract bool HandleStateRaw(SlackState slackState);
コード例 #26
0
 protected void NextHandleState(SlackState slackState)
 {
     HandleState(slackState, skipMyself: true);            
 }
コード例 #27
0
        protected override bool HandleStateRaw(SlackState slackState)
        {
            _callbackAction(slackState);

            return(true);
        }
コード例 #28
0
 protected void NextHandleState(SlackState slackState)
 {
     HandleState(slackState, skipMyself: true);
 }