public MonitorItem ChannelExist(string channel) { MonitorItem item = null; foreach (MonitorItem mi in listChannels) { if (mi.Channel.Equals(channel)) { item = mi; } } return(item); }
private void OnEnableMonitor_Click(object sender, EventArgs e) { //get the current selected item for the popup menu cMonitor newChan = new cMonitor(ServerTreeCurrentConnection, StripColorCodes(ServerTreeCurrentTab)); bool mEnabled = false; if (((ToolStripMenuItem)sender).CheckState == CheckState.Checked) { //remove the channel from being monitored if (monitoredChannels.IndexOf(newChan) > -1) { monitoredChannels.Remove(newChan); AddMonitorMessage(newChan.channel, "Stopped Monitoring channel:" + monitoredChannels.Count, false, ServerTreeCurrentConnection.ServerSetting.ID); } ((ToolStripMenuItem)sender).CheckState = CheckState.Unchecked; } else { //add the channel for monitoring if (monitoredChannels.IndexOf(newChan) == -1) { monitoredChannels.Add(newChan); AddMonitorMessage(newChan.channel, "Started Monitoring channel:" + monitoredChannels.Count, false, ServerTreeCurrentConnection.ServerSetting.ID); } ((ToolStripMenuItem)sender).CheckState = CheckState.Checked; mEnabled = true; } //save this setting in an XML file if (monitorChannels.ChannelExist(newChan.channel) != null) { monitorChannels.UpdateChannel(newChan.channel, mEnabled); } else { MonitorItem c = new MonitorItem { Channel = newChan.channel, Enabled = mEnabled }; monitorChannels.AddChannel(c); } SaveSettings(); }
public override PluginArgs ChannelJoin(PluginArgs args) { if (args.Nick == args.Connection.ServerSetting.NickName) { //add the channel to the list //check if this channel is on Monitor settings bool disabled = false; if (monitorChannels.ChannelExist(args.Channel) != null) { if (monitorChannels.ChannelExist(args.Channel).Enabled == false) { disabled = true; } } if (disabled == false) { cMonitor newChan = new cMonitor(args.Connection, StripColorCodes(args.Channel)); monitoredChannels.Add(newChan); AddMonitorMessage(args.Channel, "Started Monitoring channel:" + monitoredChannels.Count, false, args.Connection.ServerSetting.ID); } if (monitorChannels.ChannelExist(args.Channel) != null) { monitorChannels.UpdateChannel(args.Channel, !disabled); } else { MonitorItem c = new MonitorItem { Channel = args.Channel, Enabled = !disabled }; monitorChannels.AddChannel(c); } SaveSettings(); } return(args); }
public void AddChannel(MonitorItem item) { listChannels.Add(item); }