Пример #1
0
        internal void ShowPurgeDialog(string text, int duration)
        {
            var topmost = OnTop;

            try
            {
                if (topmost)
                    OnTop = false;

                var win = new PurgeWindow(this, text, duration);
                win.OnTop = topmost;

                bool result = win.ShowDialog() ?? false;
                if (!result)
                    return;

                text = win.Text;

                if (!int.TryParse(win.DurationText, out duration) || duration < 1)
                    duration = 1;

                if (string.IsNullOrWhiteSpace(text))
                    return;

                var channel = m_channel;
                var users = (from item in Messages
                             where channel == item.Channel && item.User != null && !item.User.IsModerator
                             let msg = item as ChatMessage
                             where msg != null && msg.Message.IsWildcardMatch(text)
                             group msg by msg.User into g
                             select g.Key).ToArray();

                if (users.Length == 0)
                {
                    AddItem(new StatusMessage(null, this, string.Format("No match for '{0}' in recent non-moderator messages.", text)));
                    return;
                }

                var choice = MessageBoxResult.Yes;
                if (win.Ban && ConfirmBans)
                    choice = MessageBox.Show("Are you sure you want to ban the following users?\n" + string.Join("\n", users.Select(p => p.Name)), "Ban Users", MessageBoxButton.YesNo);
                else if (duration > 1 && ConfirmTimeouts)
                    choice = MessageBox.Show(string.Format("Are you sure you want to give a {0} second timeout to the following users?\n{1}", duration, string.Join("\n", users.Select(p => p.Name))), "Timeout Users", MessageBoxButton.YesNo);

                if (choice != MessageBoxResult.Yes)
                    return;

                Debug.Assert(duration != -1);
                if (win.Ban)
                    duration = -1;

                TimeoutUserList(duration, channel, users);
            }
            finally
            {
                if (topmost)
                    OnTop = true;
            }
        }
Пример #2
0
        internal void ShowPurgeDialog(string text, int duration)
        {
            var topmost = OnTop;

            try
            {
                if (topmost)
                {
                    OnTop = false;
                }

                var win = new PurgeWindow(this, text, duration);
                win.OnTop = topmost;

                bool result = win.ShowDialog() ?? false;
                if (!result)
                {
                    return;
                }

                text = win.Text;

                if (!int.TryParse(win.DurationText, out duration) || duration < 1)
                {
                    duration = 1;
                }

                if (string.IsNullOrWhiteSpace(text))
                {
                    return;
                }

                var channel = m_channel;
                var users   = (from item in Messages
                               where channel == item.Channel && item.User != null && !item.User.IsModerator
                               let msg = item as ChatMessage
                                         where msg != null && msg.Message.IsWildcardMatch(text)
                                         group msg by msg.User into g
                                         select g.Key).ToArray();

                if (users.Length == 0)
                {
                    AddItem(new StatusMessage(null, this, string.Format("No match for '{0}' in recent non-moderator messages.", text)));
                    return;
                }

                var choice = MessageBoxResult.Yes;
                if (win.Ban && ConfirmBans)
                {
                    choice = MessageBox.Show("Are you sure you want to ban the following users?\n" + string.Join("\n", users.Select(p => p.Name)), "Ban Users", MessageBoxButton.YesNo);
                }
                else if (duration > 1 && ConfirmTimeouts)
                {
                    choice = MessageBox.Show(string.Format("Are you sure you want to give a {0} second timeout to the following users?\n{1}", duration, string.Join("\n", users.Select(p => p.Name))), "Timeout Users", MessageBoxButton.YesNo);
                }

                if (choice != MessageBoxResult.Yes)
                {
                    return;
                }

                Debug.Assert(duration != -1);
                if (win.Ban)
                {
                    duration = -1;
                }

                TimeoutUserList(duration, channel, users);
            }
            finally
            {
                if (topmost)
                {
                    OnTop = true;
                }
            }
        }