\r
namespace Radegast\r
{\r
+ /// <summary>\r
+ /// Arguments for tab events\r
+ /// </summary>\r
+ public class TabEventArgs : EventArgs\r
+ {\r
+ /// <summary>\r
+ /// Tab that was manipulated in the event\r
+ /// </summary>\r
+ public SleekTab Tab;\r
+\r
+ public TabEventArgs()\r
+ : base()\r
+ {\r
+ }\r
+ \r
+ public TabEventArgs(SleekTab tab)\r
+ :base()\r
+ {\r
+ Tab = tab;\r
+ }\r
+ }\r
+\r
public partial class TabsConsole : UserControl\r
{\r
+ /// <summary>\r
+ /// Delegate inviked on tab operations\r
+ /// </summary>\r
+ /// <param name="sender">Event sender</param>\r
+ /// <param name="e">Event arguments</param>\r
+ public delegate void TabCallback(object sender, TabEventArgs e);\r
+\r
+ /// <summary>\r
+ /// Fired when a tab is selected\r
+ /// </summary>\r
+ public event TabCallback OnTabSelected;\r
+\r
+ /// <summary>\r
+ /// Fired when a new tab is added\r
+ /// </summary>\r
+ public event TabCallback OnTabAdded;\r
+\r
+ /// <summary>\r
+ /// Fired when a tab is removed\r
+ /// </summary>\r
+ public event TabCallback OnTabRemoved;\r
+\r
private RadegastInstance instance;\r
private GridClient client { get { return instance.Client; } }\r
private RadegastNetcom netcom { get { return instance.Netcom; } }\r
private ChatConsole chatConsole;\r
\r
private SleekTab selectedTab;\r
+\r
+ /// <summary>\r
+ /// Currently selected tab\r
+ /// </summary>\r
public SleekTab SelectedTab\r
{\r
get\r
button.Click += new EventHandler(TabButtonClick);\r
tab.Button = button;\r
tabs.Add(tab.Name, tab);\r
+\r
+ if (OnTabAdded != null)\r
+ {\r
+ try { OnTabAdded(this, new TabEventArgs(selectedTab)); }\r
+ catch (Exception) { }\r
+ }\r
}\r
\r
public SleekTab AddTab(string name, string label, Control control)\r
tab.TabClosed += new EventHandler(tab_TabClosed);\r
tabs.Add(name.ToLower(), tab);\r
\r
+ if (OnTabAdded != null)\r
+ {\r
+ try { OnTabAdded(this, new TabEventArgs(selectedTab)); }\r
+ catch (Exception) { }\r
+ }\r
+\r
return tab;\r
}\r
\r
\r
tbtnCloseTab.Enabled = tab.AllowClose;\r
owner.AcceptButton = tab.DefaultControlButton;\r
+\r
+ if (OnTabSelected != null)\r
+ {\r
+ try { OnTabSelected(this, new TabEventArgs(selectedTab)); }\r
+ catch (Exception) { }\r
+ }\r
}\r
\r
private void tab_TabClosed(object sender, EventArgs e)\r
SleekTab tab = (SleekTab)sender;\r
\r
tabs.Remove(tab.Name);\r
+\r
+ if (OnTabRemoved != null)\r
+ {\r
+ try { OnTabRemoved(this, new TabEventArgs(tab)); }\r
+ catch (Exception) { }\r
+ }\r
+\r
tab = null;\r
}\r
\r