OSDN Git Service

RAD-48: Add multiline paste capability in chat input.
authorLatif Khalifa <latifer@streamgrid.net>
Mon, 26 Oct 2009 10:26:04 +0000 (10:26 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Mon, 26 Oct 2009 10:26:04 +0000 (10:26 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@371 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/Core/Types/ChatInputBox.cs [new file with mode: 0644]
Radegast/GUI/Consoles/ChatConsole.Designer.cs
Radegast/GUI/Consoles/ChatConsole.cs
Radegast/GUI/Consoles/ConferenceIMTabWindow.Designer.cs
Radegast/GUI/Consoles/ConferenceIMTabWindow.cs
Radegast/GUI/Consoles/GroupIMTabWindow.Designer.cs
Radegast/GUI/Consoles/GroupIMTabWindow.cs
Radegast/GUI/Consoles/IMTabWindow.Designer.cs
Radegast/GUI/Consoles/IMTabWindow.cs
Radegast/Radegast.csproj

diff --git a/Radegast/Core/Types/ChatInputBox.cs b/Radegast/Core/Types/ChatInputBox.cs
new file mode 100644 (file)
index 0000000..0158bfa
--- /dev/null
@@ -0,0 +1,71 @@
+// \r
+// Radegast Metaverse Client\r
+// Copyright (c) 2009, Radegast Development Team\r
+// All rights reserved.\r
+// \r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions are met:\r
+// \r
+//     * Redistributions of source code must retain the above copyright notice,\r
+//       this list of conditions and the following disclaimer.\r
+//     * Redistributions in binary form must reproduce the above copyright\r
+//       notice, this list of conditions and the following disclaimer in the\r
+//       documentation and/or other materials provided with the distribution.\r
+//     * Neither the name of the application "Radegast", nor the names of its\r
+//       contributors may be used to endorse or promote products derived from\r
+//       this software without specific prior written permission.\r
+// \r
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+//\r
+// $Id: IMTabWindow.Designer.cs 323 2009-10-07 01:08:34Z latifer@gmail.com $\r
+//\r
+using System;\r
+using System.Windows.Forms;\r
+\r
+namespace Radegast\r
+{\r
+    public class ChatInputBox : TextBox\r
+    {\r
+        public static readonly string NewlineMarker = new string('\u00b6', 1);\r
+\r
+        public ChatInputBox()\r
+            : base()\r
+        {\r
+        }\r
+\r
+        protected override void WndProc(ref Message m)\r
+        {\r
+            switch (m.Msg)\r
+            {\r
+                case 0x302: //WM_PASTE\r
+                    Paste();\r
+                    break;\r
+\r
+                default:\r
+                    base.WndProc(ref m);\r
+                    break;\r
+            }\r
+        }\r
+\r
+        public new void Paste()\r
+        {\r
+            Paste(Clipboard.GetText());\r
+        }\r
+\r
+        public new void Paste(string text)\r
+        {\r
+            base.Paste(text.Replace(Environment.NewLine, NewlineMarker));\r
+        }\r
+\r
+\r
+    }\r
+}\r
index eb1aefa..287a22e 100644 (file)
@@ -63,7 +63,7 @@ namespace Radegast
             this.components = new System.ComponentModel.Container();\r
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChatConsole));\r
             this.rtbChat = new System.Windows.Forms.RichTextBox();\r
-            this.cbxInput = new System.Windows.Forms.ComboBox();\r
+            this.cbxInput = new ChatInputBox();\r
             this.btnSay = new System.Windows.Forms.Button();\r
             this.btnShout = new System.Windows.Forms.Button();\r
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();\r
@@ -130,7 +130,6 @@ namespace Radegast
             this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
                         | System.Windows.Forms.AnchorStyles.Right)));\r
             this.cbxInput.Enabled = false;\r
-            this.cbxInput.FormattingEnabled = true;\r
             this.cbxInput.Location = new System.Drawing.Point(0, 0);\r
             this.cbxInput.Name = "cbxInput";\r
             this.cbxInput.Size = new System.Drawing.Size(352, 21);\r
@@ -525,7 +524,7 @@ namespace Radegast
 \r
         public ListViewNoFlicker lvwObjects;\r
         public RichTextBox rtbChat;\r
