diff --git a/OpenMetaverse.GUI/AvatarList.cs b/OpenMetaverse.GUI/AvatarList.cs
index 6e0101fb..32eedd42 100644
--- a/OpenMetaverse.GUI/AvatarList.cs
+++ b/OpenMetaverse.GUI/AvatarList.cs
@@ -82,6 +82,14 @@ namespace OpenMetaverse.GUI
else this.Items.Clear();
}
+ private void InitializeClient(GridClient client)
+ {
+ _Client = client;
+ _Client.Network.OnCurrentSimChanged += new NetworkManager.CurrentSimChangedCallback(Network_OnCurrentSimChanged);
+ _Client.Objects.OnNewAvatar += new ObjectManager.NewAvatarCallback(Objects_OnNewAvatar);
+ _Client.Objects.OnObjectKilled += new ObjectManager.KillObjectCallback(Objects_OnObjectKilled);
+ }
+
private void UpdateAvatar(Avatar avatar)
{
if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { UpdateAvatar(avatar); });
@@ -125,14 +133,6 @@ namespace OpenMetaverse.GUI
}
}
- private void InitializeClient(GridClient client)
- {
- _Client = client;
- _Client.Network.OnCurrentSimChanged += new NetworkManager.CurrentSimChangedCallback(Network_OnCurrentSimChanged);
- _Client.Objects.OnNewAvatar += new ObjectManager.NewAvatarCallback(Objects_OnNewAvatar);
- _Client.Objects.OnObjectKilled += new ObjectManager.KillObjectCallback(Objects_OnObjectKilled);
- }
-
private void AvatarList_DoubleClick(object sender, EventArgs e)
{
ListView list = (ListView)sender;
diff --git a/OpenMetaverse.GUI/InventoryTree.cs b/OpenMetaverse.GUI/InventoryTree.cs
index 615a8925..d18c2a22 100644
--- a/OpenMetaverse.GUI/InventoryTree.cs
+++ b/OpenMetaverse.GUI/InventoryTree.cs
@@ -24,7 +24,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-using OpenMetaverse;
using System.Collections.Generic;
using System.Windows.Forms;
diff --git a/OpenMetaverse.GUI/LocalChat.cs b/OpenMetaverse.GUI/LocalChat.cs
new file mode 100644
index 00000000..ff29beb0
--- /dev/null
+++ b/OpenMetaverse.GUI/LocalChat.cs
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2007-2008, openmetaverse.org
+ * All rights reserved.
+ *
+ * - Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * - Neither the name of the openmetaverse.org nor the names
+ * of its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace OpenMetaverse.GUI
+{
+ public class LocalChat : Panel
+ {
+ private GridClient _Client;
+ private RichTextBox _rtfOutput = new RichTextBox();
+ private TextBox _txtInput = new TextBox();
+
+ ///
+ /// Gets or sets the GridClient associated with this control
+ ///
+ public GridClient Client
+ {
+ get { return _Client; }
+ set { if (value != null) InitializeClient(value); }
+ }
+
+ ///
+ /// Panel control for an unspecified client's local chat interaction
+ ///
+ public LocalChat()
+ {
+ _rtfOutput.Anchor = AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+ _rtfOutput.Width = this.Width;
+ _rtfOutput.Height = this.Height - _txtInput.Height;
+ _rtfOutput.Top = 0;
+ _rtfOutput.Left = 0;
+
+ _txtInput.Dock = DockStyle.Bottom;
+ _txtInput.KeyDown += new KeyEventHandler(_txtInput_KeyDown);
+
+ this.Controls.AddRange(new Control[]{ _rtfOutput, _txtInput });
+ }
+
+ ///
+ /// Panel control for the specified client's local chat interaction
+ ///
+ public LocalChat(GridClient client)
+ {
+ _Client = client;
+ }
+
+ private void InitializeClient(GridClient client)
+ {
+ _Client = client;
+ _Client.Self.OnChat += new AgentManager.ChatCallback(Self_OnChat);
+ }
+
+ public void LogChat(string name, ChatType type, string text, Color color)
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke((MethodInvoker)delegate { LogChat(name, type, text, color); });
+ }
+ else
+ {
+ _rtfOutput.SelectionStart = _rtfOutput.Text.Length;
+ _rtfOutput.SelectionColor = color;
+ DateTime now = DateTime.Now;
+ string volume;
+ if (type == ChatType.Shout) volume = " shouts";
+ else if (type == ChatType.Whisper) volume = " whispers";
+ else volume = string.Empty;
+ _rtfOutput.SelectedText = string.Format("{0}[{1}:{2}] {3}{4}: {5}", Environment.NewLine, now.Hour.ToString().PadLeft(2, '0'), now.Minute.ToString().PadLeft(2, '0'), name, volume, text);
+ }
+ }
+
+ void Self_OnChat(string message, ChatAudibleLevel audible, ChatType type, ChatSourceType sourceType, string fromName, UUID id, UUID ownerid, Vector3 position)
+ {
+ if (audible == ChatAudibleLevel.Fully && type != ChatType.StartTyping && type != ChatType.StopTyping)
+ {
+ Color color;
+ if (sourceType == ChatSourceType.Agent) color = Color.FromKnownColor(KnownColor.ControlText);
+ else color = Color.FromKnownColor(KnownColor.GrayText);
+ LogChat(fromName, type, message, color);
+ }
+ }
+
+ void _txtInput_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Enter && _txtInput.Text != string.Empty)
+ {
+ e.SuppressKeyPress = true;
+ _Client.Self.Chat(_txtInput.Text, 0, e.Control ? ChatType.Shout : ChatType.Normal);
+ _txtInput.Clear();
+ }
+ }
+ }
+
+}
diff --git a/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj b/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
index 359b0004..18db3f12 100644
--- a/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
+++ b/OpenMetaverse.GUI/OpenMetaverse.GUI.csproj
@@ -30,6 +30,7 @@
+
@@ -40,6 +41,9 @@
Component
+
+ Component
+