Beispiel #1
0
        private void ChannelModeHandler(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            ChannelMode       mode = item.Tag as ChannelMode;

            switch (mode.Letter)
            {
            case 'b':
                bans.Clear();
                ChannelMode("+b");
                break;

            case 'e':
                exempts.Clear();
                ChannelMode("+e");
                break;

            case 'I':
                invite.Clear();
                ChannelMode("+I");
                break;

            case 'k':
                if (!item.Checked)
                {
                    StringEnterDialog diag = new StringEnterDialog(Resources.SetPassword);
                    if (diag.ShowDialog() == DialogResult.OK && diag.PrintedText.Length > 0)
                    {
                        ChannelMode("+k", diag.PrintedText);
                    }
                }
                else
                {
                    ChannelMode("-k", this.password);
                }
                break;

            case 'l':
                if (!item.Checked)
                {
                    InputNumDialog diag = new InputNumDialog(Resources.EnterLimit);
                    if (diag.ShowDialog() == DialogResult.OK && diag.Value > 0)
                    {
                        ChannelMode("+l", diag.Value.ToString());
                    }
                }
                else
                {
                    ChannelMode("-l");
                }
                break;

            default:
                ChannelMode((!item.Checked ? "+" : "-") + mode.Letter);
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Установлен режим канала
        /// </summary>
        /// <param name="p">Режимы</param>
        protected internal void Mode(string name, string p, params string[] param)
        {
            if (p.Length < 2)
            {
                return;
            }
            bool add      = p[0] == '+';
            int  paramInd = 0;

            for (int i = 1; i < p.Length; i++)
            {
                if (p[i] == '+')
                {
                    add = true;
                    continue;
                }
                else if (p[i] == '-')
                {
                    add = false;
                    continue;
                }

                switch (p[i])
                {
                case 'b':
                    break;

                case 'e':
                    break;

                case 'I':
                    break;

                case 'h':
                    goto case 'v';

                case 'k':
                    if (paramInd < param.Length)
                    {
                        password = param[paramInd++];
                    }
                    goto default;

                case 'l':
                    if (add && paramInd < param.Length)
                    {
                        limit = int.Parse(param[paramInd++]);
                    }
                    goto default;

                case 'o':
                    goto case 'v';

                case 'v':
                    string person = param[paramInd++];
                    lock (this.channelUsers.SyncRoot)
                    {
                        int ind = this.channelUsers.FindIndex(cu => cu.NickName == person);
                        if (ind > -1)
                        {
                            this.channelUsers[ind].SetMode(MDIChildServer.ModesTable2[p[i]], add);
                            if (person == this.ServerWindow.Nick)
                            {
                                this.tSMIchannelModes.Enabled          = this.channelUsers[ind].Modes.ContainsKey('@') && this.channelUsers[ind].Modes['@'];
                                this.tSMIchannelModes.DropDown.Enabled = this.tSMIchannelModes.Enabled;
                            }
                            SortUsersList();
                        }
                    }
                    break;

                default:
                    if (!modes.ContainsKey(p[i]))
                    {
                        modes[p[i]] = new ChannelMode(p[i], string.Empty, null, null);
                    }
                    modes[p[i]].Set = add;
                    break;
                }
            }
            UpdateTitle();
            PutMessage(String.Format("{0} {1} {2} {3}", name, Resources.SetsMode, p, string.Join(" ", param)), settings.Colors[3]);
            if (ChannelModesChanged != null)
            {
                ChannelModesChanged(this, new EventArgs());
            }
        }
Beispiel #3
0
        public MDIChildChannel(MDIParent main, MDIChildServer mainWindow, Channel channel, Dictionary <string, UserInfo> whois)
            : base(main, mainWindow, channel.Name, whois)
        {
            InitializeComponent();

            this.channel = channel;

            this.Size = UISettings.Default.IRCWindowSize;

            this.dgvUsers.ContextMenuStrip = new IRCContextMenuStrip();

            this.dgvUsers.ContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.tSMICtcp,
                this.toolStripMenuItem6,
                this.tsmiHalfOp,
                this.toolStripMenuItem9,
                this.toolStripSeparator2,
                this.tsmiCall,
                this.tsmiInvite,
                this.toolStripSeparator3,
                this.toolStripMenuItem13,
                this.tSMIBan,
                this.tsmiKickAndBan
            });

            this.dgvUsers.ContextMenuStrip.Opened += (sender, e) => NeedUpdateWhois = false;

            this.winName = this.Channel.Name;
            this.Text    = this.Channel.Name + " [0] []";

            this.MyCmd += new CmdDel(MDIChildChannel_MyCmd);

            this.contextMenuStripChat.Items.Add(new ToolStripSeparator());
            this.tSMIchannelModes = new ToolStripMenuItem(Resources.ChannelModes);
            this.contextMenuStripChat.Items.Add(tSMIchannelModes);

            modes['m'] = new ChannelMode('m', Resources.ModeM, ChannelModeHandler, tSMIchannelModes);
            tSMIchannelModes.DropDownItems.Add(new ToolStripSeparator());
            modes['i'] = new ChannelMode('i', Resources.ModeI, ChannelModeHandler, tSMIchannelModes);
            modes['k'] = new ChannelMode('k', Resources.ModeK, ChannelModeHandler, tSMIchannelModes);
            modes['l'] = new ChannelMode('l', Resources.ModeL, ChannelModeHandler, tSMIchannelModes);
            tSMIchannelModes.DropDownItems.Add(new ToolStripSeparator());
            modes['b'] = new ChannelMode('b', Resources.ModeB, ChannelModeHandler, tSMIchannelModes);
            modes['e'] = new ChannelMode('e', Resources.ModeE, ChannelModeHandler, tSMIchannelModes);
            modes['I'] = new ChannelMode('I', Resources.ModeBigI, ChannelModeHandler, tSMIchannelModes);
            tSMIchannelModes.DropDownItems.Add(new ToolStripSeparator());
            modes['t'] = new ChannelMode('t', Resources.ModeT, ChannelModeHandler, tSMIchannelModes);
            modes['n'] = new ChannelMode('n', Resources.ModeN, ChannelModeHandler, tSMIchannelModes);
            modes['c'] = new ChannelMode('c', Resources.ModeC, ChannelModeHandler, tSMIchannelModes);
            modes['c'] = new ChannelMode('S', Resources.ModeBigS, ChannelModeHandler, tSMIchannelModes);
            tSMIchannelModes.DropDownItems.Add(new ToolStripSeparator());
            modes['p'] = new ChannelMode('p', Resources.ModeP, ChannelModeHandler, tSMIchannelModes);
            modes['s'] = new ChannelMode('s', Resources.ModeS, ChannelModeHandler, tSMIchannelModes);
            modes['a'] = new ChannelMode('a', Resources.ModeA, ChannelModeHandler, tSMIchannelModes);

            this.dgvUsers.CellMouseDoubleClick += dgvUsers_CellMouseDoubleClick;
            this.dgvUsers.CellMouseEnter       += dgvUsers_CellMouseEnter;
            this.dgvUsers.CellMouseLeave       += (sender, e) => { currentRow = -1; NeedUpdateWhois = false; };
            this.dgvUsers.MouseLeave           += (sender, e) => { currentRow = -1; NeedUpdateWhois = false; this.userInfoToolTip1.Hide(this.dgvUsers); };

            this.tsmiStick.Checked    = this.Channel.Sticked;
            this.tsmiAutoOpen.Checked = this.Channel.AutoOpen;

            this.tsmiStick.CheckedChanged += (sender, e) =>
            {
                this.Channel.Sticked = this.tsmiStick.Checked;
                if (this.Channel.Sticked)
                {
                    this.ServerWindow.Server.Sticked = true;
                }
            };

            this.tsmiAutoOpen.CheckedChanged += (sender, e) => this.Channel.AutoOpen = this.tsmiAutoOpen.Checked;

            this.Channel.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == "Sticked")
                {
                    this.tsmiStick.Checked = this.Channel.Sticked;
                    this.myNode.Sticked    = this.Channel.Sticked;
                    if (this.Channel.Sticked)
                    {
                        this.MyNode.Tag = this.Channel;
                    }
                }
            };
        }