-        public ComboBox cbxInput;\r
+        public ChatInputBox cbxInput;\r
         public Button btnSay;\r
         public Button btnShout;\r
         public SplitContainer splitContainer1;\r
index fce9b11..3e92729 100644 (file)
@@ -53,7 +53,7 @@ namespace Radegast
         private Dictionary<uint, Avatar> avatars = new Dictionary<uint, Avatar>();\r
         private Dictionary<uint, bool> bots = new Dictionary<uint,bool>();\r
         private readonly Dictionary<UUID, ulong> agentSimHandle = new Dictionary<UUID, ulong>();\r
-        public ComboBox ChatInputText { get { return cbxInput; } }\r
+        public ChatInputBox ChatInputText { get { return cbxInput; } }\r
 \r
         public ChatConsole(RadegastInstance instance)\r
         {\r
@@ -284,6 +284,8 @@ namespace Radegast
                 msg = input;\r
             }\r
 \r
+            msg = msg.Replace(ChatInputBox.NewlineMarker, "\n");\r
+\r
             int ch = 0;\r
             Match m = chatRegex.Match(msg);\r
 \r
@@ -301,7 +303,6 @@ namespace Radegast
 \r
         private void ClearChatInput()\r
         {\r
-            cbxInput.Items.Add(cbxInput.Text);\r
             cbxInput.Text = string.Empty;\r
         }\r
 \r
index d6213d8..aaa2474 100644 (file)
@@ -59,8 +59,8 @@ namespace Radegast
         private void InitializeComponent()\r
         {\r
             this.rtbIMText = new System.Windows.Forms.RichTextBox();\r
-            this.cbxInput = new System.Windows.Forms.ComboBox();\r
             this.btnSend = new System.Windows.Forms.Button();\r
+            this.cbxInput = new Radegast.ChatInputBox();\r
             this.SuspendLayout();\r
             // \r
             // rtbIMText\r
@@ -78,24 +78,11 @@ namespace Radegast
             this.rtbIMText.Text = "";\r
             this.rtbIMText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbIMText_LinkClicked);\r
             // \r
-            // cbxInput\r
-            // \r
-            this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
-                        | System.Windows.Forms.AnchorStyles.Right)));\r
-            this.cbxInput.FormattingEnabled = true;\r
-            this.cbxInput.Location = new System.Drawing.Point(3, 306);\r
-            this.cbxInput.Name = "cbxInput";\r
-            this.cbxInput.Size = new System.Drawing.Size(413, 21);\r
-            this.cbxInput.TabIndex = 0;\r
-            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
-            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
-            this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged);\r
-            // \r
             // btnSend\r
             // \r
             this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btnSend.Enabled = false;\r
-            this.btnSend.Location = new System.Drawing.Point(422, 304);\r
+            this.btnSend.Location = new System.Drawing.Point(422, 305);\r
             this.btnSend.Name = "btnSend";\r
             this.btnSend.Size = new System.Drawing.Size(75, 23);\r
             this.btnSend.TabIndex = 1;\r
@@ -103,6 +90,18 @@ namespace Radegast
             this.btnSend.UseVisualStyleBackColor = true;\r
             this.btnSend.Click += new System.EventHandler(this.btnSend_Click);\r
             // \r
+            // cbxInput\r
+            // \r
+            this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.cbxInput.Location = new System.Drawing.Point(3, 306);\r
+            this.cbxInput.Name = "cbxInput";\r
+            this.cbxInput.Size = new System.Drawing.Size(413, 21);\r
+            this.cbxInput.TabIndex = 0;\r
+            this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged);\r
+            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
+            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
+            // \r
             // ConferenceIMTabWindow\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
@@ -114,13 +113,14 @@ namespace Radegast
             this.Name = "ConferenceIMTabWindow";\r
             this.Size = new System.Drawing.Size(500, 330);\r
             this.ResumeLayout(false);\r
+            this.PerformLayout();\r
 \r
         }\r
 \r
         #endregion\r
 \r
         public System.Windows.Forms.RichTextBox rtbIMText;\r
-        public System.Windows.Forms.ComboBox cbxInput;\r
+        public ChatInputBox cbxInput;\r
         public System.Windows.Forms.Button btnSend;\r
 \r
     }\r
