2 // Radegast Metaverse Client
\r
3 // Copyright (c) 2009, Radegast Development Team
\r
4 // All rights reserved.
\r
6 // Redistribution and use in source and binary forms, with or without
\r
7 // modification, are permitted provided that the following conditions are met:
\r
9 // * Redistributions of source code must retain the above copyright notice,
\r
10 // this list of conditions and the following disclaimer.
\r
11 // * Redistributions in binary form must reproduce the above copyright
\r
12 // notice, this list of conditions and the following disclaimer in the
\r
13 // documentation and/or other materials provided with the distribution.
\r
14 // * Neither the name of the application "Radegast", nor the names of its
\r
15 // contributors may be used to endorse or promote products derived from
\r
16 // this software without specific prior written permission.
\r
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
32 using System.Collections.Generic;
\r
33 using System.ComponentModel;
\r
34 using System.Drawing;
\r
35 using System.Windows.Forms;
\r
36 using Radegast.Netcom;
\r
37 using OpenMetaverse;
\r
41 public partial class TabsConsole : UserControl
\r
44 /// Delegate inviked on tab operations
\r
46 /// <param name="sender">Event sender</param>
\r
47 /// <param name="e">Event arguments</param>
\r
48 public delegate void TabCallback(object sender, TabEventArgs e);
\r
51 /// Fired when a tab is selected
\r
53 public event TabCallback OnTabSelected;
\r
56 /// Fired when a new tab is added
\r
58 public event TabCallback OnTabAdded;
\r
61 /// Fired when a tab is removed
\r
63 public event TabCallback OnTabRemoved;
\r
65 private RadegastInstance instance;
\r
66 private GridClient client { get { return instance.Client; } }
\r
67 private RadegastNetcom netcom { get { return instance.Netcom; } }
\r
68 private ChatTextManager mainChatManger;
\r
70 private Dictionary<string, RadegastTab> tabs = new Dictionary<string, RadegastTab>();
\r
71 public Dictionary<string, RadegastTab> Tabs { get { return tabs; } }
\r
73 private ChatConsole chatConsole;
\r
75 private RadegastTab selectedTab;
\r
78 /// Currently selected tab
\r
80 public RadegastTab SelectedTab
\r
90 public TabsConsole(RadegastInstance instance)
\r
92 InitializeComponent();
\r
93 Disposed += new EventHandler(TabsConsole_Disposed);
\r
95 this.instance = instance;
\r
99 InitializeMainTab();
\r
100 InitializeChatTab();
\r
103 client.Self.OnScriptQuestion += new AgentManager.ScriptQuestionCallback(Self_OnScriptQuestion);
\r
104 client.Self.OnScriptDialog += new AgentManager.ScriptDialogCallback(Self_OnScriptDialog);
\r
107 void TabsConsole_Disposed(object sender, EventArgs e)
\r
109 RemoveNetcomEvents();
\r
110 client.Self.OnScriptQuestion -= new AgentManager.ScriptQuestionCallback(Self_OnScriptQuestion);
\r
111 client.Self.OnScriptDialog -= new AgentManager.ScriptDialogCallback(Self_OnScriptDialog);
\r
114 private void AddNetcomEvents()
\r
116 netcom.ClientLoginStatus += new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);
\r
117 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
\r
118 netcom.ClientDisconnected += new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);
\r
119 netcom.ChatReceived += new EventHandler<ChatEventArgs>(netcom_ChatReceived);
\r
120 netcom.ChatSent += new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
\r
121 netcom.AlertMessageReceived += new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
\r
122 netcom.InstantMessageReceived += new EventHandler<InstantMessageEventArgs>(netcom_InstantMessageReceived);
\r
125 private void RemoveNetcomEvents()
\r
127 netcom.ClientLoginStatus -= new EventHandler<ClientLoginEventArgs>(netcom_ClientLoginStatus);
\r
128 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
\r
129 netcom.ClientDisconnected -= new EventHandler<ClientDisconnectEventArgs>(netcom_ClientDisconnected);
\r
130 netcom.ChatReceived -= new EventHandler<ChatEventArgs>(netcom_ChatReceived);
\r
131 netcom.ChatSent -= new EventHandler<ChatSentEventArgs>(netcom_ChatSent);
\r
132 netcom.AlertMessageReceived -= new EventHandler<AlertMessageEventArgs>(netcom_AlertMessageReceived);
\r
133 netcom.InstantMessageReceived -= new EventHandler<InstantMessageEventArgs>(netcom_InstantMessageReceived);
\r
136 void Self_OnScriptDialog(string message, string objectName, UUID imageID, UUID objectID, string firstName, string lastName, int chatChannel, List<string> buttons)
\r
138 instance.MainForm.AddNotification(new ntfScriptDialog(instance, message, objectName, imageID, objectID, firstName, lastName, chatChannel, buttons));
\r
141 void Self_OnScriptQuestion(Simulator simulator, UUID taskID, UUID itemID, string objectName, string objectOwner, ScriptPermission questions)
\r
143 instance.MainForm.AddNotification(new ntfPermissions(instance, simulator, taskID, itemID, objectName, objectOwner, questions));
\r
146 private void netcom_ClientLoginStatus(object sender, ClientLoginEventArgs e)
\r
148 if (e.Status != LoginStatus.Success) return;
\r
150 InitializeOnlineTabs();
\r
152 if (tabs.ContainsKey("login"))
\r
154 if (selectedTab.Name == "login")
\r
155 tabs["chat"].Select();
\r
157 tabs["login"].AllowClose = true;
\r
158 tabs["login"].Close();
\r
161 client.Self.RetrieveInstantMessages();
\r
164 private void netcom_ClientLoggedOut(object sender, EventArgs e)
\r
166 DisposeOnlineTabs();
\r
168 tabs["chat"].Select();
\r
169 DisplayNotificationInChat("Logged out.");
\r
173 private void netcom_ClientDisconnected(object sender, ClientDisconnectEventArgs e)
\r
175 if (e.Type == NetworkManager.DisconnectType.ClientInitiated) return;
\r
177 DisposeOnlineTabs();
\r
179 tabs["chat"].Select();
\r
180 DisplayNotificationInChat("Disconnected.");
\r
183 private void netcom_AlertMessageReceived(object sender, AlertMessageEventArgs e)
\r
185 tabs["chat"].Highlight();
\r
188 private void netcom_ChatSent(object sender, ChatSentEventArgs e)
\r
190 tabs["chat"].Highlight();
\r
193 private void netcom_ChatReceived(object sender, ChatEventArgs e)
\r
195 if (string.IsNullOrEmpty(e.Message)) return;
\r
197 tabs["chat"].Highlight();
\r
200 private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
\r
202 switch (e.IM.Dialog)
\r
204 case InstantMessageDialog.SessionSend:
\r
205 if (instance.Groups.ContainsKey(e.IM.IMSessionID))
\r
211 HandleConferenceIM(e);
\r
215 case InstantMessageDialog.MessageFromAgent:
\r
216 if (e.IM.FromAgentName == "Second Life")
\r
218 HandleIMFromObject(e);
\r
220 else if (e.IM.GroupIM || instance.Groups.ContainsKey(e.IM.IMSessionID))
\r
224 else if (e.IM.BinaryBucket.Length > 1)
\r
226 HandleConferenceIM(e);
\r
234 case InstantMessageDialog.MessageFromObject:
\r
235 HandleIMFromObject(e);
\r
238 case InstantMessageDialog.StartTyping:
\r
239 if (TabExists(e.IM.FromAgentName))
\r
241 RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
\r
242 if (!tab.Highlighted) tab.PartialHighlight();
\r
247 case InstantMessageDialog.StopTyping:
\r
248 if (TabExists(e.IM.FromAgentName))
\r
250 RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
\r
251 if (!tab.Highlighted) tab.Unhighlight();
\r
256 case InstantMessageDialog.MessageBox:
\r
257 instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
\r
260 case InstantMessageDialog.RequestTeleport:
\r
261 instance.MainForm.AddNotification(new ntfTeleport(instance, e.IM));
\r
264 case InstantMessageDialog.GroupInvitation:
\r
265 instance.MainForm.AddNotification(new ntfGroupInvitation(instance, e.IM));
\r
268 case InstantMessageDialog.FriendshipOffered:
\r
269 instance.MainForm.AddNotification(new ntfFriendshipOffer(instance, e.IM));
\r
272 case InstantMessageDialog.InventoryAccepted:
\r
273 DisplayNotificationInChat(e.IM.FromAgentName + " accepted your inventory offer.");
\r
276 case InstantMessageDialog.GroupNotice:
\r
277 instance.MainForm.AddNotification(new ntfGroupNotice(instance, e.IM));
\r
280 case InstantMessageDialog.InventoryOffered:
\r
281 case InstantMessageDialog.TaskInventoryOffered:
\r
282 instance.MainForm.AddNotification(new ntfInventoryOffer(instance, e.IM));
\r
288 /// Displays notification in the main chat tab
\r
290 /// <param name="msg">Message to be printed in the chat tab</param>
\r
291 public void DisplayNotificationInChat(string msg)
\r
293 DisplayNotificationInChat(msg, ChatBufferTextStyle.ObjectChat);
\r
297 /// Displays notification in the main chat tab
\r
299 /// <param name="msg">Message to be printed in the chat tab</param>
\r
300 /// <param name="style">Style of the message to be printed, normal, object, etc.</param>
\r
301 public void DisplayNotificationInChat(string msg, ChatBufferTextStyle style)
\r
303 if (InvokeRequired)
\r
305 BeginInvoke(new MethodInvoker(delegate()
\r
307 DisplayNotificationInChat(msg, style);
\r
312 ChatBufferItem line = new ChatBufferItem(
\r
319 mainChatManger.ProcessBufferItem(line, true);
\r
320 tabs["chat"].Highlight();
\r
322 catch (Exception) { }
\r
325 private void HandleIMFromObject(InstantMessageEventArgs e)
\r
327 DisplayNotificationInChat(e.IM.FromAgentName + ": " + e.IM.Message);
\r
330 private void HandleIM(InstantMessageEventArgs e)
\r
332 if (TabExists(e.IM.IMSessionID.ToString()))
\r
334 RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
\r
335 if (!tab.Selected) tab.Highlight();
\r
339 IMTabWindow imTab = AddIMTab(e);
\r
340 tabs[e.IM.IMSessionID.ToString()].Highlight();
\r
343 private void HandleConferenceIM(InstantMessageEventArgs e)
\r
345 if (TabExists(e.IM.IMSessionID.ToString()))
\r
347 RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
\r
348 if (!tab.Selected) tab.Highlight();
\r
352 ConferenceIMTabWindow imTab = AddConferenceIMTab(e);
\r
353 tabs[e.IM.IMSessionID.ToString()].Highlight();
\r
356 private void HandleGroupIM(InstantMessageEventArgs e)
\r
358 if (TabExists(e.IM.IMSessionID.ToString()))
\r
360 RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
\r
361 if (!tab.Selected) tab.Highlight();
\r
365 GroupIMTabWindow imTab = AddGroupIMTab(e);
\r
366 tabs[e.IM.IMSessionID.ToString()].Highlight();
\r
369 private void InitializeMainTab()
\r
371 MainConsole mainConsole = new MainConsole(instance);
\r
373 RadegastTab tab = AddTab("login", "Login", mainConsole);
\r
374 tab.AllowClose = false;
\r
375 tab.AllowDetach = false;
\r
376 tab.AllowMerge = false;
\r
378 mainConsole.RegisterTab(tab);
\r
381 private void InitializeChatTab()
\r
383 chatConsole = new ChatConsole(instance);
\r
384 mainChatManger = chatConsole.ChatManager;
\r
386 RadegastTab tab = AddTab("chat", "Chat", chatConsole);
\r
387 tab.AllowClose = false;
\r
388 tab.AllowDetach = false;
\r
389 tab.AllowHide = false;
\r
394 /// Create Tabs that only make sense when connected
\r
396 private void InitializeOnlineTabs()
\r
398 RadegastTab tab = AddTab("friends", "Friends", new FriendsConsole(instance));
\r
399 tab.AllowClose = false;
\r
400 tab.AllowDetach = true;
\r
401 tab.Visible = false;
\r
403 tab = AddTab("groups", "Groups", new GroupsConsole(instance));
\r
404 tab.AllowClose = false;
\r
405 tab.AllowDetach = true;
\r
406 tab.Visible = false;
\r
408 tab = AddTab("inventory", "Inventory", new InventoryConsole(instance));
\r
409 tab.AllowClose = false;
\r
410 tab.AllowDetach = true;
\r
411 tab.Visible = false;
\r
413 tab = AddTab("search", "Search", new SearchConsole(instance));
\r
414 tab.AllowClose = false;
\r
415 tab.AllowDetach = false;
\r
416 tab.Visible = false;
\r
418 tab = AddTab("map", "Map", new MapConsole(instance));
\r
419 tab.AllowClose = false;
\r
420 tab.AllowDetach = true;
\r
421 tab.Visible = false;
\r
426 /// Close tabs that make no sense when not connected
\r
428 private void DisposeOnlineTabs()
\r
430 ForceCloseTab("map");
\r
431 ForceCloseTab("search");
\r
432 ForceCloseTab("inventory");
\r
433 ForceCloseTab("groups");
\r
434 ForceCloseTab("friends");
\r
437 private void ForceCloseTab(string name)
\r
439 if (!TabExists(name)) return;
\r
441 RadegastTab tab = tabs[name];
\r
442 if (tab.Merged) SplitTab(tab);
\r
444 tab.AllowClose = true;
\r
450 public void AddContextMenu(Type libomvType, String label, EventHandler handler)
\r
452 instance.ContextActionManager.AddContextMenu(libomvType, label, handler);
\r
455 public void AddContextMenu(ContextAction handler)
\r
457 instance.ContextActionManager.AddContextMenu(handler);
\r
460 public void AddTab(RadegastTab tab)
\r
462 ToolStripButton button = (ToolStripButton)tstTabs.Items.Add(tab.Label);
\r
463 button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
\r
464 button.Image = null;
\r
465 button.AutoToolTip = false;
\r
466 button.Tag = tab.Name;
\r
467 button.Click += new EventHandler(TabButtonClick);
\r
468 tab.Button = button;
\r
469 tabs.Add(tab.Name, tab);
\r
471 if (OnTabAdded != null)
\r
473 try { OnTabAdded(this, new TabEventArgs(tab)); }
\r
474 catch (Exception) { }
\r
478 public RadegastTab AddTab(string name, string label, Control control)
\r
480 // WORKAROUND: one should never add tab that alrady exists
\r
481 // but under some weird conditions disconnect/connect
\r
482 // fire in the wrong order
\r
483 if (TabExists(name))
\r
485 Logger.Log("Force closing tab '" + name + "'", Helpers.LogLevel.Warning, client);
\r
486 ForceCloseTab(name);
\r
489 toolStripContainer1.ContentPanel.Controls.Add(control);
\r
490 control.Visible = false;
\r
491 control.Dock = DockStyle.Fill;
\r
493 ToolStripButton button = (ToolStripButton)tstTabs.Items.Add(label);
\r
494 button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
\r
495 button.Image = null;
\r
496 button.AutoToolTip = false;
\r
497 button.Tag = name.ToLower();
\r
498 button.Click += new EventHandler(TabButtonClick);
\r
500 RadegastTab tab = new RadegastTab(instance, button, control, name.ToLower(), label);
\r
501 tab.TabAttached += new EventHandler(tab_TabAttached);
\r
502 tab.TabDetached += new EventHandler(tab_TabDetached);
\r
503 tab.TabSelected += new EventHandler(tab_TabSelected);
\r
504 tab.TabClosed += new EventHandler(tab_TabClosed);
\r
505 tab.TabHidden += new EventHandler(tab_TabHidden);
\r
506 tabs.Add(name.ToLower(), tab);
\r
508 if (OnTabAdded != null)
\r
510 try { OnTabAdded(this, new TabEventArgs(tab)); }
\r
511 catch (Exception) { }
\r
517 private void tab_TabAttached(object sender, EventArgs e)
\r
519 RadegastTab tab = (RadegastTab)sender;
\r
523 private void tab_TabDetached(object sender, EventArgs e)
\r
525 RadegastTab tab = (RadegastTab)sender;
\r
526 frmDetachedTab form = (frmDetachedTab)tab.Owner;
\r
528 form.ReattachStrip = tstTabs;
\r
529 form.ReattachContainer = toolStripContainer1.ContentPanel;
\r
532 private void tab_TabSelected(object sender, EventArgs e)
\r
534 RadegastTab tab = (RadegastTab)sender;
\r
536 if (selectedTab != null &&
\r
537 selectedTab != tab)
\r
538 { selectedTab.Deselect(); }
\r
542 tbtnCloseTab.Enabled = tab.AllowClose || tab.AllowHide;
\r
543 owner.AcceptButton = tab.DefaultControlButton;
\r
545 if (OnTabSelected != null)
\r
547 try { OnTabSelected(this, new TabEventArgs(selectedTab)); }
\r
548 catch (Exception) { }
\r
552 void tab_TabHidden(object sender, EventArgs e)
\r
554 RadegastTab tab = (RadegastTab)sender;
\r
556 if (selectedTab != null && selectedTab == tab)
\r
559 tabs["chat"].Select();
\r
563 private void tab_TabClosed(object sender, EventArgs e)
\r
565 RadegastTab tab = (RadegastTab)sender;
\r
567 if (selectedTab != null && selectedTab == tab)
\r
570 tabs["chat"].Select();
\r
573 tabs.Remove(tab.Name);
\r
575 if (OnTabRemoved != null)
\r
577 try { OnTabRemoved(this, new TabEventArgs(tab)); }
\r
578 catch (Exception) { }
\r
584 private void TabButtonClick(object sender, EventArgs e)
\r
586 ToolStripButton button = (ToolStripButton)sender;
\r
588 RadegastTab tab = tabs[button.Tag.ToString()];
\r
592 public void RemoveTabEntry(RadegastTab tab)
\r
594 if (tstTabs.Items.Contains(tab.Button))
\r
596 tstTabs.Items.Remove(tab.Button);
\r
599 tab.Button.Dispose();
\r
600 tabs.Remove(tab.Name);
\r
603 public void RemoveTab(string name)
\r
605 if (tabs.ContainsKey(name))
\r
611 //Used for outside classes that have a reference to TabsConsole
\r
612 public void SelectTab(string name)
\r
614 tabs[name.ToLower()].Select();
\r
617 public bool TabExists(string name)
\r
619 return tabs.ContainsKey(name.ToLower());
\r
622 public RadegastTab GetTab(string name)
\r
624 return tabs[name.ToLower()];
\r
627 public List<RadegastTab> GetOtherTabs()
\r
629 List<RadegastTab> otherTabs = new List<RadegastTab>();
\r
631 foreach (ToolStripItem item in tstTabs.Items)
\r
633 if (item.Tag == null) continue;
\r
634 if ((ToolStripItem)item == selectedTab.Button) continue;
\r
636 RadegastTab tab = tabs[item.Tag.ToString()];
\r
637 if (!tab.AllowMerge) continue;
\r
638 if (tab.Merged) continue;
\r
640 otherTabs.Add(tab);
\r
647 /// Activates the next tab
\r
649 public void SelectNextTab()
\r
651 List<ToolStripItem> buttons = new List<ToolStripItem>();
\r
653 foreach (ToolStripItem item in tstTabs.Items)
\r
655 if (item.Tag == null || !item.Visible) continue;
\r
662 for (int i = 0; i < buttons.Count; i++)
\r
664 if (buttons[i] == selectedTab.Button)
\r
673 if (current == buttons.Count)
\r
676 SelectTab(tabs[buttons[current].Tag.ToString()].Name);
\r
680 /// Activates the previous tab
\r
682 public void SelectPreviousTab()
\r
684 List<ToolStripItem> buttons = new List<ToolStripItem>();
\r
686 foreach (ToolStripItem item in tstTabs.Items)
\r
688 if (item.Tag == null || !item.Visible) continue;
\r
695 for (int i = 0; i < buttons.Count; i++)
\r
697 if (buttons[i] == selectedTab.Button)
\r
707 current = buttons.Count - 1;
\r
709 SelectTab(tabs[buttons[current].Tag.ToString()].Name);
\r
713 public IMTabWindow AddIMTab(UUID target, UUID session, string targetName)
\r
715 IMTabWindow imTab = new IMTabWindow(instance, target, session, targetName);
\r
717 RadegastTab tab = AddTab(session.ToString(), "IM: " + targetName, imTab);
\r
718 imTab.SelectIMInput();
\r
724 public ConferenceIMTabWindow AddConferenceIMTab(UUID session, string name)
\r
726 ConferenceIMTabWindow imTab = new ConferenceIMTabWindow(instance, session, name);
\r
728 RadegastTab tab = AddTab(session.ToString(), name, imTab);
\r
729 imTab.SelectIMInput();
\r
735 public ConferenceIMTabWindow AddConferenceIMTab(InstantMessageEventArgs e)
\r
737 ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
\r
738 imTab.TextManager.ProcessIM(e);
\r
742 public GroupIMTabWindow AddGroupIMTab(UUID session, string name)
\r
744 GroupIMTabWindow imTab = new GroupIMTabWindow(instance, session, name);
\r
746 RadegastTab tab = AddTab(session.ToString(), name, imTab);
\r
747 imTab.SelectIMInput();
\r
752 public GroupIMTabWindow AddGroupIMTab(InstantMessageEventArgs e)
\r
754 GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
\r
755 imTab.TextManager.ProcessIM(e);
\r
759 public IMTabWindow AddIMTab(InstantMessageEventArgs e)
\r
761 IMTabWindow imTab = AddIMTab(e.IM.FromAgentID, e.IM.IMSessionID, e.IM.FromAgentName);
\r
762 imTab.TextManager.ProcessIM(e);
\r
766 public OutfitTextures AddOTTab(Avatar avatar)
\r
768 OutfitTextures otTab = new OutfitTextures(instance, avatar);
\r
770 RadegastTab tab = AddTab("OT: " + avatar.Name, "OT: " + avatar.Name, otTab);
\r
771 otTab.GetTextures();
\r
775 public MasterTab AddMSTab(Avatar avatar)
\r
777 MasterTab msTab = new MasterTab(instance, avatar);
\r
779 RadegastTab tab = AddTab("MS: " + avatar.Name, "MS: " + avatar.Name, msTab);
\r
783 public AttachmentTab AddATTab(Avatar avatar)
\r
785 AttachmentTab atTab = new AttachmentTab(instance, avatar);
\r
787 RadegastTab tab = AddTab("AT: " + avatar.Name, "AT: " + avatar.Name, atTab);
\r
791 public AnimTab AddAnimTab(Avatar avatar)
\r
793 AnimTab animTab = new AnimTab(instance, avatar);
\r
795 RadegastTab tab = AddTab("Anim: " + avatar.Name, "Anim: " + avatar.Name, animTab);
\r
799 private void tbtnTabOptions_Click(object sender, EventArgs e)
\r
801 tmnuMergeWith.Enabled = selectedTab.AllowMerge;
\r
802 tmnuDetachTab.Enabled = selectedTab.AllowDetach;
\r
804 tmnuMergeWith.DropDown.Items.Clear();
\r
806 if (!selectedTab.AllowMerge) return;
\r
807 if (!selectedTab.Merged)
\r
809 tmnuMergeWith.Text = "Merge With";
\r
811 List<RadegastTab> otherTabs = GetOtherTabs();
\r
813 tmnuMergeWith.Enabled = (otherTabs.Count > 0);
\r
814 if (!tmnuMergeWith.Enabled) return;
\r
816 foreach (RadegastTab tab in otherTabs)
\r
818 ToolStripItem item = tmnuMergeWith.DropDown.Items.Add(tab.Label);
\r
819 item.Tag = tab.Name;
\r
820 item.Click += new EventHandler(MergeItemClick);
\r
825 tmnuMergeWith.Text = "Split";
\r
826 tmnuMergeWith.Click += new EventHandler(SplitClick);
\r
830 private void MergeItemClick(object sender, EventArgs e)
\r
832 ToolStripItem item = (ToolStripItem)sender;
\r
833 RadegastTab tab = tabs[item.Tag.ToString()];
\r
835 selectedTab.MergeWith(tab);
\r
837 SplitContainer container = (SplitContainer)selectedTab.Control;
\r
838 toolStripContainer1.ContentPanel.Controls.Add(container);
\r
840 selectedTab.Select();
\r
841 RemoveTabEntry(tab);
\r
843 tabs.Add(tab.Name, selectedTab);
\r
846 private void SplitClick(object sender, EventArgs e)
\r
848 SplitTab(selectedTab);
\r
849 selectedTab.Select();
\r
852 public void SplitTab(RadegastTab tab)
\r
854 RadegastTab otherTab = tab.Split();
\r
855 if (otherTab == null) return;
\r
857 toolStripContainer1.ContentPanel.Controls.Add(tab.Control);
\r
858 toolStripContainer1.ContentPanel.Controls.Add(otherTab.Control);
\r
860 tabs.Remove(otherTab.Name);
\r
864 private void tmnuDetachTab_Click(object sender, EventArgs e)
\r
866 if (!selectedTab.AllowDetach) return;
\r
867 RadegastTab tab = selectedTab;
\r
868 tabs["chat"].Select();
\r
869 tab.Detach(instance);
\r
872 private void tbtnCloseTab_Click(object sender, EventArgs e)
\r
874 RadegastTab tab = selectedTab;
\r
877 else if (tab.AllowClose)
\r
881 private void TabsConsole_Load(object sender, EventArgs e)
\r
883 owner = this.FindForm();
\r
886 private void ctxTabs_Opening(object sender, CancelEventArgs e)
\r
888 Point pt = this.PointToClient(Cursor.Position);
\r
889 ToolStripItem stripItem = tstTabs.GetItemAt(pt);
\r
891 if (stripItem == null)
\r
897 tabs[stripItem.Tag.ToString()].Select();
\r
899 ctxBtnClose.Enabled = selectedTab.AllowClose || selectedTab.AllowHide;
\r
900 ctxBtnDetach.Enabled = selectedTab.AllowDetach;
\r
901 ctxBtnMerge.Enabled = selectedTab.AllowMerge;
\r
902 ctxBtnMerge.DropDown.Items.Clear();
\r
904 if (!ctxBtnClose.Enabled && !ctxBtnDetach.Enabled && !ctxBtnMerge.Enabled)
\r
910 if (!selectedTab.AllowMerge) return;
\r
911 if (!selectedTab.Merged)
\r
913 ctxBtnMerge.Text = "Merge With";
\r
915 List<RadegastTab> otherTabs = GetOtherTabs();
\r
917 ctxBtnMerge.Enabled = (otherTabs.Count > 0);
\r
918 if (!ctxBtnMerge.Enabled) return;
\r
920 foreach (RadegastTab tab in otherTabs)
\r
922 ToolStripItem item = ctxBtnMerge.DropDown.Items.Add(tab.Label);
\r
923 item.Tag = tab.Name;
\r
924 item.Click += new EventHandler(MergeItemClick);
\r
929 ctxBtnMerge.Text = "Split";
\r
930 ctxBtnMerge.Click += new EventHandler(SplitClick);
\r
939 /// Arguments for tab events
\r
941 public class TabEventArgs : EventArgs
\r
944 /// Tab that was manipulated in the event
\r
946 public RadegastTab Tab;
\r
948 public TabEventArgs()
\r
953 public TabEventArgs(RadegastTab tab)
\r