/// <summary> /// Creates a new channel and tab. /// </summary> /// <param name="displayName">The name of the channel.</param> /// <param name="switchTo">A value indicating whether or not to switch to the new channel.</param> /// <returns>The new channel.</returns> public IRCChannel CreateChannel(string displayName, bool switchTo) { IRCChannel retval = new IRCChannel(this, this.Connection); retval.Disposed += new IRCChannel.DisposedHandler(this.ChannelDisposed); IRCTabType type = IRCTabType.Channel; Regex regex = new Regex(@"(?<channel>[#&][^\x07\x2C\s]{1,199})", RegexOptions.IgnoreCase); if (!regex.Match(displayName).Success) { type = IRCTabType.PM; } this.TabHost.InvokeAction(() => { string tabName = string.Format("{0}_{1}", this.Connection.ToString(), displayName); IRCTabPage tabPage = new IRCTabPage(this.ServerTab.OwningForm, tabName, displayName, type); tabPage.Connection = this.Connection; tabPage.ConnectionSpecificName = displayName; retval.TabPage = tabPage; retval.TabPage.Marshal = this; retval.Name = displayName; // Iterate through the tab pages to figure out how to place // this channels tab page in a group of other ones on the // same network, in alphabetical order. int index = this.TabHost.TabPages.IndexOf(this.ServerTab) + 1; for (int i = index; i < this.TabHost.TabPages.Count; i++) { IRCTabPage tab = this.TabHost.TabPages[i] as IRCTabPage; if (tab != null && tab.Marshal == this && tab.Text.CompareTo(retval.TabPage.Text) < 0) { index = i + 1; } else if (tab != null && tab.Marshal != this) { break; } } this.TabHost.TabPages.Insert(index, tabPage); if (switchTo) { this.TabHost.SelectedTab = tabPage; } }); this.Channels.Add(retval); if (this.channelCreated != null) { this.channelCreated.Invoke(this, retval); } return retval; }
/// <summary> /// Initialises a new instance of the <see cref="IRCTabPage"/> class. /// </summary> /// <param name="owningForm">The form that the tab page is displayed on.</param> /// <param name="name">The name of the tab page.</param> /// <param name="text">The text to display in the caption.</param> /// <param name="type">The type of IRC entity being represented.</param> public IRCTabPage(MainForm owningForm, string name, string text, IRCTabType type) : base(text) { this.initialising = true; GlobalSettings settings = GlobalSettings.Instance; this.owningForm = owningForm; this.adminGroupExpanded = true; this.founderGroupExpanded = true; this.halfOperatorGroupExpanded = true; this.operatorGroupExpanded = true; this.voiceGroupExpanded = true; this.normalGroupExpanded = true; this.MessageQueue = new Queue <Action>(); this.Name = name; this.type = type; this.ConnectionSpecificName = string.Empty; this.groupingByMode = settings.GroupUsersByMode == GlobalSettings.Boolean.Yes; switch (type) { case IRCTabType.Console: this.normalImageIndex = 0; break; case IRCTabType.Server: this.normalImageIndex = 1; break; case IRCTabType.Channel: this.normalImageIndex = 2; break; case IRCTabType.PM: this.normalImageIndex = 3; break; } this.ImageIndex = this.NormalImageIndex; this.Initialise(); }
/// <summary> /// Initialises a new instance of the <see cref="IRCTabPage"/> class. /// </summary> /// <param name="owningForm">The form that the tab page is displayed on.</param> /// <param name="name">The name of the tab page.</param> /// <param name="text">The text to display in the caption.</param> /// <param name="type">The type of IRC entity being represented.</param> public IRCTabPage(MainForm owningForm, string name, string text, IRCTabType type) : base(text) { this.initialising = true; GlobalSettings settings = GlobalSettings.Instance; this.owningForm = owningForm; this.adminGroupExpanded = true; this.founderGroupExpanded = true; this.halfOperatorGroupExpanded = true; this.operatorGroupExpanded = true; this.voiceGroupExpanded = true; this.normalGroupExpanded = true; this.MessageQueue = new Queue<Action>(); this.Name = name; this.type = type; this.ConnectionSpecificName = string.Empty; this.groupingByMode = settings.GroupUsersByMode == GlobalSettings.Boolean.Yes; switch (type) { case IRCTabType.Console: this.normalImageIndex = 0; break; case IRCTabType.Server: this.normalImageIndex = 1; break; case IRCTabType.Channel: this.normalImageIndex = 2; break; case IRCTabType.PM: this.normalImageIndex = 3; break; } this.ImageIndex = this.NormalImageIndex; this.Initialise(); }