index ad6ea00..3723fd5 100644 (file)
@@ -139,7 +139,8 @@ namespace Radegast
 \r
         private void SendMessage(string msg)\r
         {\r
-            string message = msg;\r
+            string message = msg.Replace(ChatInputBox.NewlineMarker, "\n");\r
+\r
             if (message.Length > 1023)\r
             {\r
                 message = message.Remove(1023);\r
@@ -152,7 +153,6 @@ namespace Radegast
 \r
         private void ClearIMInput()\r
         {\r
-            cbxInput.Items.Add(cbxInput.Text);\r
             cbxInput.Text = string.Empty;\r
         }\r
 \r
index 56727da..a52d452 100644 (file)
@@ -59,7 +59,7 @@ namespace Radegast
         private void InitializeComponent()\r
         {\r
             this.rtbIMText = new System.Windows.Forms.RichTextBox();\r
-            this.cbxInput = new System.Windows.Forms.ComboBox();\r
+            this.cbxInput = new Radegast.ChatInputBox();\r
             this.btnSend = new System.Windows.Forms.Button();\r
             this.chatSplit = new System.Windows.Forms.SplitContainer();\r
             this.Participants = new Radegast.ListViewNoFlicker();\r
@@ -86,14 +86,13 @@ namespace Radegast
             // \r
             this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
                         | System.Windows.Forms.AnchorStyles.Right)));\r
-            this.cbxInput.FormattingEnabled = true;\r
             this.cbxInput.Location = new System.Drawing.Point(3, 306);\r
             this.cbxInput.Name = "cbxInput";\r
             this.cbxInput.Size = new System.Drawing.Size(373, 21);\r
             this.cbxInput.TabIndex = 0;\r
-            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
-            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
             this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged);\r
+            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
+            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
             // \r
             // btnSend\r
             // \r
@@ -168,13 +167,14 @@ namespace Radegast
             this.chatSplit.Panel2.ResumeLayout(false);\r
             this.chatSplit.ResumeLayout(false);\r
             this.ResumeLayout(false);\r
+            this.PerformLayout();\r
 \r
         }\r
 \r
         #endregion\r
 \r
         public System.Windows.Forms.RichTextBox rtbIMText;\r
-        public System.Windows.Forms.ComboBox cbxInput;\r
+        public ChatInputBox cbxInput;\r
         public System.Windows.Forms.Button btnSend;\r
         public System.Windows.Forms.SplitContainer chatSplit;\r
         public ListViewNoFlicker Participants;\r
index 64e4d63..4f54884 100644 (file)
@@ -300,7 +300,8 @@ namespace Radegast
         {\r
             if (cbxInput.Text.Length == 0) return;\r
 \r
-            string message = cbxInput.Text;\r
+            string message = cbxInput.Text.Replace(ChatInputBox.NewlineMarker, "\n");\r
+\r
             if (message.Length > 1023) message = message.Remove(1023);\r
 \r
             if (!client.Self.GroupChatSessions.ContainsKey(session))\r
@@ -326,7 +327,6 @@ namespace Radegast
 \r
         private void ClearIMInput()\r
         {\r
-            cbxInput.Items.Add(cbxInput.Text);\r
             cbxInput.Text = string.Empty;\r
         }\r
 \r
index 3c534fe..9224a9e 100644 (file)
@@ -59,10 +59,10 @@ namespace Radegast
         private void InitializeComponent()\r
         {\r
             this.rtbIMText = new System.Windows.Forms.RichTextBox();\r
-            this.cbxInput = new System.Windows.Forms.ComboBox();\r
             this.btnSend = new System.Windows.Forms.Button();\r
             this.toolStrip1 = new System.Windows.Forms.ToolStrip();\r
             this.tbtnProfile = new System.Windows.Forms.ToolStripButton();\r
+            this.cbxInput = new Radegast.ChatInputBox();\r
             this.toolStrip1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
@@ -81,24 +81,11 @@ namespace Radegast
             this.rtbIMText.Text = "";\r
             this.rtbIMText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbIMText_LinkClicked);\r
             // \r
-            // cbxInput\r
-            // \r
-            this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
-                        | System.Windows.Forms.AnchorStyles.Right)));\r
-            this.cbxInput.FormattingEnabled = true;\r
-            this.cbxInput.Location = new System.Drawing.Point(3, 306);\r
-            this.cbxInput.Name = "cbxInput";\r
-            this.cbxInput.Size = new System.Drawing.Size(413, 21);\r
-            this.cbxInput.TabIndex = 0;\r
-            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
-            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
-            this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged);\r
-            // \r
             // btnSend\r
             // \r
             this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
             this.btnSend.Enabled = false;\r
