Пример #1
0
        // warning: a lot of duplication in GetPrivateMessageContextMenuWpf! change both at once! (temporary solution)

        // warning: a lot of duplication in GetPrivateMessageContextMenuWpf! change both at once!  (temporary solution)
        public static ContextMenu GetPrivateMessageContextMenu(PrivateMessageControl control)
        {
            var contextMenu = new ContextMenu();

            try
            {
                var headerItem = new System.Windows.Forms.MenuItem("Private Channel - " + control.UserName);

                headerItem.Enabled     = false;
                headerItem.DefaultItem = true; //This is to make it appear bold
                contextMenu.MenuItems.Add(headerItem);
                contextMenu.MenuItems.Add("-");

                var details = new System.Windows.Forms.MenuItem("Details");
                details.Click += (s, e) => NavigationControl.Instance.Path = "http://zero-k.info/Users/LobbyDetail/" + control.UserName;
                contextMenu.MenuItems.Add(details);

                if (Program.FriendManager.Friends.Contains(control.UserName))
                {
                    var pinItem = new System.Windows.Forms.MenuItem("Unfriend");
                    pinItem.Click += (s, e) => Program.FriendManager.RemoveFriend(control.UserName);
                    contextMenu.MenuItems.Add(pinItem);
                }
                else
                {
                    var pinItem = new System.Windows.Forms.MenuItem("Friend");
                    pinItem.Click += (s, e) => Program.FriendManager.AddFriend(control.UserName);
                    contextMenu.MenuItems.Add(pinItem);
                }

                var isUserOnline = Program.TasClient.ExistingUsers.ContainsKey(control.UserName);

                var joinItem = new System.Windows.Forms.MenuItem("Join Same Battle");
                joinItem.Enabled = isUserOnline && Program.TasClient.ExistingUsers[control.UserName].IsInBattleRoom;
                joinItem.Click  += (s, e) => ActionHandler.JoinPlayer(control.UserName);
                contextMenu.MenuItems.Add(joinItem);

                var reportUser = new System.Windows.Forms.MenuItem("Report User");
                reportUser.Click += (s, e) => NavigationControl.Instance.Path = "http://zero-k.info/Users/ReportToAdminFromLobby/" + control.UserName;
                contextMenu.MenuItems.Add(reportUser);

                contextMenu.MenuItems.Add("-");

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

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

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

                if (control.CanClose)
                {
                    var closeItem = new System.Windows.Forms.MenuItem("Close");
                    closeItem.Click += (s, e) => ActionHandler.CloseChannel(control.UserName);
                    contextMenu.MenuItems.Add(closeItem);
                }

                contextMenu.MenuItems.Add("-");
                MenuItem textColoringMenu = new System.Windows.Forms.MenuItem("Compose a colored text");
                textColoringMenu.Click += (s, e) => { ActionHandler.ShowColoringPanel(control.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);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Error generating channel context menu: " + e);
            }

            return(contextMenu);
        }
Пример #2
0
        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);
        }