示例#1
0
        ChatControl CreateChannelControl(string channelName)
        {
            if (IsIgnoredChannel(channelName))
            {
                return(null);
            }
            var existing = GetChannelControl(channelName);

            if (existing != null)
            {
                return(existing);
            }
            var chatControl = new ChatControl(channelName)
            {
                Dock = DockStyle.Fill
            };
            var gameInfo = KnownGames.List.FirstOrDefault(x => x.Channel == channelName);

            if (gameInfo != null)
            {
                toolTabs.AddTab(channelName, gameInfo.FullName, chatControl, ZklResources.game, null, 2);
            }
            else
            {
                toolTabs.AddTab(channelName, channelName, chatControl, ZklResources.chat, null, 1);
            }
            chatControl.ChatLine += (s, e) => Program.TasClient.Say(TasClient.SayPlace.Channel, channelName, e.Data, false);
            return(chatControl);
        }
        public TextColoringPanel(SendBox currentSendbox)
        {
            timedUpdate.Interval = 50; //timer tick to add micro delay to ChatBox preview update.
            timedUpdate.Tick    += timedUpdate_Tick;
            InitializeComponent();
            Icon = ZklResources.ZkIcon;
            button1.BackColor  = TextColor.GetColor(0);  //white
            button2.BackColor  = TextColor.GetColor(1);  //black
            button3.BackColor  = TextColor.GetColor(2);  //blue
            button4.BackColor  = TextColor.GetColor(3);  //green
            button5.BackColor  = TextColor.GetColor(4);  //red
            button6.BackColor  = TextColor.GetColor(5);  //brown
            button7.BackColor  = TextColor.GetColor(6);  //purple
            button8.BackColor  = TextColor.GetColor(7);  //orange
            button9.BackColor  = TextColor.GetColor(8);  //yellow
            button10.BackColor = TextColor.GetColor(9);  //light green
            button11.BackColor = TextColor.GetColor(10); //teal
            button12.BackColor = TextColor.GetColor(11);
            button13.BackColor = TextColor.GetColor(12);
            button14.BackColor = TextColor.GetColor(13);
            button15.BackColor = TextColor.GetColor(14);
            button16.BackColor = TextColor.GetColor(15);
            if (sendBox.TextBox.SelectionLength <= 1)
            {
                sendBox.TextBox.SelectionStart = 0;
            }
            comboBox1.SelectedItem   = "To-line-end";
            ignoreSpaceCheck.Checked = true;

            sendBox.dontSendTextOnEnter     = true; //pressing enter wont send text
            sendBox.TextBox.ScrollBars      = ScrollBars.Vertical;
            sendBox.dontUseUpDownHistoryKey = true;
            sendBox.CompleteWord           += (word) => //autocomplete of username
            {
                var w = word.ToLower();
                IEnumerable <string> firstResult = new string[1];
                ChatControl          zkChatArea  = Program.MainWindow.navigationControl.ChatTab.GetChannelControl("zk");
                if (zkChatArea != null)
                {
                    IEnumerable <string> extraResult = zkChatArea.playerBox.GetUserNames()
                                                       .Where(x => x.ToLower().StartsWith(w))
                                                       .Union(zkChatArea.playerBox.GetUserNames().Where(x => x.ToLower().Contains(w)));
                    firstResult = firstResult.Concat(extraResult);
                }
                return(firstResult);
            };
            sendBox.TextBox.WordWrap = true;
            sendBox.Text             = currentSendbox.Text; //copy paste from chat area to coloring panel
            currentSendbox_          = currentSendbox;
            Program.ToolTip.SetText(sendBox, "Tips: press CTRL+R/G/B on chatbox for instant Red,Green or Blue coloring");
        }
