From: Latif Khalifa Date: Thu, 20 May 2010 09:46:32 +0000 (+0000) Subject: RAD-162: debug console window X-Git-Tag: 1.22~53 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0f0ff4ea675a5a94e31bd60c76ca347a7d291289;p=radegast%2Fradegast.git RAD-162: debug console window Activated via Alt-Ctrl-D keyboard shortcut or via Help -> Debug Console... git-svn-id: https://radegast.googlecode.com/svn/trunk@642 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- diff --git a/Radegast/GUI/Consoles/DebugConsole.Designer.cs b/Radegast/GUI/Consoles/DebugConsole.Designer.cs new file mode 100644 index 0000000..281082f --- /dev/null +++ b/Radegast/GUI/Consoles/DebugConsole.Designer.cs @@ -0,0 +1,95 @@ +// +// Radegast Metaverse Client +// Copyright (c) 2009, Radegast Development Team +// 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. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the application "Radegast", 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 HOLDER 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. +// +// $Id$ +// + +namespace Radegast +{ + partial class DebugConsole + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.rtbLog = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // rtbLog + // + this.rtbLog.AccessibleName = "Debug Log"; + this.rtbLog.BackColor = System.Drawing.SystemColors.Window; + this.rtbLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.rtbLog.HideSelection = false; + this.rtbLog.Location = new System.Drawing.Point(0, 0); + this.rtbLog.Name = "rtbLog"; + this.rtbLog.ReadOnly = true; + this.rtbLog.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.rtbLog.Size = new System.Drawing.Size(551, 364); + this.rtbLog.TabIndex = 0; + this.rtbLog.Text = ""; + this.rtbLog.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbLog_LinkClicked); + // + // DebugConsole + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.rtbLog); + this.Name = "DebugConsole"; + this.Size = new System.Drawing.Size(551, 364); + this.ResumeLayout(false); + + } + + #endregion + + public System.Windows.Forms.RichTextBox rtbLog; + } +} diff --git a/Radegast/GUI/Consoles/DebugConsole.cs b/Radegast/GUI/Consoles/DebugConsole.cs new file mode 100644 index 0000000..b031b41 --- /dev/null +++ b/Radegast/GUI/Consoles/DebugConsole.cs @@ -0,0 +1,98 @@ +// +// Radegast Metaverse Client +// Copyright (c) 2009, Radegast Development Team +// 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. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the application "Radegast", 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 HOLDER 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. +// +// $Id$ +// +using System; +using System.Drawing; +using System.Windows.Forms; +using log4net.Core; + +namespace Radegast +{ + public partial class DebugConsole : RadegastTabControl + { + public DebugConsole() + : this(null) + { + } + + public DebugConsole(RadegastInstance instance) + :base(instance) + { + InitializeComponent(); + Disposed += new EventHandler(DebugConsole_Disposed); + RadegastAppender.Log += new EventHandler(RadegastAppender_Log); + } + + void DebugConsole_Disposed(object sender, EventArgs e) + { + RadegastAppender.Log -= new EventHandler(RadegastAppender_Log); + } + + void RadegastAppender_Log(object sender, LogEventArgs e) + { + if (InvokeRequired) + { + if (IsHandleCreated) + BeginInvoke(new MethodInvoker(() => RadegastAppender_Log(sender, e))); + return; + } + + rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText); + rtbLog.AppendText(string.Format("{0} [", e.LogEntry.TimeStamp.ToString("HH:mm:ss"))); + + if (e.LogEntry.Level == Level.Error) + { + rtbLog.SelectionColor = Color.Red; + } + else if (e.LogEntry.Level == Level.Warn) + { + rtbLog.SelectionColor = Color.Yellow; + } + else if (e.LogEntry.Level == Level.Info) + { + rtbLog.SelectionColor = Color.Green; + } + else + { + rtbLog.SelectionColor = Color.Gray; + } + + rtbLog.AppendText(e.LogEntry.Level.Name); + rtbLog.SelectionColor = Color.FromKnownColor(KnownColor.WindowText); + rtbLog.AppendText(string.Format("]: - {0}{1}", e.LogEntry.MessageObject.ToString(), Environment.NewLine)); + } + + private void rtbLog_LinkClicked(object sender, LinkClickedEventArgs e) + { + instance.MainForm.ProcessLink(e.LinkText); + } + + } +} diff --git a/Radegast/GUI/Consoles/DebugConsole.resx b/Radegast/GUI/Consoles/DebugConsole.resx new file mode 100644 index 0000000..ff31a6d --- /dev/null +++ b/Radegast/GUI/Consoles/DebugConsole.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Radegast/GUI/Dialogs/MainForm.Designer.cs b/Radegast/GUI/Dialogs/MainForm.Designer.cs index 513e4ad..567f85b 100644 --- a/Radegast/GUI/Dialogs/MainForm.Designer.cs +++ b/Radegast/GUI/Dialogs/MainForm.Designer.cs @@ -116,13 +116,14 @@ namespace Radegast this.lblTime = new System.Windows.Forms.ToolStripLabel(); this.tbtnMedia = new System.Windows.Forms.ToolStripButton(); this.tbtnVoice = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.tbtnHelp = new System.Windows.Forms.ToolStripDropDownButton(); this.keyboardShortcutsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportBugsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.debugConsoleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); this.aboutRadegastToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.tlblLoginName = new System.Windows.Forms.ToolStripStatusLabel(); this.tlblMoneyBalance = new System.Windows.Forms.ToolStripStatusLabel(); @@ -168,8 +169,8 @@ namespace Radegast this.lblTime, this.tbtnMedia, this.tbtnVoice, - this.toolStripSeparator2, - this.tbtnHelp}); + this.tbtnHelp, + this.toolStripSeparator2}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(738, 25); @@ -563,11 +564,6 @@ namespace Radegast this.tbtnVoice.Text = "Voice"; this.tbtnVoice.Click += new System.EventHandler(this.tbtnVoice_Click); // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); - // // tbtnHelp // this.tbtnHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; @@ -575,6 +571,7 @@ namespace Radegast this.keyboardShortcutsToolStripMenuItem, this.reportBugsToolStripMenuItem, this.checkForUpdatesToolStripMenuItem, + this.debugConsoleToolStripMenuItem, this.toolStripMenuItem6, this.aboutRadegastToolStripMenuItem}); this.tbtnHelp.Image = ((System.Drawing.Image)(resources.GetObject("tbtnHelp.Image"))); @@ -586,36 +583,49 @@ namespace Radegast // keyboardShortcutsToolStripMenuItem // this.keyboardShortcutsToolStripMenuItem.Name = "keyboardShortcutsToolStripMenuItem"; - this.keyboardShortcutsToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.keyboardShortcutsToolStripMenuItem.Size = new System.Drawing.Size(223, 22); this.keyboardShortcutsToolStripMenuItem.Text = "Keyboard Shortcuts"; this.keyboardShortcutsToolStripMenuItem.Click += new System.EventHandler(this.keyboardShortcutsToolStripMenuItem_Click); // // reportBugsToolStripMenuItem // this.reportBugsToolStripMenuItem.Name = "reportBugsToolStripMenuItem"; - this.reportBugsToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.reportBugsToolStripMenuItem.Size = new System.Drawing.Size(223, 22); this.reportBugsToolStripMenuItem.Text = "Bugs/Feature Requests..."; this.reportBugsToolStripMenuItem.Click += new System.EventHandler(this.reportBugsToolStripMenuItem_Click); // // checkForUpdatesToolStripMenuItem // this.checkForUpdatesToolStripMenuItem.Name = "checkForUpdatesToolStripMenuItem"; - this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.checkForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(223, 22); this.checkForUpdatesToolStripMenuItem.Text = "Check for Updates..."; this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); // + // debugConsoleToolStripMenuItem + // + this.debugConsoleToolStripMenuItem.Name = "debugConsoleToolStripMenuItem"; + this.debugConsoleToolStripMenuItem.ShortcutKeyDisplayString = "Alt-Ctrl-D"; + this.debugConsoleToolStripMenuItem.Size = new System.Drawing.Size(223, 22); + this.debugConsoleToolStripMenuItem.Text = "Debug Console..."; + this.debugConsoleToolStripMenuItem.Click += new System.EventHandler(this.debugConsoleToolStripMenuItem_Click); + // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(200, 6); + this.toolStripMenuItem6.Size = new System.Drawing.Size(220, 6); // // aboutRadegastToolStripMenuItem // this.aboutRadegastToolStripMenuItem.Name = "aboutRadegastToolStripMenuItem"; - this.aboutRadegastToolStripMenuItem.Size = new System.Drawing.Size(203, 22); + this.aboutRadegastToolStripMenuItem.Size = new System.Drawing.Size(223, 22); this.aboutRadegastToolStripMenuItem.Text = "About Radegast..."; this.aboutRadegastToolStripMenuItem.Click += new System.EventHandler(this.aboutRadegastToolStripMenuItem_Click); // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -825,7 +835,6 @@ namespace Radegast this.Name = "frmMain"; this.Text = "Radegast"; this.Load += new System.EventHandler(this.frmMain_Load); - this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyUp); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing); this.Resize += new System.EventHandler(this.frmMain_Resize); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyDown); @@ -915,6 +924,7 @@ namespace Radegast public System.Windows.Forms.ToolStripMenuItem disconnectToolStripMenuItem; public System.Windows.Forms.ToolStripMenuItem reconnectToolStripMenuItem; public System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem; + public System.Windows.Forms.ToolStripMenuItem debugConsoleToolStripMenuItem; } } diff --git a/Radegast/GUI/Dialogs/MainForm.cs b/Radegast/GUI/Dialogs/MainForm.cs index 325e221..3b8c9cd 100644 --- a/Radegast/GUI/Dialogs/MainForm.cs +++ b/Radegast/GUI/Dialogs/MainForm.cs @@ -532,6 +532,13 @@ namespace Radegast return; } + // Alt-Ctrl-D Open debug console + if (e.Modifiers == (Keys.Control | Keys.Alt) && e.KeyCode == Keys.D) + { + e.Handled = e.SuppressKeyPress = true; + debugConsoleToolStripMenuItem.PerformClick(); + } + // Alt 1-8: Toggle various tabs if (e.Modifiers == Keys.Alt) { @@ -610,10 +617,6 @@ namespace Radegast } } - private void frmMain_KeyUp(object sender, KeyEventArgs e) - { - } - bool firstLoad = true; private void frmMain_Load(object sender, EventArgs e) @@ -1227,6 +1230,21 @@ namespace Radegast } } + private void debugConsoleToolStripMenuItem_Click(object sender, EventArgs e) + { + if (tabsConsole.TabExists("debug")) + { + ToggleHidden("debug"); + } + else + { + RadegastTab tab = tabsConsole.AddTab("debug", "Debug", new DebugConsole(instance)); + tab.AllowClose = false; + tab.AllowHide = true; + tab.Select(); + } + } + private void tbnObjects_Click(object sender, EventArgs e) { if (tabsConsole.TabExists("objects")) @@ -1359,6 +1377,7 @@ namespace Radegast { tmnuExit_Click(this, EventArgs.Empty); } + #endregion } } \ No newline at end of file diff --git a/Radegast/Radegast.csproj b/Radegast/Radegast.csproj index 8fd632b..4a935e8 100644 --- a/Radegast/Radegast.csproj +++ b/Radegast/Radegast.csproj @@ -242,6 +242,12 @@ ConferenceIMTabWindow.cs + + UserControl + + + DebugConsole.cs + UserControl @@ -552,6 +558,9 @@ ConferenceIMTabWindow.cs Designer + + DebugConsole.cs + GroupDetails.cs Designer