From f398787d72772ae2f10578f590d3803906ef4c54 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Wed, 15 Sep 2010 01:51:06 +0000 Subject: [PATCH] RAD-7 RAD-172: Complete inventory search, recent and worn filters git-svn-id: https://radegast.googlecode.com/svn/trunk@744 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/Core/RadegastInstance.cs | 50 +++++++++++++ .../Inventory/InventoryConsole.Designer.cs | 87 ++++++++++++++++------ .../GUI/Consoles/Inventory/InventoryConsole.cs | 22 ++++-- Radegast/GUI/Dialogs/MainForm.cs | 32 +------- Radegast/RadegastBuild.cs | 2 +- 5 files changed, 134 insertions(+), 59 deletions(-) diff --git a/Radegast/Core/RadegastInstance.cs b/Radegast/Core/RadegastInstance.cs index 28e71ff..70cbd78 100644 --- a/Radegast/Core/RadegastInstance.cs +++ b/Radegast/Core/RadegastInstance.cs @@ -75,6 +75,16 @@ namespace Radegast } } + /// + /// When was Radegast started (UTC) + /// + public readonly DateTime StartupTimeUTC; + + /// + /// Time zone of the current world (currently hard coded to US Pacific time) + /// + public TimeZoneInfo WordTimeZone; + private string userDir; /// /// System (not grid!) user's dir @@ -250,6 +260,10 @@ namespace Radegast client = client0; + // Initialize current time zone, and mark when we started + GetWorldTimeZone(); + StartupTimeUTC = DateTime.UtcNow; + // Are we running mono? monoRuntime = Type.GetType("Mono.Runtime") != null; @@ -323,6 +337,42 @@ namespace Radegast netcom.ClientConnected -= new EventHandler(netcom_ClientConnected); } + private void GetWorldTimeZone() + { + try + { + foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()) + { + if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles") + { + WordTimeZone = tz; + break; + } + } + } + catch (Exception) { } + } + + public DateTime GetWorldTime() + { + DateTime now; + + try + { + if (WordTimeZone != null) + now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, WordTimeZone); + else + now = DateTime.UtcNow.AddHours(-7); + } + catch (Exception) + { + now = DateTime.UtcNow.AddHours(-7); + } + + return now; + } + + public void Reconnect() { TabConsole.DisplayNotificationInChat("Attempting to reconnect...", ChatBufferTextStyle.StatusDarkBlue); diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs b/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs index 17b3ec9..fc796dc 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.Designer.cs @@ -111,9 +111,12 @@ namespace Radegast this.lstInventorySearch = new Radegast.ListViewNoFlicker(); this.chResItemName = new System.Windows.Forms.ColumnHeader(); this.pnlSearchOptions = new System.Windows.Forms.Panel(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.cbSrchRecent = new System.Windows.Forms.RadioButton(); + this.cbSrchWorn = new System.Windows.Forms.RadioButton(); + this.rbSrchAll = new System.Windows.Forms.RadioButton(); this.lblSearchStatus = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.cbSrchWorn = new System.Windows.Forms.CheckBox(); this.cbSrchCreator = new System.Windows.Forms.CheckBox(); this.cbSrchDesc = new System.Windows.Forms.CheckBox(); this.cbSrchName = new System.Windows.Forms.CheckBox(); @@ -128,6 +131,7 @@ namespace Radegast this.pnlItemProperties.SuspendLayout(); this.tabSearch.SuspendLayout(); this.pnlSearchOptions.SuspendLayout(); + this.groupBox2.SuspendLayout(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // @@ -454,6 +458,7 @@ namespace Radegast // // pnlSearchOptions // + this.pnlSearchOptions.Controls.Add(this.groupBox2); this.pnlSearchOptions.Controls.Add(this.lblSearchStatus); this.pnlSearchOptions.Controls.Add(this.groupBox1); this.pnlSearchOptions.Controls.Add(this.txtSearch); @@ -464,10 +469,57 @@ namespace Radegast this.pnlSearchOptions.Size = new System.Drawing.Size(407, 88); this.pnlSearchOptions.TabIndex = 10; // + // groupBox2 + // + this.groupBox2.Controls.Add(this.cbSrchRecent); + this.groupBox2.Controls.Add(this.cbSrchWorn); + this.groupBox2.Controls.Add(this.rbSrchAll); + this.groupBox2.Location = new System.Drawing.Point(3, 29); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(227, 50); + this.groupBox2.TabIndex = 2; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Filter"; + // + // cbSrchRecent + // + this.cbSrchRecent.AutoSize = true; + this.cbSrchRecent.Location = new System.Drawing.Point(105, 19); + this.cbSrchRecent.Name = "cbSrchRecent"; + this.cbSrchRecent.Size = new System.Drawing.Size(60, 17); + this.cbSrchRecent.TabIndex = 2; + this.cbSrchRecent.Text = "Recent"; + this.cbSrchRecent.UseVisualStyleBackColor = true; + this.cbSrchRecent.CheckedChanged += new System.EventHandler(this.rbSrchAll_CheckedChanged); + // + // cbSrchWorn + // + this.cbSrchWorn.AutoSize = true; + this.cbSrchWorn.Location = new System.Drawing.Point(48, 19); + this.cbSrchWorn.Name = "cbSrchWorn"; + this.cbSrchWorn.Size = new System.Drawing.Size(51, 17); + this.cbSrchWorn.TabIndex = 1; + this.cbSrchWorn.Text = "Worn"; + this.cbSrchWorn.UseVisualStyleBackColor = true; + this.cbSrchWorn.CheckedChanged += new System.EventHandler(this.rbSrchAll_CheckedChanged); + // + // rbSrchAll + // + this.rbSrchAll.AutoSize = true; + this.rbSrchAll.Checked = true; + this.rbSrchAll.Location = new System.Drawing.Point(6, 19); + this.rbSrchAll.Name = "rbSrchAll"; + this.rbSrchAll.Size = new System.Drawing.Size(36, 17); + this.rbSrchAll.TabIndex = 0; + this.rbSrchAll.TabStop = true; + this.rbSrchAll.Text = "All"; + this.rbSrchAll.UseVisualStyleBackColor = true; + this.rbSrchAll.CheckedChanged += new System.EventHandler(this.rbSrchAll_CheckedChanged); + // // lblSearchStatus // this.lblSearchStatus.AutoSize = true; - this.lblSearchStatus.Location = new System.Drawing.Point(317, 49); + this.lblSearchStatus.Location = new System.Drawing.Point(335, 6); this.lblSearchStatus.Name = "lblSearchStatus"; this.lblSearchStatus.Size = new System.Drawing.Size(46, 13); this.lblSearchStatus.TabIndex = 3; @@ -475,32 +527,20 @@ namespace Radegast // // groupBox1 // - this.groupBox1.Controls.Add(this.cbSrchWorn); this.groupBox1.Controls.Add(this.cbSrchCreator); this.groupBox1.Controls.Add(this.cbSrchDesc); this.groupBox1.Controls.Add(this.cbSrchName); - this.groupBox1.Location = new System.Drawing.Point(3, 29); + this.groupBox1.Location = new System.Drawing.Point(236, 30); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(308, 49); - this.groupBox1.TabIndex = 2; + this.groupBox1.Size = new System.Drawing.Size(154, 49); + this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; this.groupBox1.Text = "Search in"; // - // cbSrchWorn - // - this.cbSrchWorn.AutoSize = true; - this.cbSrchWorn.Location = new System.Drawing.Point(151, 19); - this.cbSrchWorn.Name = "cbSrchWorn"; - this.cbSrchWorn.Size = new System.Drawing.Size(76, 17); - this.cbSrchWorn.TabIndex = 2; - this.cbSrchWorn.Text = "Only Worn"; - this.cbSrchWorn.UseVisualStyleBackColor = true; - this.cbSrchWorn.CheckedChanged += new System.EventHandler(this.cbSrchWorn_CheckedChanged); - // // cbSrchCreator // this.cbSrchCreator.AutoSize = true; - this.cbSrchCreator.Location = new System.Drawing.Point(233, 19); + this.cbSrchCreator.Location = new System.Drawing.Point(151, 19); this.cbSrchCreator.Name = "cbSrchCreator"; this.cbSrchCreator.Size = new System.Drawing.Size(60, 17); this.cbSrchCreator.TabIndex = 3; @@ -547,9 +587,9 @@ namespace Radegast // this.btnInvSearch.Location = new System.Drawing.Point(236, 1); this.btnInvSearch.Name = "btnInvSearch"; - this.btnInvSearch.Size = new System.Drawing.Size(75, 23); + this.btnInvSearch.Size = new System.Drawing.Size(96, 23); this.btnInvSearch.TabIndex = 1; - this.btnInvSearch.Text = "Search"; + this.btnInvSearch.Text = "Search/Refresh"; this.btnInvSearch.UseVisualStyleBackColor = true; this.btnInvSearch.Click += new System.EventHandler(this.btnInvSearch_Click); // @@ -573,6 +613,8 @@ namespace Radegast this.tabSearch.ResumeLayout(false); this.pnlSearchOptions.ResumeLayout(false); this.pnlSearchOptions.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.ResumeLayout(false); @@ -619,6 +661,9 @@ namespace Radegast private System.Windows.Forms.CheckBox cbSrchCreator; private System.Windows.Forms.CheckBox cbSrchDesc; private System.Windows.Forms.Label lblSearchStatus; - private System.Windows.Forms.CheckBox cbSrchWorn; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.RadioButton rbSrchAll; + private System.Windows.Forms.RadioButton cbSrchRecent; + private System.Windows.Forms.RadioButton cbSrchWorn; } } diff --git a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs index a2cd834..22462a6 100644 --- a/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs +++ b/Radegast/GUI/Consoles/Inventory/InventoryConsole.cs @@ -2087,7 +2087,7 @@ namespace Radegast { add = true; } - + if (cbSrchWorn.Checked && add && !( (it.InventoryType == InventoryType.Wearable && IsWorn(it)) || @@ -2098,6 +2098,11 @@ namespace Radegast add = false; } + if (cbSrchRecent.Checked && add && it.CreationDate < instance.StartupTimeUTC) + { + add = false; + } + if (add) { found++; @@ -2126,11 +2131,11 @@ namespace Radegast lstInventorySearch.VirtualListSize = 0; searchString = txtSearch.Text.Trim().ToLower(); - if (searchString == string.Empty && !cbSrchWorn.Checked) - { - lblSearchStatus.Text = "0 results"; - return; - } + //if (searchString == string.Empty && rbSrchAll.Checked) + //{ + // lblSearchStatus.Text = "0 results"; + // return; + //} if (emptyItem == null) { @@ -2277,6 +2282,11 @@ namespace Radegast UpdateSearch(); } + private void rbSrchAll_CheckedChanged(object sender, EventArgs e) + { + UpdateSearch(); + } + private void lstInventorySearch_MouseClick(object sender, MouseEventArgs e) { if (lstInventorySearch.SelectedIndices.Count != 1) diff --git a/Radegast/GUI/Dialogs/MainForm.cs b/Radegast/GUI/Dialogs/MainForm.cs index a88613b..056f8d7 100644 --- a/Radegast/GUI/Dialogs/MainForm.cs +++ b/Radegast/GUI/Dialogs/MainForm.cs @@ -129,7 +129,6 @@ namespace Radegast public frmMain(RadegastInstance instance) : base(instance) { - GetSLTimeZone(); InitializeComponent(); Disposed += new EventHandler(frmMain_Disposed); @@ -1046,39 +1045,10 @@ namespace Radegast ); } - private TimeZoneInfo SLTime; - - private void GetSLTimeZone() - { - try - { - foreach (TimeZoneInfo tz in TimeZoneInfo.GetSystemTimeZones()) - { - if (tz.Id == "Pacific Standard Time" || tz.Id == "America/Los_Angeles") - { - SLTime = tz; - break; - } - } - } - catch (Exception) { } - } private void timerWorldClock_Tick(object sender, EventArgs e) { - DateTime now; - try - { - if (SLTime != null) - now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, SLTime); - else - now = DateTime.UtcNow.AddHours(-7); - } - catch (Exception) - { - now = DateTime.UtcNow.AddHours(-7); - } - lblTime.Text = now.ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture); + lblTime.Text = instance.GetWorldTime().ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture); } private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/Radegast/RadegastBuild.cs b/Radegast/RadegastBuild.cs index 449c11a..a0dbea7 100644 --- a/Radegast/RadegastBuild.cs +++ b/Radegast/RadegastBuild.cs @@ -1,5 +1,5 @@ // Autogenerated: run updatebuildnr.bat/sh to update namespace Radegast { - public static class RadegastBuild { public static int CurrentRev = 734; } + public static class RadegastBuild { public static int CurrentRev = 744; } } -- 2.11.0