From 92cf001be7670e42568a4b8d86402160357f03c2 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Fri, 6 Nov 2009 16:41:29 +0000 Subject: [PATCH] RAD-76: Add search for groups git-svn-id: https://radegast.googlecode.com/svn/trunk@433 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast.sln | 9 - Radegast/GUI/Consoles/GroupDetails.cs | 13 +- Radegast/GUI/Consoles/SearchConsole.Designer.cs | 245 ++++++++++++++++++++---- Radegast/GUI/Consoles/SearchConsole.cs | 195 +++++++++++++++++++ Radegast/Radegast.csproj | 34 ++-- 5 files changed, 429 insertions(+), 67 deletions(-) diff --git a/Radegast.sln b/Radegast.sln index 107af2f..c0d0a86 100644 --- a/Radegast.sln +++ b/Radegast.sln @@ -91,42 +91,33 @@ Global {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Debug|Any CPU.Build.0 = Debug|Any CPU {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Debug|x86.ActiveCfg = Debug|x86 - {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Debug|x86.Build.0 = Debug|x86 {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Release|Any CPU.ActiveCfg = Release|Any CPU {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Release|Any CPU.Build.0 = Release|Any CPU {C191AC11-5EF9-4F37-82C4-BD2C5E0369D2}.Release|x86.ActiveCfg = Release|x86 {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|Any CPU.Build.0 = Debug|Any CPU {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|x86.ActiveCfg = Debug|x86 - {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|x86.Build.0 = Debug|x86 {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|Any CPU.ActiveCfg = Release|Any CPU {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|Any CPU.Build.0 = Release|Any CPU {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|x86.ActiveCfg = Release|x86 - {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|x86.Build.0 = Release|x86 {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|x86.ActiveCfg = Debug|x86 - {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|x86.Build.0 = Debug|x86 {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|Any CPU.Build.0 = Release|Any CPU {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|x86.ActiveCfg = Release|x86 - {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|x86.Build.0 = Release|x86 {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|x86.ActiveCfg = Debug|x86 - {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|x86.Build.0 = Debug|x86 {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|Any CPU.Build.0 = Release|Any CPU {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|x86.ActiveCfg = Release|x86 - {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|x86.Build.0 = Release|x86 {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|Any CPU.Build.0 = Debug|Any CPU {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|x86.ActiveCfg = Debug|x86 - {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|x86.Build.0 = Debug|x86 {DDFA3357-938D-41A3-881E-152105641A3D}.Release|Any CPU.ActiveCfg = Release|Any CPU {DDFA3357-938D-41A3-881E-152105641A3D}.Release|Any CPU.Build.0 = Release|Any CPU {DDFA3357-938D-41A3-881E-152105641A3D}.Release|x86.ActiveCfg = Release|x86 - {DDFA3357-938D-41A3-881E-152105641A3D}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Radegast/GUI/Consoles/GroupDetails.cs b/Radegast/GUI/Consoles/GroupDetails.cs index 53251d5..92ba699 100644 --- a/Radegast/GUI/Consoles/GroupDetails.cs +++ b/Radegast/GUI/Consoles/GroupDetails.cs @@ -191,9 +191,7 @@ namespace Radegast void Groups_GroupProfile(object sender, GroupProfileEventArgs e) { - Group group = e.Group; - - if (group.ID != this.group.ID) return; + if (group.ID != e.Group.ID) return; if (InvokeRequired) { @@ -201,7 +199,14 @@ namespace Radegast return; } - this.group = group; + group = e.Group; + if (group.InsigniaID != UUID.Zero && pnlInsignia.Controls.Count == 0) + { + SLImageHandler insignia = new SLImageHandler(instance, group.InsigniaID, string.Empty); + insignia.Dock = DockStyle.Fill; + pnlInsignia.Controls.Add(insignia); + } + tbxCharter.Text = group.Charter; lblFounded.Text = "Founded by: " + instance.getAvatarName(group.FounderID); diff --git a/Radegast/GUI/Consoles/SearchConsole.Designer.cs b/Radegast/GUI/Consoles/SearchConsole.Designer.cs index f1e5d1f..85637b3 100644 --- a/Radegast/GUI/Consoles/SearchConsole.Designer.cs +++ b/Radegast/GUI/Consoles/SearchConsole.Designer.cs @@ -72,18 +72,32 @@ namespace Radegast this.btnLink = new System.Windows.Forms.Button(); this.tpgPlaces = new System.Windows.Forms.TabPage(); this.pnlPlaceDetail = new System.Windows.Forms.Panel(); - this.lvwPlaces = new Radegast.ListViewNoFlicker(); - this.Place = new System.Windows.Forms.ColumnHeader(); - this.Traffic = new System.Windows.Forms.ColumnHeader(); this.btnSearchPlace = new System.Windows.Forms.Button(); this.txtSearchPlace = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.btnNextPlace = new System.Windows.Forms.Button(); this.btnPrevPlace = new System.Windows.Forms.Button(); this.lblNrPlaces = new System.Windows.Forms.Label(); + this.tpgGroups = new System.Windows.Forms.TabPage(); + this.pnlGroupDetail = new System.Windows.Forms.Panel(); + this.btnSearchGroup = new System.Windows.Forms.Button(); + this.txtSearchGroup = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.btnNextGroup = new System.Windows.Forms.Button(); + this.btnPrevGroup = new System.Windows.Forms.Button(); + this.lblNrGroups = new System.Windows.Forms.Label(); + this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); + this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); + this.lvwPlaces = new Radegast.ListViewNoFlicker(); + this.Place = new System.Windows.Forms.ColumnHeader(); + this.Traffic = new System.Windows.Forms.ColumnHeader(); + this.lvwGroups = new Radegast.ListViewNoFlicker(); + this.columnHeader3 = new System.Windows.Forms.ColumnHeader(); + this.columnHeader4 = new System.Windows.Forms.ColumnHeader(); this.tabControl1.SuspendLayout(); this.tpgPeople.SuspendLayout(); this.tpgPlaces.SuspendLayout(); + this.tpgGroups.SuspendLayout(); this.SuspendLayout(); // // pnlFindPeople @@ -189,6 +203,7 @@ namespace Radegast // this.tabControl1.Controls.Add(this.tpgPeople); this.tabControl1.Controls.Add(this.tpgPlaces); + this.tabControl1.Controls.Add(this.tpgGroups); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; @@ -253,41 +268,6 @@ namespace Radegast this.pnlPlaceDetail.Size = new System.Drawing.Size(353, 338); this.pnlPlaceDetail.TabIndex = 15; // - // lvwPlaces - // - this.lvwPlaces.AllowColumnReorder = true; - this.lvwPlaces.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.lvwPlaces.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.Place, - this.Traffic}); - this.lvwPlaces.FullRowSelect = true; - this.lvwPlaces.GridLines = true; - this.lvwPlaces.HideSelection = false; - this.lvwPlaces.Location = new System.Drawing.Point(12, 35); - this.lvwPlaces.MultiSelect = false; - this.lvwPlaces.Name = "lvwPlaces"; - this.lvwPlaces.ShowGroups = false; - this.lvwPlaces.ShowItemToolTips = true; - this.lvwPlaces.Size = new System.Drawing.Size(294, 315); - this.lvwPlaces.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.lvwPlaces.TabIndex = 14; - this.lvwPlaces.UseCompatibleStateImageBehavior = false; - this.lvwPlaces.View = System.Windows.Forms.View.Details; - this.lvwPlaces.SelectedIndexChanged += new System.EventHandler(this.lvwPlaces_SelectedIndexChanged); - this.lvwPlaces.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvwPlaces_ColumnClick); - // - // Place - // - this.Place.Text = "Place"; - this.Place.Width = 200; - // - // Traffic - // - this.Traffic.Text = "Traffic"; - this.Traffic.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.Traffic.Width = 50; - // // btnSearchPlace // this.btnSearchPlace.Enabled = false; @@ -352,6 +332,180 @@ namespace Radegast this.lblNrPlaces.TabIndex = 8; this.lblNrPlaces.Text = "0 places found"; // + // tpgGroups + // + this.tpgGroups.Controls.Add(this.pnlGroupDetail); + this.tpgGroups.Controls.Add(this.lvwGroups); + this.tpgGroups.Controls.Add(this.btnSearchGroup); + this.tpgGroups.Controls.Add(this.txtSearchGroup); + this.tpgGroups.Controls.Add(this.label3); + this.tpgGroups.Controls.Add(this.btnNextGroup); + this.tpgGroups.Controls.Add(this.btnPrevGroup); + this.tpgGroups.Controls.Add(this.lblNrGroups); + this.tpgGroups.Location = new System.Drawing.Point(4, 22); + this.tpgGroups.Name = "tpgGroups"; + this.tpgGroups.Padding = new System.Windows.Forms.Padding(3); + this.tpgGroups.Size = new System.Drawing.Size(672, 374); + this.tpgGroups.TabIndex = 2; + this.tpgGroups.Text = "Groups"; + this.tpgGroups.UseVisualStyleBackColor = true; + // + // pnlGroupDetail + // + this.pnlGroupDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlGroupDetail.AutoScroll = true; + this.pnlGroupDetail.Location = new System.Drawing.Point(312, 9); + this.pnlGroupDetail.Name = "pnlGroupDetail"; + this.pnlGroupDetail.Size = new System.Drawing.Size(353, 338); + this.pnlGroupDetail.TabIndex = 23; + // + // btnSearchGroup + // + this.btnSearchGroup.Enabled = false; + this.btnSearchGroup.Location = new System.Drawing.Point(228, 5); + this.btnSearchGroup.Name = "btnSearchGroup"; + this.btnSearchGroup.Size = new System.Drawing.Size(75, 23); + this.btnSearchGroup.TabIndex = 21; + this.btnSearchGroup.Text = "Search"; + this.btnSearchGroup.UseVisualStyleBackColor = true; + this.btnSearchGroup.Click += new System.EventHandler(this.btnSearchGroup_Click); + // + // txtSearchGroup + // + this.txtSearchGroup.Location = new System.Drawing.Point(44, 7); + this.txtSearchGroup.Name = "txtSearchGroup"; + this.txtSearchGroup.Size = new System.Drawing.Size(178, 21); + this.txtSearchGroup.TabIndex = 20; + this.txtSearchGroup.TextChanged += new System.EventHandler(this.txtSearchGroup_TextChanged); + this.txtSearchGroup.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearchGroup_KeyDown); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 10); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(36, 13); + this.label3.TabIndex = 19; + this.label3.Text = "Group"; + // + // btnNextGroup + // + this.btnNextGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnNextGroup.Enabled = false; + this.btnNextGroup.Location = new System.Drawing.Point(591, 347); + this.btnNextGroup.Name = "btnNextGroup"; + this.btnNextGroup.Size = new System.Drawing.Size(75, 23); + this.btnNextGroup.TabIndex = 18; + this.btnNextGroup.Text = "Next >"; + this.btnNextGroup.UseVisualStyleBackColor = true; + this.btnNextGroup.Click += new System.EventHandler(this.btnNextGroup_Click); + // + // btnPrevGroup + // + this.btnPrevGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnPrevGroup.Enabled = false; + this.btnPrevGroup.Location = new System.Drawing.Point(510, 347); + this.btnPrevGroup.Name = "btnPrevGroup"; + this.btnPrevGroup.Size = new System.Drawing.Size(75, 23); + this.btnPrevGroup.TabIndex = 17; + this.btnPrevGroup.Text = "< Previous"; + this.btnPrevGroup.UseVisualStyleBackColor = true; + this.btnPrevGroup.Click += new System.EventHandler(this.btnPrevGroup_Click); + // + // lblNrGroups + // + this.lblNrGroups.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblNrGroups.AutoSize = true; + this.lblNrGroups.Location = new System.Drawing.Point(6, 352); + this.lblNrGroups.Name = "lblNrGroups"; + this.lblNrGroups.Size = new System.Drawing.Size(80, 13); + this.lblNrGroups.TabIndex = 16; + this.lblNrGroups.Text = "0 groups found"; + this.lblNrGroups.Visible = false; + // + // columnHeader1 + // + this.columnHeader1.Text = "Place"; + this.columnHeader1.Width = 200; + // + // columnHeader2 + // + this.columnHeader2.Text = "Traffic"; + this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader2.Width = 50; + // + // lvwPlaces + // + this.lvwPlaces.AllowColumnReorder = true; + this.lvwPlaces.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lvwPlaces.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.Place, + this.Traffic}); + this.lvwPlaces.FullRowSelect = true; + this.lvwPlaces.GridLines = true; + this.lvwPlaces.HideSelection = false; + this.lvwPlaces.Location = new System.Drawing.Point(12, 35); + this.lvwPlaces.MultiSelect = false; + this.lvwPlaces.Name = "lvwPlaces"; + this.lvwPlaces.ShowGroups = false; + this.lvwPlaces.ShowItemToolTips = true; + this.lvwPlaces.Size = new System.Drawing.Size(294, 315); + this.lvwPlaces.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.lvwPlaces.TabIndex = 14; + this.lvwPlaces.UseCompatibleStateImageBehavior = false; + this.lvwPlaces.View = System.Windows.Forms.View.Details; + this.lvwPlaces.SelectedIndexChanged += new System.EventHandler(this.lvwPlaces_SelectedIndexChanged); + this.lvwPlaces.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvwPlaces_ColumnClick); + // + // Place + // + this.Place.Text = "Place"; + this.Place.Width = 200; + // + // Traffic + // + this.Traffic.Text = "Traffic"; + this.Traffic.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.Traffic.Width = 50; + // + // lvwGroups + // + this.lvwGroups.AllowColumnReorder = true; + this.lvwGroups.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lvwGroups.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader3, + this.columnHeader4}); + this.lvwGroups.FullRowSelect = true; + this.lvwGroups.GridLines = true; + this.lvwGroups.HideSelection = false; + this.lvwGroups.Location = new System.Drawing.Point(9, 34); + this.lvwGroups.MultiSelect = false; + this.lvwGroups.Name = "lvwGroups"; + this.lvwGroups.ShowGroups = false; + this.lvwGroups.ShowItemToolTips = true; + this.lvwGroups.Size = new System.Drawing.Size(294, 315); + this.lvwGroups.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.lvwGroups.TabIndex = 22; + this.lvwGroups.UseCompatibleStateImageBehavior = false; + this.lvwGroups.View = System.Windows.Forms.View.Details; + this.lvwGroups.SelectedIndexChanged += new System.EventHandler(this.lvwGroups_SelectedIndexChanged); + this.lvwGroups.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvwGroups_ColumnClick); + // + // columnHeader3 + // + this.columnHeader3.Text = "Group"; + this.columnHeader3.Width = 200; + // + // columnHeader4 + // + this.columnHeader4.Text = "Members"; + this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader4.Width = 50; + // // SearchConsole // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -366,6 +520,8 @@ namespace Radegast this.tpgPeople.PerformLayout(); this.tpgPlaces.ResumeLayout(false); this.tpgPlaces.PerformLayout(); + this.tpgGroups.ResumeLayout(false); + this.tpgGroups.PerformLayout(); this.ResumeLayout(false); } @@ -395,6 +551,19 @@ namespace Radegast public System.Windows.Forms.ColumnHeader Place; public System.Windows.Forms.ColumnHeader Traffic; public System.Windows.Forms.Panel pnlPlaceDetail; + public System.Windows.Forms.TabPage tpgGroups; + public System.Windows.Forms.Panel pnlGroupDetail; + public ListViewNoFlicker lvwGroups; + public System.Windows.Forms.ColumnHeader columnHeader3; + public System.Windows.Forms.ColumnHeader columnHeader4; + public System.Windows.Forms.Button btnSearchGroup; + public System.Windows.Forms.TextBox txtSearchGroup; + public System.Windows.Forms.Label label3; + public System.Windows.Forms.Button btnNextGroup; + public System.Windows.Forms.Button btnPrevGroup; + public System.Windows.Forms.Label lblNrGroups; + public System.Windows.Forms.ColumnHeader columnHeader1; + public System.Windows.Forms.ColumnHeader columnHeader2; } } diff --git a/Radegast/GUI/Consoles/SearchConsole.cs b/Radegast/GUI/Consoles/SearchConsole.cs index 7f199ac..63b27f9 100644 --- a/Radegast/GUI/Consoles/SearchConsole.cs +++ b/Radegast/GUI/Consoles/SearchConsole.cs @@ -60,17 +60,20 @@ namespace Radegast // Callbacks client.Directory.DirPeopleReply += new EventHandler(Directory_DirPeopleReply); client.Directory.DirPlacesReply += new EventHandler(Directory_DirPlacesReply); + client.Directory.DirGroupsReply += new EventHandler(Directory_DirGroupsReply); console = new FindPeopleConsole(instance, UUID.Random()); console.Dock = DockStyle.Fill; console.SelectedIndexChanged += new EventHandler(console_SelectedIndexChanged); pnlFindPeople.Controls.Add(console); lvwPlaces.ListViewItemSorter = new PlaceSorter(); + lvwGroups.ListViewItemSorter = new GroupSorter(); } void SearchConsole_Disposed(object sender, EventArgs e) { client.Directory.DirPeopleReply -= new EventHandler(Directory_DirPeopleReply); client.Directory.DirPlacesReply -= new EventHandler(Directory_DirPlacesReply); + client.Directory.DirGroupsReply -= new EventHandler(Directory_DirGroupsReply); } #endregion Construction and disposal @@ -378,5 +381,197 @@ namespace Radegast } } #endregion Places search + + #region Groups search + private UUID groupSearch; + private int groupMatches = 0; + private int groupStart = 0; + + void Directory_DirGroupsReply(object sender, DirGroupsReplyEventArgs e) + { + if (e.QueryID != groupSearch) return; + + if (InvokeRequired) + { + BeginInvoke(new MethodInvoker(() => Directory_DirGroupsReply(sender, e))); + return; + } + + lvwGroups.BeginUpdate(); + + if (e.MatchedGroups.Count == 0) + lvwGroups.Items.Clear(); + + foreach (DirectoryManager.GroupSearchData group in e.MatchedGroups) + { + if (group.GroupID == UUID.Zero) continue; + + ListViewItem item = new ListViewItem(); + item.Name = group.GroupID.ToString(); + item.Text = group.GroupName; + item.Tag = group; + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, group.Members.ToString())); + + lvwGroups.Items.Add(item); + } + lvwGroups.Sort(); + lvwGroups.EndUpdate(); + + groupMatches += e.MatchedGroups.Count; + btnNextGroup.Enabled = groupMatches > 100; + btnPrevGroup.Enabled = placeStart != 0; + + if (e.MatchedGroups.Count > 0 && e.MatchedGroups[e.MatchedGroups.Count - 1].GroupID == UUID.Zero) + groupMatches -= 1; + + lblNrGroups.Visible = true; + lblNrGroups.Text = string.Format("{0} groups found", groupMatches > 100 ? "More than " + (groupStart + 100).ToString() : (groupStart + groupMatches).ToString()); + } + + private void btnSearchGroup_Click(object sender, EventArgs e) + { + groupMatches = 0; + groupStart = 0; + lvwGroups.Items.Clear(); + groupSearch = client.Directory.StartGroupSearch(txtSearchGroup.Text.Trim(), 0); + } + + private void txtSearchGroup_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.SuppressKeyPress = e.Handled = true; + btnSearchGroup.PerformClick(); + } + } + + private void txtSearchGroup_TextChanged(object sender, EventArgs e) + { + if (txtSearchGroup.Text.Length > 1) + { + btnSearchGroup.Enabled = true; + } + else + { + btnSearchGroup.Enabled = false; + } + } + + private void btnPrevGroup_Click(object sender, EventArgs e) + { + groupMatches = 0; + groupStart -= 100; + lvwGroups.Items.Clear(); + groupSearch = client.Directory.StartGroupSearch(txtSearchGroup.Text.Trim(), groupStart); + } + + private void btnNextGroup_Click(object sender, EventArgs e) + { + groupMatches = 0; + groupStart += 100; + lvwGroups.Items.Clear(); + groupSearch = client.Directory.StartGroupSearch(txtSearchGroup.Text.Trim(), groupStart); + } + + private void lvwGroups_SelectedIndexChanged(object sender, EventArgs e) + { + foreach (Control c in pnlGroupDetail.Controls) + { + c.Dispose(); + } + pnlGroupDetail.Controls.Clear(); + + if (lvwGroups.SelectedItems.Count == 1) + { + try + { + DirectoryManager.GroupSearchData g = (DirectoryManager.GroupSearchData)lvwGroups.SelectedItems[0].Tag; + GroupDetails grpPanel = new GroupDetails(instance, new Group() { ID = g.GroupID, Name = g.GroupName }); + grpPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + grpPanel.Region = new System.Drawing.Region( + new System.Drawing.RectangleF( + grpPanel.tpGeneral.Left, grpPanel.tpGeneral.Top, grpPanel.tpGeneral.Width, grpPanel.tpGeneral.Height)); + pnlGroupDetail.Controls.Add(grpPanel); + } + catch { } + } + } + + private void lvwGroups_ColumnClick(object sender, ColumnClickEventArgs e) + { + GroupSorter sorter = (GroupSorter)lvwGroups.ListViewItemSorter; + switch (e.Column) + { + case 0: + sorter.SortBy = GroupSorter.SortByColumn.Name; + break; + + case 1: + sorter.SortBy = GroupSorter.SortByColumn.Members; + break; + } + + if (sorter.CurrentOrder == GroupSorter.SortOrder.Ascending) + sorter.CurrentOrder = GroupSorter.SortOrder.Descending; + else + sorter.CurrentOrder = GroupSorter.SortOrder.Ascending; + + lvwGroups.Sort(); + } + + public class GroupSorter : System.Collections.IComparer + { + public enum SortByColumn + { + Name, + Members + } + + public enum SortOrder + { + Ascending, + Descending + } + + public SortOrder CurrentOrder = SortOrder.Ascending; + public SortByColumn SortBy = SortByColumn.Name; + + public int Compare(object x, object y) + { + ListViewItem item1 = (ListViewItem)x; + ListViewItem item2 = (ListViewItem)y; + DirectoryManager.GroupSearchData group1 = (DirectoryManager.GroupSearchData)item1.Tag; + DirectoryManager.GroupSearchData group2 = (DirectoryManager.GroupSearchData)item2.Tag; + + switch (SortBy) + { + case SortByColumn.Name: + if (CurrentOrder == SortOrder.Ascending) + return string.Compare(item1.Text, item2.Text); + else + return string.Compare(item2.Text, item1.Text); + + case SortByColumn.Members: + if (CurrentOrder == SortOrder.Ascending) + { + if (group1.Members > group2.Members) + return 1; + else if (group1.Members < group2.Members) + return -1; + } + else + { + if (group1.Members > group2.Members) + return -1; + else if (group1.Members < group2.Members) + return 1; + } + break; + } + + return 0; + } + } + #endregion Groups search } } diff --git a/Radegast/Radegast.csproj b/Radegast/Radegast.csproj index 07267d9..63d8b65 100644 --- a/Radegast/Radegast.csproj +++ b/Radegast/Radegast.csproj @@ -77,22 +77,6 @@ - - False - ..\..\libopenmetaverse\bin\OpenMetaverse.dll - - - False - ..\..\libopenmetaverse\bin\OpenMetaverse.Http.dll - - - False - ..\..\libopenmetaverse\bin\OpenMetaverse.StructuredData.dll - - - False - ..\..\libopenmetaverse\bin\OpenMetaverseTypes.dll - 3.5 @@ -1065,6 +1049,24 @@ PreserveNewest + + + {A195EB92-3AC5-4443-8D65-8052480A21DA} + OpenMetaverse.Http + + + {18015F8B-CE5A-4BE0-88C4-6EF8AA7743CE} + OpenMetaverse.StructuredData + + + {FA1077AE-9D37-4097-8F07-897C3531115B} + OpenMetaverseTypes + + + {6B306F2F-3F4F-4C2B-B60A-F1D6B935D9A4} + OpenMetaverse + +