-            this.btnSend.Location = new System.Drawing.Point(422, 304);\r
+            this.btnSend.Location = new System.Drawing.Point(422, 302);\r
             this.btnSend.Name = "btnSend";\r
             this.btnSend.Size = new System.Drawing.Size(75, 23);\r
             this.btnSend.TabIndex = 1;\r
@@ -126,6 +113,18 @@ namespace Radegast
             this.tbtnProfile.Text = "Profile";\r
             this.tbtnProfile.Click += new System.EventHandler(this.tbtnProfile_Click);\r
             // \r
+            // cbxInput\r
+            // \r
+            this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)\r
+                        | System.Windows.Forms.AnchorStyles.Right)));\r
+            this.cbxInput.Location = new System.Drawing.Point(3, 304);\r
+            this.cbxInput.Name = "cbxInput";\r
+            this.cbxInput.Size = new System.Drawing.Size(413, 21);\r
+            this.cbxInput.TabIndex = 0;\r
+            this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged);\r
+            this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown);\r
+            this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp);\r
+            // \r
             // IMTabWindow\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
@@ -147,7 +146,7 @@ namespace Radegast
         #endregion\r
 \r
         public System.Windows.Forms.RichTextBox rtbIMText;\r
-        public System.Windows.Forms.ComboBox cbxInput;\r
+        public ChatInputBox cbxInput;\r
         public System.Windows.Forms.Button btnSend;\r
         public System.Windows.Forms.ToolStrip toolStrip1;\r
         public System.Windows.Forms.ToolStripButton tbtnProfile;\r
index bdd6f1b..4d2b6c7 100644 (file)
@@ -100,7 +100,7 @@ namespace Radegast
 \r
         private void btnSend_Click(object sender, EventArgs e)\r
         {\r
-            netcom.SendInstantMessage(cbxInput.Text, target, session);\r
+            netcom.SendInstantMessage(cbxInput.Text.Replace(ChatInputBox.NewlineMarker, "\n"), target, session);\r
             this.ClearIMInput();\r
         }\r
 \r
@@ -142,13 +142,12 @@ namespace Radegast
             e.SuppressKeyPress = true;\r
             if (cbxInput.Text.Length == 0) return;\r
 \r
-            netcom.SendInstantMessage(cbxInput.Text, target, session);\r
+            netcom.SendInstantMessage(cbxInput.Text.Replace(ChatInputBox.NewlineMarker, "\n"), target, session);\r
             this.ClearIMInput();\r
         }\r
 \r
         private void ClearIMInput()\r
         {\r
-            cbxInput.Items.Add(cbxInput.Text);\r
             cbxInput.Text = string.Empty;\r
         }\r
 \r
@@ -195,5 +194,20 @@ namespace Radegast
             get { return textManager; }\r
             set { textManager = value; }\r
         }\r
+\r
+        private void chatInput_TextChanged(object sender, EventArgs e)\r
+        {\r
+\r
+        }\r
+\r
+        private void chatInput_KeyDown(object sender, KeyEventArgs e)\r
+        {\r
+\r
+        }\r
+\r
+        private void chatInput_KeyUp(object sender, KeyEventArgs e)\r
+        {\r
+\r
+        }\r
     }\r
 }\r
index 3c8df92..beddd5e 100644 (file)
     <Compile Include="Core\Types\AgentNameTextBox.cs">\r
       <SubType>Component</SubType>\r
     </Compile>\r
+    <Compile Include="Core\Types\ChatInputBox.cs">\r
+      <SubType>Component</SubType>\r
+    </Compile>\r
     <Compile Include="Core\Types\CircularList.cs" />\r
     <Compile Include="Core\Types\DettachableControl.cs">\r
       <SubType>UserControl</SubType>\r