public void SetResources(ResourceViewManager.ResourceList resources, SimPe.Interfaces.Files.IPackageFile pkg) { ResourceViewManager.ResourceNameList nn = new ResourceViewManager.ResourceNameList(); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in resources) { nn.Add(new NamedPackedFileDescriptor(pfd, pkg)); } SetResources(nn); }
internal void SetResources(ResourceViewManager.ResourceNameList resources) { ResourceViewManager.ResourceNameList rnl = this.SelectedItems; this.Clear(); seltimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); this.CancelThreads(); lock (names) { foreach (NamedPackedFileDescriptor pfd in names) { pfd.Descriptor.ChangedUserData -= new SimPe.Events.PackedFileChanged(Descriptor_ChangedUserData); pfd.Descriptor.DescriptionChanged -= new EventHandler(Descriptor_DescriptionChanged); pfd.Descriptor.ChangedData -= new SimPe.Events.PackedFileChanged(Descriptor_ChangedData); } names.Clear(); if (FileTable.WrapperRegistry != null) { lv.SmallImageList = FileTable.WrapperRegistry.WrapperImageList; } //if (resources != this.resources) { this.Clear(); foreach (NamedPackedFileDescriptor pfd in resources) { bool add = true; if (curfilter != null) { if (curfilter.Active) { add = !curfilter.IsFiltered(pfd.Descriptor); } } if (add) { names.Add(pfd); pfd.Descriptor.ChangedData += new SimPe.Events.PackedFileChanged(Descriptor_ChangedData); pfd.Descriptor.DescriptionChanged += new EventHandler(Descriptor_DescriptionChanged); pfd.Descriptor.ChangedUserData += new SimPe.Events.PackedFileChanged(Descriptor_ChangedUserData); } } try { lv.VirtualListSize = 0; lv.VirtualListSize = names.Count; } catch //this hack is required because whidbey (.NET 2) has a bug { System.Diagnostics.Debug.WriteLine("Suppressed VirtualListSize exception."); } SortResources(); foreach (NamedPackedFileDescriptor q in rnl) { for (int i = 0; i < names.Count; i++) { if (names[i].Descriptor == q.Descriptor) { lv.SelectedIndices.Add(i); break; } } } } lastresources = resources; DoSignalSelectionChanged(Handle); } }