Esempio n. 1
0
        private void UserDMBtn_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            if (btn.Tag == null)
            {
                return;
            }

            if (btn.Tag is SocketDMChannel)
            {
                SocketDMChannel c = btn.Tag as SocketDMChannel;

                DMUserEntry etry = new DMUserEntry();
                etry.Channel = c;
                etry.UpdateMe();

                var body = new DirectMsgsContents.DirectMessagesSidebarContent();
                App.MainWnd.Sidebar.Set(new DirectMsgsContents.SidebarHeaderSerach(), body);
                body.Select(etry);
            }

            if (btn.Tag is SocketGroupChannel)
            {
                SocketGroupChannel c = btn.Tag as SocketGroupChannel;

                DMUserEntry etry = new DMUserEntry();
                etry.Channel = c;
                etry.UpdateMe();

                var body = new DirectMsgsContents.DirectMessagesSidebarContent();
                App.MainWnd.Sidebar.Set(new DirectMsgsContents.SidebarHeaderSerach(), body);
                body.Select(etry);
            }
        }
Esempio n. 2
0
        public void AddGroupDM(SocketGroupChannel u)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(() => AddGroupDM(u));
                return;
            }

            Grid g = new Grid();

            g.Margin = new Thickness(4);

            TextBlock i = new TextBlock();

            i.Text = "Group " + u.Name;
            g.Children.Add(i);
            i.HorizontalAlignment = HorizontalAlignment.Left;
            i.VerticalAlignment   = VerticalAlignment.Center;
            i.Margin = new Thickness(4);

            var UserDMBtn = GetContainer(g);

            UserDMBtn.Click += UserDMBtn_Click;
            UserDMBtn.Tag    = u;
            Add(UserDMBtn);
        }
Esempio n. 3
0
        public void UpdateMessages()
        {
            new Thread(() =>
            {
                const int HowManyMessagesDownload = 25;

                if (Channel != null)
                {
                    if (Channel is SocketDMChannel)
                    {
                        SocketDMChannel c = (SocketDMChannel)Channel;

                        var msgs  = c.GetMessagesAsync(HowManyMessagesDownload).ToList();
                        var reslt = msgs.GetAwaiter().GetResult()[1];

                        UpdateMessagesEx(reslt.ToArray());
                    }
                    else if (Channel is SocketGroupChannel)
                    {
                        SocketGroupChannel c = (SocketGroupChannel)Channel;

                        var msgs  = c.GetMessagesAsync(HowManyMessagesDownload).ToList();
                        var reslt = msgs.GetAwaiter().GetResult()[1];

                        UpdateMessagesEx(reslt.ToArray());
                    }
                    else if (Channel is SocketTextChannel)
                    {
                        SocketTextChannel c = (SocketTextChannel)Channel;

                        var msgs  = c.GetMessagesAsync(HowManyMessagesDownload).ToList();
                        var reslt = msgs.GetAwaiter().GetResult()[1];

                        UpdateMessagesEx(reslt.ToArray());
                    }
                    else if (Channel is SocketChannel)
                    {
                        SocketTextChannel c = (SocketTextChannel)Channel;

                        var msgs  = c.GetMessagesAsync(HowManyMessagesDownload).ToList();
                        var reslt = msgs.GetAwaiter().GetResult()[1];

                        UpdateMessagesEx(reslt.ToArray());
                    }
                }

                if (DmBotChannel != null)
                {
                    var msgs   = DmBotChannel.GetMessagesAsync(HowManyMessagesDownload).ToList();
                    var reslt1 = msgs.GetAwaiter().GetResult();
                    var reslt  = reslt1[0];

                    UpdateMessagesEx(reslt.ToArray());
                }
            }).Start();
        }
Esempio n. 4
0
        /*
         * Send Tag Change Object To Channel Method
         *
         * Purpose:
         * Parses the TagChange data received and sends a message to the channel provided
         *
         */
        public async void SendTagChangeToChannel(List <TagChange> TagChanges, SocketGroupChannel chan)
        {
            string message = "```", tempMessage = "";

            foreach (var tagChange in TagChanges)
            {
                string fromTag, toTag;
                if (tagChange.FromTag == "" || tagChange.FromTag == null)
                {
                    fromTag = "Untagged";
                }
                else
                {
                    fromTag = tagChange.FromTag;
                }
                if (tagChange.ToTag == "" || tagChange.ToTag == null)
                {
                    toTag = "Untagged";
                }
                else
                {
                    toTag = tagChange.ToTag;
                }
                tempMessage += "Country (#" + tagChange.Number + ") - Was detected changing from [" + fromTag + "] to [" + toTag + "].";
                if ((message.Length + tempMessage.Length + Environment.NewLine.Length) < 2000)
                {
                    message += tempMessage + Environment.NewLine;
                }
                else
                {
                    await chan.SendMessageAsync(message + "```");

                    message  = "```";
                    message += tempMessage + Environment.NewLine;
                }
            }
            await chan.SendMessageAsync(message + "```");
        }