示例#3
0
        public PrivateMessageControl(string name)
        {
            InitializeComponent();
            ChatBox.Font                 = Program.Conf.ChatFont;
            Name                         = name;
            UserName                     = name;
            ChatBox.MouseUp             += autoscrollRichTextBox1_MouseUp;
            ChatBox.FocusInputRequested += (s, e) => GoToSendBox();
            ChatBox.ChatBackgroundColor  = TextColor.background; //same as Program.Conf.BgColor but TextWindow.cs need this.
            ChatBox.IRCForeColor         = 14;                   //mirc grey. Unknown use

            HistoryManager.InsertLastLines(UserName, ChatBox);

            VisibleChanged += PrivateMessageControl_VisibleChanged;
            Program.TasClient.BattleUserJoined += TasClient_BattleUserJoined;
            Program.TasClient.UserAdded        += TasClient_UserAdded;
            Program.TasClient.UserRemoved      += TasClient_UserRemoved;

            var extras = new BitmapButton();

            extras.Text   = "Extras";
            extras.Click += (s, e) => { ContextMenus.GetPrivateMessageContextMenu(this).Show(extras, new Point(0, 0)); };
            ChatBox.Controls.Add(extras);

            sendBox.CompleteWord += (word) => //autocomplete of username
            {
                var      w           = word.ToLower();
                string[] nameInArray = new string[1] {
                    name
                };
                System.Collections.Generic.IEnumerable <string> firstResult = nameInArray
                                                                              .Where(x => x.ToLower().StartsWith(w))
                                                                              .Union(nameInArray.Where(x => x.ToLower().Contains(w)));;
                if (true)
                {
                    ChatControl zkChatArea = Program.MainWindow.navigationControl.ChatTab.GetChannelControl("zk");
                    if (zkChatArea != null)
                    {
                        System.Collections.Generic.IEnumerable <string> extraResult = zkChatArea.playerBox.GetUserNames()
                                                                                      .Where(x => x.ToLower().StartsWith(w))
                                                                                      .Union(zkChatArea.playerBox.GetUserNames().Where(x => x.ToLower().Contains(w)));
                        firstResult = firstResult.Concat(extraResult); //Reference: http://stackoverflow.com/questions/590991/merging-two-ienumerablets
                    }
                }
                return(firstResult);
            };
        }
示例#4
0
        void AddBattleControl()
        {
            if (battleChatControl == null || battleChatControl.IsDisposed)
            {
                battleChatControl = new BattleChatControl {
                    Dock = DockStyle.Fill
                }
            }
            ;
            if (toolTabs.GetChannelTab("Battle") == null)
            {
                toolTabs.AddTab("Battle", "Battle", battleChatControl, ZklResources.battle, "Current battle room", 3);
            }
        }

        ChatControl CreateChannelControl(string channelName)
        {
            if (IsIgnoredChannel(channelName))
            {
                return(null);
            }
            var existing = GetChannelControl(channelName);

            if (existing != null)
            {
                return(existing);
            }
            var chatControl = new ChatControl(channelName)
            {
                Dock = DockStyle.Fill
            };
            var gameInfo = KnownGames.List.FirstOrDefault(x => x.Channel == channelName);

            if (gameInfo != null)
            {
                toolTabs.AddTab(channelName, gameInfo.FullName, chatControl, ZklResources.game, null, 2);
            }
            else
            {
                toolTabs.AddTab(channelName, channelName, chatControl, ZklResources.chat, null, 1);
            }
            chatControl.ChatLine += (s, e) => Program.TasClient.Say(SayPlace.Channel, channelName, e.Data, false);
            return(chatControl);
        }
        ChatControl CreateChannelControl(string channelName)
        {
            if (IsIgnoredChannel(channelName)) return null;
            var existing = GetChannelControl(channelName);
            if (existing != null) return existing;
            var chatControl = new ChatControl(channelName) { Dock = DockStyle.Fill };
            var gameInfo = KnownGames.List.FirstOrDefault(x => x.Channel == channelName);

            if (gameInfo != null) toolTabs.AddTab(channelName, gameInfo.FullName, chatControl, ZklResources.game, null, 2);
            else toolTabs.AddTab(channelName, channelName, chatControl, ZklResources.chat, null, 1);
            chatControl.ChatLine += (s, e) => Program.TasClient.Say(SayPlace.Channel, channelName, e.Data, false);
            return chatControl;
        }
