void doUpdateUserList() { var items = allPeersInCircle; userListView.BeginUpdate(); while (userListView.Items.Count < items.Length) { ListViewItem i = new ListViewItem(); i.SubItems.Add(""); i.SubItems.Add(""); i.SubItems.Add(""); userListView.Items.Add(i); } while (userListView.Items.Count > items.Length) { userListView.Items.RemoveAt(0); } for (int i = 0; i < items.Length; i++) { userListView.Items[i].Tag = items[i]; /* string s1 = items[i].username; * string s2 = ""; * * for (int i2 = 0; i2 < s1.Length; i2++) * if (char.IsLetterOrDigit(s1[i2]) || s1[i2] == ' ' || s1[i2] == '_') * s2 += s1[i2];*/ string s2 = items[i].username; if (items[i].maybeDead) { userListView.Items[i].ForeColor = SystemColors.GrayText; } else { userListView.Items[i].ForeColor = SystemColors.WindowText; } Font b = userListView.Font; if (items[i].behindDoubleNAT) { b = new Font("Comic Sans MS", b.SizeInPoints); } if (items[i].probablyDead) { userListView.Items[i].Font = new Font(b, FontStyle.Italic); } else { userListView.Items[i].Font = new Font(b, FontStyle.Regular); } if (items[i].afk.HasValue) { userListView.Items[i].Text = s2 + (items[i].afk.Value ? " (AFK)" : ""); } else { userListView.Items[i].Text = s2; } userListView.Items[i].SubItems[1].Text = (items[i].buildNumber.ToString()); userListView.Items[i].SubItems[2].Text = (ByteFormatter.formatBytes(items[i].share)); userListView.Items[i].SubItems[3].Text = (items[i].description); } userListView.EndUpdate(); }
void doUpdate(Model.Commands.FileListing list) { connected = true; ignoreReselect = true; foldersView.BeginUpdate(); //foldersView.Nodes.Clear(); TreeNode root = traverse(list.path); root.Nodes.Clear(); foreach (Model.Commands.FSListing i in list.folders) { TreeNode t = new TreeNode(i.name); t.Name = i.name; root.Nodes.Add(t); } foldersView.EndUpdate(); filesView.BeginUpdate(); filesView.Items.Clear(); if (list.path != "/") { filesView.Items.Add(new ListViewItem("..")); } foreach (Model.Commands.FSListing i in list.folders) { ListViewItem l = new ListViewItem(); l.Text = i.name; l.Name = i.name; l.SubItems.Add(ByteFormatter.formatBytes(i.size)); l.SubItems.Add(DateFormatter.formatDate(i.updated)); l.Tag = i; filesView.Items.Add(l); try { if (!iconCache.Images.ContainsKey("Folder")) { iconCache.Images.Add("Folder", IconReader.GetFolderIcon(IconReader.IconSize.Small, IconReader.FolderType.Closed)); } l.ImageKey = "Folder"; } catch { //don't care } } foreach (Model.Commands.FSListing i in list.files) { ListViewItem l = new ListViewItem(); l.Text = i.name; l.Name = i.name; l.SubItems.Add(ByteFormatter.formatBytes(i.size)); l.SubItems.Add(DateFormatter.formatDate(i.updated)); l.Tag = i; filesView.Items.Add(l); string s = i.name; if (i.name.Contains(".")) { s = s.Substring(s.LastIndexOf(".") + 1); } try { if (!iconCache.Images.ContainsKey(s)) { iconCache.Images.Add(s, IconReader.GetFileIcon("filename." + s, IconReader.IconSize.Small, false)); } l.ImageKey = s; } catch { //don't care } } filesView.EndUpdate(); ignoreReselect = false; updateFilterList(); }