Beispiel #1
0
        private void SaveMessagesCheckbox_Unchecked(object sender, RoutedEventArgs e)
        {
            GuildObj guild = Guilds.FirstOrDefault(x => x.TextChannels.FirstOrDefault(y => y.Channel.Name == selectedChannel) != null);

            if (guild == null)
            {
                return;
            }
            ChannelObj channel = guild.TextChannels.FirstOrDefault(x => x.Channel.Name == selectedChannel);

            channel.SaveMessages    = (bool)SaveMessagesCheckbox.IsChecked;
            Client.MessageReceived -= channel.Client_MessageReceived;
        }
Beispiel #2
0
        private void ChannelNames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MessagesTab.Items.Clear();
            ListBox box     = (ListBox)sender;
            string  content = (string)box.SelectedItem;

            Console.WriteLine("Content: " + content);
            selectedChannel = content;
            GuildObj guild = Guilds.FirstOrDefault(x => x.TextChannels.FirstOrDefault(y => y.Channel.Name == content) != null);

            if (guild == null)
            {
                return;
            }
            SaveMessagesCheckbox.Visibility = Visibility.Visible;
            ChannelObj channel = guild.TextChannels.FirstOrDefault(x => x.Channel.Name == content);

            UpdateMessageList(channel, true);
            SaveMessagesCheckbox.IsChecked = channel.SaveMessages;
        }
Beispiel #3
0
        public void UpdateMessageList(ChannelObj obj, bool reset = false)
        {
            if (reset)
            {
                MessagesTab.Items.Clear();
            }

            foreach (MessageObj msg in obj.Messages)
            {
                //foreach (object o in MessagesTab.Items) strings.Add((string)o);
                if (MessagesTab.Items.Contains(msg.ToString()))
                {
                    continue;
                }
                if (selectedChannel != obj.Channel.Name)
                {
                    return;
                }
                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() => MessagesTab.Items.Add(msg.ToString())));
            }
        }