示例#6
0
        public ChatControl(string name)
        {
            InitializeComponent();

            var isDesignMode = Process.GetCurrentProcess().ProcessName == "devenv"; // workaround for this.DesignMode not working in constructor

            if (isDesignMode)
            {
                return;
            }

            var extras = new BitmapButton();

            extras.Text   = "Extras";
            extras.Click += (s, e) => { ContextMenus.GetChannelContextMenu(this).Show(extras, new Point(0, 0)); };
            ChatBox.Controls.Add(extras);

            playerBox.DrawMode     = DrawMode.OwnerDrawVariable;
            playerBox.MeasureItem += (s, e) => { }; // needed for ListBox.OnMeasureItem
            playerBox.BackColor    = Program.Conf.BgColor;
            playerBox.ForeColor    = Program.Conf.TextColor;

            playerSearchBox.BackColor = Program.Conf.BgColor;
            playerSearchBox.ForeColor = Program.Conf.TextColor;

            ChatBox.Font = Program.Conf.ChatFont; //make sure this is done before HistoryManager adds text, or text becomes black.

            Name        = name;
            ChannelName = name;
            if (!DesignMode)
            {
                HistoryManager.InsertLastLines(ChannelName, ChatBox);
            }

            playerBox.Sorted = true;
            var lookingGlass = new PictureBox {
                Width = 20, Height = 20, Image = ZklResources.search, SizeMode = PictureBoxSizeMode.CenterImage
            };

            searchBarContainer.Controls.Add(lookingGlass);
            Program.ToolTip.SetText(lookingGlass, "Enter name or country shortcut to find");

            Program.ToolTip.SetText(playerSearchBox, "Enter name or country shortcut to find");

            VisibleChanged += ChatControl_VisibleChanged;

            ChatBox.MouseUp             += chatBox_MouseUp;
            ChatBox.MouseDown           += chatBox_MouseDown;
            ChatBox.MouseMove           += chatBox_MouseMove;
            ChatBox.FocusInputRequested += (s, e) => GoToSendBox();
            ChatBox.ChatBackgroundColor  = TextColor.background; //same as Program.Conf.BgColor but TextWindow.cs need this.
            ChatBox.IRCForeColor         = 14;                   //mirc grey. Unknown use

            Program.TasClient.ChannelUserAdded   += client_ChannelUserAdded;
            Program.TasClient.ChannelUserRemoved += client_ChannelUserRemoved;
            Program.TasClient.UserStatusChanged  += TasClient_UserStatusChanged;
            Program.TasClient.ChannelUsersAdded  += TasClient_ChannelUsersAdded;
            Program.TasClient.Said                += client_Said;
            Program.TasClient.UserRemoved         += TasClient_UserRemoved;
            Program.TasClient.ChannelTopicChanged += TasClient_ChannelTopicChanged;
            Program.TasClient.HourChime           += client_HourChime;

            Channel channel;

            Program.TasClient.JoinedChannels.TryGetValue(ChannelName, out channel);

            //Topic Box that displays over the channel
            topicBox.IRCForeColor             = 14; //mirc grey. Unknown use
            topicBox.ChatBackgroundColor      = TextColor.topicBackground;
            topicBox.HorizontalScroll.Enabled = true;
            topicBox.BorderStyle            = BorderStyle.FixedSingle;
            topicBox.VerticalScroll.Visible = false;
            topicBox.VerticalScroll.Enabled = false;
            topicBox.AutoSize       = true;
            topicBox.AutoSizeMode   = AutoSizeMode.GrowAndShrink;
            topicBox.HideScroll     = true;
            topicBox.ShowUnreadLine = false;
            topicBox.ShowHistory    = false;

            //hide mappanel for normal chat operation. Overriden in BattleChatControl.cs
            playerListMapSplitContainer.Panel2Collapsed = true;

            sendBox.CompleteWord += (word) => //autocomplete of username
            {
                var w = word.ToLower();
                IEnumerable <string> firstResult = playerBox.GetUserNames()
                                                   .Where(x => x.ToLower().StartsWith(w))
                                                   .Union(playerBox.GetUserNames().Where(x => x.ToLower().Contains(w)));
                if (true)
                {
                    ChatControl zkChatArea = Program.MainWindow.navigationControl.ChatTab.GetChannelControl("zk");
                    if (zkChatArea != null)
                    {
                        IEnumerable <string> extraResult = zkChatArea.playerBox.GetUserNames()
                                                           .Where(x => x.ToLower().StartsWith(w))
                                                           .Union(zkChatArea.playerBox.GetUserNames().Where(x => x.ToLower().Contains(w)));
                        firstResult = firstResult.Concat(extraResult);     //Reference: http://stackoverflow.com/questions/590991/merging-two-ienumerablets
                    }
                }
                return(firstResult);
            };

            if (channel != null)
            {
                foreach (var userName in Program.TasClient.JoinedChannels[ChannelName].ChannelUsers)
                {
                    AddUser(userName);
                }
            }
        }
        public static ContextMenu GetChannelContextMenu(ChatControl chatControl)
        {
            var contextMenu = new ContextMenu();
            try
            {
                var headerItem = new System.Windows.Forms.MenuItem("Channel - " + chatControl.ChannelName) { Enabled = false, DefaultItem = true };

                contextMenu.MenuItems.Add(headerItem);
                contextMenu.MenuItems.Add("-");

                if (!(chatControl is BattleChatControl))
                {
                    var showTopic = new System.Windows.Forms.MenuItem("Show Topic Header") { Checked = chatControl.IsTopicVisible };
                    showTopic.Click += (s, e) =>
                        {
                            chatControl.IsTopicVisible = !chatControl.IsTopicVisible;
                            showTopic.Checked = chatControl.IsTopicVisible;
                        };
                    contextMenu.MenuItems.Add(showTopic);
                }

                if (chatControl.ChannelName != "Battle")
                {
                    var autoJoinItem = new System.Windows.Forms.MenuItem("Automatically Join Channel") { Checked = Program.AutoJoinManager.Channels.Contains(chatControl.ChannelName) };
                    autoJoinItem.Click += (s, e) =>
                        {
                            if (autoJoinItem.Checked) Program.AutoJoinManager.Remove(chatControl.ChannelName);
                            else Program.AutoJoinManager.Add(chatControl.ChannelName);
                            autoJoinItem.Checked = !autoJoinItem.Checked;
                        };
                    contextMenu.MenuItems.Add(autoJoinItem);
                }

                var showJoinLeaveLines = new System.Windows.Forms.MenuItem("Show Join/Leave Lines") { Checked = chatControl.ChatBox.ShowJoinLeave };
                showJoinLeaveLines.Click += (s, e) => chatControl.ChatBox.ShowJoinLeave = !chatControl.ChatBox.ShowJoinLeave;
                contextMenu.MenuItems.Add(showJoinLeaveLines);

                var showHistoryLines = new System.Windows.Forms.MenuItem("Show Recent History") { Checked = chatControl.ChatBox.ShowHistory };
                showHistoryLines.Click += (s, e) => chatControl.ChatBox.ShowHistory = !chatControl.ChatBox.ShowHistory;
                contextMenu.MenuItems.Add(showHistoryLines);

                var historyItem = new System.Windows.Forms.MenuItem("Open History");
                historyItem.Click += (s, e) => HistoryManager.OpenHistory(chatControl.ChannelName);
                contextMenu.MenuItems.Add(historyItem);

                if (chatControl.CanLeave)
                {
                    var leaveItem = new System.Windows.Forms.MenuItem("Leave Channel");
                    leaveItem.Click += (s, e) => Program.TasClient.LeaveChannel(chatControl.ChannelName);
                    contextMenu.MenuItems.Add(leaveItem);
                }
                contextMenu.MenuItems.Add("-");
                MenuItem textColoringMenu = new System.Windows.Forms.MenuItem("Compose a colored text");
                textColoringMenu.Click += (s, e) => { ActionHandler.ShowColoringPanel(chatControl.sendBox); };
                contextMenu.MenuItems.Add(textColoringMenu);
                MenuItem unicodeTranslator = new System.Windows.Forms.MenuItem("Get Unicode symbols");
                unicodeTranslator.Click += (s, e) => { ActionHandler.ShowUnicodeTranslator(); };
                contextMenu.MenuItems.Add(unicodeTranslator);

                if (chatControl is BattleChatControl)
                {
                    contextMenu.MenuItems.Add("-");
                    contextMenu.MenuItems.Add(GetShowGameOptionsItem());
                    contextMenu.MenuItems.Add(GetAddBot());
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error generating channel context menu: " + e);
            }
            return contextMenu;
        }
        public static ContextMenu GetChannelContextMenu(ChatControl chatControl)
        {
            var contextMenu = new ContextMenu();

            try
            {
                var headerItem = new System.Windows.Forms.MenuItem("Channel - " + chatControl.ChannelName)
                {
                    Enabled = false, DefaultItem = true
                };

                contextMenu.MenuItems.Add(headerItem);
                contextMenu.MenuItems.Add("-");

                if (!(chatControl is BattleChatControl))
                {
                    var showTopic = new System.Windows.Forms.MenuItem("Show Topic Header")
                    {
                        Checked = chatControl.IsTopicVisible
                    };
                    showTopic.Click += (s, e) =>
                    {
                        chatControl.IsTopicVisible = !chatControl.IsTopicVisible;
                        showTopic.Checked          = chatControl.IsTopicVisible;
                    };
                    contextMenu.MenuItems.Add(showTopic);
                }

                if (chatControl.ChannelName != "Battle")
                {
                    var autoJoinItem = new System.Windows.Forms.MenuItem("Automatically Join Channel")
                    {
                        Checked = Program.AutoJoinManager.Channels.Contains(chatControl.ChannelName)
                    };
                    autoJoinItem.Click += (s, e) =>
                    {
                        if (autoJoinItem.Checked)
                        {
                            Program.AutoJoinManager.Remove(chatControl.ChannelName);
                        }
                        else
                        {
                            Program.AutoJoinManager.Add(chatControl.ChannelName);
                        }
                        autoJoinItem.Checked = !autoJoinItem.Checked;
                    };
                    contextMenu.MenuItems.Add(autoJoinItem);
                }

                var showJoinLeaveLines = new System.Windows.Forms.MenuItem("Show Join/Leave Lines")
                {
                    Checked = chatControl.ChatBox.ShowJoinLeave
                };
                showJoinLeaveLines.Click += (s, e) => chatControl.ChatBox.ShowJoinLeave = !chatControl.ChatBox.ShowJoinLeave;
                contextMenu.MenuItems.Add(showJoinLeaveLines);

                var showHistoryLines = new System.Windows.Forms.MenuItem("Show Recent History")
                {
                    Checked = chatControl.ChatBox.ShowHistory
                };
                showHistoryLines.Click += (s, e) => chatControl.ChatBox.ShowHistory = !chatControl.ChatBox.ShowHistory;
                contextMenu.MenuItems.Add(showHistoryLines);

                var historyItem = new System.Windows.Forms.MenuItem("Open History");
                historyItem.Click += (s, e) => HistoryManager.OpenHistory(chatControl.ChannelName);
                contextMenu.MenuItems.Add(historyItem);

                if (chatControl.CanLeave)
                {
                    var leaveItem = new System.Windows.Forms.MenuItem("Leave Channel");
                    leaveItem.Click += (s, e) => Program.TasClient.LeaveChannel(chatControl.ChannelName);
                    contextMenu.MenuItems.Add(leaveItem);
                }
                contextMenu.MenuItems.Add("-");
                MenuItem textColoringMenu = new System.Windows.Forms.MenuItem("Compose a colored text");
                textColoringMenu.Click += (s, e) => { ActionHandler.ShowColoringPanel(chatControl.sendBox); };
                contextMenu.MenuItems.Add(textColoringMenu);
                MenuItem unicodeTranslator = new System.Windows.Forms.MenuItem("Get Unicode symbols");
                unicodeTranslator.Click += (s, e) => { ActionHandler.ShowUnicodeTranslator(); };
                contextMenu.MenuItems.Add(unicodeTranslator);

                if (chatControl is BattleChatControl)
                {
                    contextMenu.MenuItems.Add("-");
                    contextMenu.MenuItems.Add(GetShowOptions());
                    contextMenu.MenuItems.Add(GetAddBotItem());
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error generating channel context menu: " + e);
            }
            return(contextMenu);
        }