From 3f5cee47728770eeb98e35bcd694e37841ba7a06 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Sun, 29 Nov 2009 04:59:39 +0000 Subject: [PATCH] RAD-88: Ability to whisper in local chat * Stream cleanup in settings. git-svn-id: https://radegast.googlecode.com/svn/trunk@457 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/Core/Settings.cs | 24 ++++++----- Radegast/GUI/Consoles/ChatConsole.Designer.cs | 61 ++++++++++++++------------- Radegast/GUI/Consoles/ChatConsole.cs | 26 ++++-------- 3 files changed, 55 insertions(+), 56 deletions(-) diff --git a/Radegast/Core/Settings.cs b/Radegast/Core/Settings.cs index 4a43076..a5517f8 100644 --- a/Radegast/Core/Settings.cs +++ b/Radegast/Core/Settings.cs @@ -77,19 +77,23 @@ namespace Radegast public static string SerializeLLSDXmlStringFormated(OSD data) { - StringWriter sw = new StringWriter(); - XmlTextWriter writer = new XmlTextWriter(sw); - writer.Formatting = Formatting.Indented; - writer.Indentation = 4; - writer.IndentChar = ' '; + using (StringWriter sw = new StringWriter()) + { + using (XmlTextWriter writer = new XmlTextWriter(sw)) + { + writer.Formatting = Formatting.Indented; + writer.Indentation = 4; + writer.IndentChar = ' '; - writer.WriteStartElement(String.Empty, "llsd", String.Empty); - OSDParser.SerializeLLSDXmlElement(writer, data); - writer.WriteEndElement(); + writer.WriteStartElement(String.Empty, "llsd", String.Empty); + OSDParser.SerializeLLSDXmlElement(writer, data); + writer.WriteEndElement(); - writer.Close(); + writer.Close(); - return sw.ToString(); + return sw.ToString(); + } + } } private void FireEvent(string key, OSD val) diff --git a/Radegast/GUI/Consoles/ChatConsole.Designer.cs b/Radegast/GUI/Consoles/ChatConsole.Designer.cs index b0dc7341..4341a3f 100644 --- a/Radegast/GUI/Consoles/ChatConsole.Designer.cs +++ b/Radegast/GUI/Consoles/ChatConsole.Designer.cs @@ -63,9 +63,7 @@ namespace Radegast this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ChatConsole)); this.rtbChat = new System.Windows.Forms.RichTextBox(); - this.cbxInput = new Radegast.ChatInputBox(); this.btnSay = new System.Windows.Forms.Button(); - this.btnShout = new System.Windows.Forms.Button(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.lvwObjects = new Radegast.ListViewNoFlicker(); this.avatarContext = new Radegast.RadegastContextMenuStrip(this.components); @@ -98,6 +96,8 @@ namespace Radegast this.btnTurnRight = new System.Windows.Forms.Button(); this.btnTurnLeft = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.cbChatType = new System.Windows.Forms.ComboBox(); + this.cbxInput = new Radegast.ChatInputBox(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); @@ -125,19 +125,6 @@ namespace Radegast this.rtbChat.MouseUp += new System.Windows.Forms.MouseEventHandler(this.rtbChat_MouseUp); this.rtbChat.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbChat_LinkClicked); // - // cbxInput - // - this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cbxInput.Enabled = false; - this.cbxInput.Location = new System.Drawing.Point(0, 0); - this.cbxInput.Name = "cbxInput"; - this.cbxInput.Size = new System.Drawing.Size(352, 21); - this.cbxInput.TabIndex = 0; - this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged); - this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown); - this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp); - // // btnSay // this.btnSay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -150,18 +137,6 @@ namespace Radegast this.btnSay.UseVisualStyleBackColor = true; this.btnSay.Click += new System.EventHandler(this.btnSay_Click); // - // btnShout - // - this.btnShout.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnShout.Enabled = false; - this.btnShout.Location = new System.Drawing.Point(440, 0); - this.btnShout.Name = "btnShout"; - this.btnShout.Size = new System.Drawing.Size(76, 24); - this.btnShout.TabIndex = 2; - this.btnShout.Text = "Shout"; - this.btnShout.UseVisualStyleBackColor = true; - this.btnShout.Click += new System.EventHandler(this.btnShout_Click); - // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -489,15 +464,43 @@ namespace Radegast // // panel1 // + this.panel1.Controls.Add(this.cbChatType); this.panel1.Controls.Add(this.cbxInput); this.panel1.Controls.Add(this.btnSay); - this.panel1.Controls.Add(this.btnShout); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Location = new System.Drawing.Point(0, 310); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(516, 24); this.panel1.TabIndex = 0; // + // cbChatType + // + this.cbChatType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cbChatType.BackColor = System.Drawing.SystemColors.Window; + this.cbChatType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbChatType.Enabled = false; + this.cbChatType.FormattingEnabled = true; + this.cbChatType.Items.AddRange(new object[] { + "Whisper", + "Normal", + "Shout"}); + this.cbChatType.Location = new System.Drawing.Point(438, 1); + this.cbChatType.Name = "cbChatType"; + this.cbChatType.Size = new System.Drawing.Size(73, 21); + this.cbChatType.TabIndex = 2; + // + // cbxInput + // + this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbxInput.Enabled = false; + this.cbxInput.Location = new System.Drawing.Point(0, 0); + this.cbxInput.Name = "cbxInput"; + this.cbxInput.Size = new System.Drawing.Size(352, 21); + this.cbxInput.TabIndex = 0; + this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged); + this.cbxInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyDown); + // // ChatConsole // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -528,7 +531,6 @@ namespace Radegast public RichTextBox rtbChat; public ChatInputBox cbxInput; public Button btnSay; - public Button btnShout; public SplitContainer splitContainer1; public Panel panel1; public ToolStrip toolStrip1; @@ -560,5 +562,6 @@ namespace Radegast public ToolStripMenuItem ctxPoint; public ToolStripMenuItem ctxSource; public ToolStripMenuItem ctxPay; + public ComboBox cbChatType; } } diff --git a/Radegast/GUI/Consoles/ChatConsole.cs b/Radegast/GUI/Consoles/ChatConsole.cs index 779dc14..da63305 100644 --- a/Radegast/GUI/Consoles/ChatConsole.cs +++ b/Radegast/GUI/Consoles/ChatConsole.cs @@ -83,6 +83,7 @@ namespace Radegast this.instance.MainForm.Load += new EventHandler(MainForm_Load); lvwObjects.ListViewItemSorter = new SorterClass(); + cbChatType.SelectedIndex = 1; } private void RegisterClientEvents(GridClient client) @@ -258,7 +259,7 @@ namespace Radegast cbxInput.Enabled = true; btnSay.Enabled = true; - btnShout.Enabled = true; + cbChatType.Enabled = true; client.Avatars.RequestAvatarProperties(client.Self.AgentID); cbxInput.Focus(); } @@ -267,15 +268,15 @@ namespace Radegast { cbxInput.Enabled = false; btnSay.Enabled = false; - btnShout.Enabled = false; + cbChatType.Enabled = false; lvwObjects.Items.Clear(); } - private void cbxInput_KeyUp(object sender, KeyEventArgs e) + private void cbxInput_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) return; - e.SuppressKeyPress = true; + e.Handled = e.SuppressKeyPress = true; if (e.Shift) ProcessChatInput(cbxInput.Text, ChatType.Whisper); @@ -324,19 +325,15 @@ namespace Radegast private void btnSay_Click(object sender, EventArgs e) { - ProcessChatInput(cbxInput.Text, ChatType.Normal); - } - - private void btnShout_Click(object sender, EventArgs e) - { - ProcessChatInput(cbxInput.Text, ChatType.Shout); + ProcessChatInput(cbxInput.Text, (ChatType)cbChatType.SelectedIndex); + cbxInput.Focus(); } private void cbxInput_TextChanged(object sender, EventArgs e) { if (cbxInput.Text.Length > 0) { - btnSay.Enabled = btnShout.Enabled = true; + btnSay.Enabled = cbChatType.Enabled = true; if (!cbxInput.Text.StartsWith("/")) { @@ -346,7 +343,7 @@ namespace Radegast } else { - btnSay.Enabled = btnShout.Enabled = false; + btnSay.Enabled = cbChatType.Enabled = false; instance.State.SetTyping(false); } } @@ -447,11 +444,6 @@ namespace Radegast instance.MainForm.ShowAgentProfile(name, av); } - private void cbxInput_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) e.SuppressKeyPress = true; - } - private void dumpOufitBtn_Click(object sender, EventArgs e) { Avatar av = currentAvatar; -- 2.11.0