From 59502d9ea199cb4c89174325b4825fa09999059b Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Thu, 3 Sep 2009 05:06:10 +0000 Subject: [PATCH] RAD-12: Added Refresh button on the attachment tab. Optimize speed of the display by not fetching properties if we have them already. git-svn-id: https://radegast.googlecode.com/svn/trunk@184 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/GUI/Consoles/AttachmentDetail.cs | 16 ++++++---- Radegast/GUI/Consoles/AttachmentTab.Designer.cs | 28 ++++++++++++++++++ Radegast/GUI/Consoles/AttachmentTab.cs | 39 +++++++++++++++++++++---- 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/Radegast/GUI/Consoles/AttachmentDetail.cs b/Radegast/GUI/Consoles/AttachmentDetail.cs index c95d1db..ff06509 100644 --- a/Radegast/GUI/Consoles/AttachmentDetail.cs +++ b/Radegast/GUI/Consoles/AttachmentDetail.cs @@ -71,18 +71,24 @@ namespace Radegast private void AttachmentDetail_Load(object sender, EventArgs e) { boxID.Text = attachment.ID.ToString(); - client.Objects.SelectObject(client.Network.CurrentSim, attachment.LocalID); + + if (attachment.Properties == null) + { + client.Objects.SelectObject(client.Network.CurrentSim, attachment.LocalID); + } + else + { + UpdateControls(); + } } private void UpdateControls() { if (InvokeRequired) { - Invoke(new MethodInvoker(delegate() - { - UpdateControls(); - })); + Invoke(new MethodInvoker(UpdateControls)); return; } + lblAttachmentPoint.Text = attachment.PrimData.AttachmentPoint.ToString(); boxName.Text = attachment.Properties.Name; diff --git a/Radegast/GUI/Consoles/AttachmentTab.Designer.cs b/Radegast/GUI/Consoles/AttachmentTab.Designer.cs index d81cfc9..32807f9 100644 --- a/Radegast/GUI/Consoles/AttachmentTab.Designer.cs +++ b/Radegast/GUI/Consoles/AttachmentTab.Designer.cs @@ -57,19 +57,47 @@ namespace Radegast /// private void InitializeComponent() { + this.pnlControls = new System.Windows.Forms.Panel(); + this.btnRefresh = new System.Windows.Forms.Button(); + this.pnlControls.SuspendLayout(); this.SuspendLayout(); // + // pnlControls + // + this.pnlControls.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlControls.Controls.Add(this.btnRefresh); + this.pnlControls.Location = new System.Drawing.Point(0, 0); + this.pnlControls.Name = "pnlControls"; + this.pnlControls.Size = new System.Drawing.Size(150, 30); + this.pnlControls.TabIndex = 0; + // + // btnRefresh + // + this.btnRefresh.Location = new System.Drawing.Point(3, 3); + this.btnRefresh.Name = "btnRefresh"; + this.btnRefresh.Size = new System.Drawing.Size(75, 23); + this.btnRefresh.TabIndex = 0; + this.btnRefresh.Text = "&Refresh"; + this.btnRefresh.UseVisualStyleBackColor = true; + this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); + // // AttachmentTab // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; + this.Controls.Add(this.pnlControls); this.Name = "AttachmentTab"; this.Load += new System.EventHandler(this.AttachmentTab_Load); + this.pnlControls.ResumeLayout(false); this.ResumeLayout(false); } #endregion + + private System.Windows.Forms.Panel pnlControls; + private System.Windows.Forms.Button btnRefresh; } } diff --git a/Radegast/GUI/Consoles/AttachmentTab.cs b/Radegast/GUI/Consoles/AttachmentTab.cs index 4a7a3f8..0350e64 100644 --- a/Radegast/GUI/Consoles/AttachmentTab.cs +++ b/Radegast/GUI/Consoles/AttachmentTab.cs @@ -54,6 +54,11 @@ namespace Radegast private void AttachmentTab_Load(object sender, EventArgs e) { + RefreshList(); + } + + private void RefreshList() + { List attachments = client.Network.CurrentSim.ObjectsPrimitives.FindAll( delegate(Primitive prim) { @@ -61,21 +66,45 @@ namespace Radegast } ); - Controls.Clear(); + List toRemove = new List(); + + foreach (Control c in Controls) + { + if (c is AttachmentDetail) + { + toRemove.Add(c); + } + } + + for (int i = 0; i < toRemove.Count; i++) + { + Controls.Remove(toRemove[i]); + toRemove[i].Dispose(); + } + List added = new List(); int n = 0; - foreach (Primitive prim in attachments) { - if (!added.Contains(prim.ID)) { + foreach (Primitive prim in attachments) + { + if (!added.Contains(prim.ID)) + { AttachmentDetail ad = new AttachmentDetail(instance, av, prim); - ad.Location = new Point(0, n++ * ad.Height); - ad.Dock = DockStyle.Top; + ad.Location = new Point(0, pnlControls.Height + n * ad.Height); + ad.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + ad.Width = ClientSize.Width; Controls.Add(ad); added.Add(prim.ID); + n++; } } AutoScrollPosition = new Point(0, 0); } + + private void btnRefresh_Click(object sender, EventArgs e) + { + RefreshList(); + } } } -- 2.11.0