Esempio n. 1
0
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            tabControl.Items.Add(new TabItem {
                Header = "All", Name = "All", IsSelected = true
            });
            foreach (Scopes scope in Enum.GetValues(typeof(Scopes)))
            {
                tabControl.Items.Add(new TabItem
                {
                    Header     = scope.ToString(),
                    Name       = scope.ToString(),
                    Visibility = Visibility.Collapsed,
                    Background = null
                });
            }

            foreach (TabItem tab in tabControl.Items)
            {
                tab.Content = new RichTextBox
                {
                    Name = tab.Name,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                    Background = null,
                    IsReadOnly = true,
                };
            }

            var timer = new DispatcherTimer();

            timer.Tick += (s, ev) =>
            {
                var clients = ElementClient.GetClients();
                clientSelect.Items.Clear();
                clients.ForEach(ec => clientSelect.Items.Add(new ListBoxItem {
                    Content = ec.Nickname, Tag = ec.Pid
                }));
            };
            timer.Interval = TimeSpan.FromMilliseconds(5000);
            timer.Start();

            _pw             = new PW(ElementClient.GetClients()[0]);
            _pw.NewMessage += cm => tabControl.Dispatcher.Invoke(new Action(() =>
            {
                var filters = filter.Text.Split(' ').WhereNot(s => s.Empty());
                if (filters.Empty() || filters.Any(s => cm.Text.ContainsCi(s)))
                {
                    TabByName(cm.Scope.ToString()).Visibility = Visibility.Visible;
                    AddText(cm);
                    _cnt++;
                    if (IsActive)
                    {
                        _cnt = 0;
                    }
                    UpdateIcon();
                }
            }));
        }
Esempio n. 2
0
        private void AttachClick(object sender, RoutedEventArgs e)
        {
            var client = ElementClient.GetClients().Single(ec => ec.Pid == ((ListBoxItem)clientSelect.SelectedItem).Tag.To <int>());

            _pw = new PW(client);

            foreach (TabItem tab in tabControl.Items)
            {
                tab.Visibility = (tab.Name == "All" ? Visibility.Visible : Visibility.Collapsed);
                tab.Content    = new RichTextBox
                {
                    Name = tab.Name,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                    Background = null
                };
            }
        }
Esempio n. 3
0
        public PW(ElementClient client)
        {
            _client = client;

            NewMessage += cm => { };

            _lastMessages = new List <ChatMessage>();
            var timer = new Timer(s =>
            {
                var newMessages = GetMessages();
                foreach (var chatMessage in newMessages.Except(_lastMessages))
                {
                    NewMessage(chatMessage);
                }
                _lastMessages = newMessages;
            });

            timer.Change(500, 500);
        }