예제 #1
0
        void DoTheSorting()
        {
            BeginUpdate();

            ResourceViewManager.ResourceNameList oldsel = this.SelectedItems;

            lv.SelectedIndices.Clear();
            names.SortByColumn(sc, asc);
            bool first = true;

            foreach (NamedPackedFileDescriptor pfd in oldsel)
            {
                int i = names.IndexOf(pfd);
                if (i > 0)
                {
                    if (first)
                    {
                        lv.EnsureVisible(i);
                    }
                    lv.SelectedIndices.Add(i);
                    first = false;
                }
            }
            EndUpdate(false);
        }
예제 #2
0
        public static void AddInstances(ResourceMaps.LongMap map, ResourceTreeNodeExt tn, bool group, bool type)
        {
            List <ResourceTreeNodeExt> nodelist = new List <ResourceTreeNodeExt>();

            foreach (ulong inst in map.Keys)
            {
                ResourceViewManager.ResourceNameList list = map[inst];
                ResourceTreeNodeExt node = new ResourceTreeNodeExt(inst, list, "0x" + Helper.HexString(inst));
                if (group)
                {
                    ResourceTreeNodeExt groupnode = new ResourceTreeNodeExt(inst, list, "Groups");
                    AddSubNodesForGroups(groupnode, list);
                    node.Nodes.Add(groupnode);
                }
                if (type)
                {
                    ResourceTreeNodeExt typenode = new ResourceTreeNodeExt(inst, list, "Types");
                    ResourceTreeNodesByGroup.AddSubNodesForTypes(typenode, list);
                    node.Nodes.Add(typenode);
                }

                nodelist.Add(node);
            }

            nodelist.Sort();
            foreach (ResourceTreeNodeExt node in nodelist)
            {
                tn.Nodes.Add(node);
            }
        }
예제 #3
0
        public ResoureNameSorter(ResourceListViewExt parent, ResourceViewManager.ResourceNameList names, int ticket)
        {
            int numberofthreads = Helper.WindowsRegistry.SortProcessCount;

            handle      = parent.Handle;
            this.parent = parent;
            this.ticket = ticket;
            this.names  = new Stack <NamedPackedFileDescriptor>();
            foreach (NamedPackedFileDescriptor pfd in names)
            {
                this.names.Push(pfd);
            }


            counter = 0;
            if (Helper.WindowsRegistry.AsynchronSort)
            {
                started = numberofthreads;
                for (int i = 0; i < numberofthreads; i++)
                {
                    System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ReadNames));
                    t.Name = "Resource Sorting Thread " + i + "." + Helper.HexString(ticket);
                    t.Start();
                }
            }
            else
            {
                started = 1;
                ReadNames();
            }
        }
예제 #4
0
 public ResourceMaps()
 {
     all      = new ResourceViewManager.ResourceNameList();
     typemap  = new IntMap();
     groupmap = new IntMap();
     instmap  = new LongMap();
 }
예제 #5
0
        public ResourceListViewExt()
        {
            noselectevent = 0;
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            cache = new Dictionary <int, ResourceListItemExt>();

            lastresources = null;
            seltimer      = new System.Threading.Timer(new System.Threading.TimerCallback(SelectionTimerCallback), Handle, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
            sortticket    = 0;
            sc            = ResourceViewManager.SortColumn.Offset;
            asc           = true;
            InitializeComponent();
            names    = new ResourceViewManager.ResourceNameList();
            myhandle = Handle;

            if (!Helper.WindowsRegistry.ResourceListShowExtensions)
            {
                lv.Columns.Remove(clTName);
            }
            if (!Helper.WindowsRegistry.HiddenMode)
            {
                lv.Columns.Remove(clSize);
                lv.Columns.Remove(clOffset);
            }

            colHeads = new List <ColumnHeader>(new ColumnHeader[] { clType, clTName, clGroup, clInstHi, clInst, clOffset, clSize });
        }
예제 #6
0
        public static void AddGroups(ResourceMaps.IntMap map, ResourceTreeNodeExt tn, bool type, bool inst)
        {
            List <ResourceTreeNodeExt> nodelist = new List <ResourceTreeNodeExt>();

            foreach (uint group in map.Keys)
            {
                ResourceViewManager.ResourceNameList list = map[group];
                ResourceTreeNodeExt node = new ResourceTreeNodeExt(group, list, "0x" + Helper.HexString(group));
                if (type)
                {
                    ResourceTreeNodeExt typenode = new ResourceTreeNodeExt(group, list, "Types");
                    AddSubNodesForTypes(typenode, list);
                    node.Nodes.Add(typenode);
                }

                if (inst)
                {
                    ResourceTreeNodeExt instnode = new ResourceTreeNodeExt(group, list, "Instances");
                    AddSubNodesForInstances(instnode, list);
                    node.Nodes.Add(instnode);
                }

                nodelist.Add(node);
            }

            nodelist.Sort();
            foreach (ResourceTreeNodeExt node in nodelist)
            {
                tn.Nodes.Add(node);
            }
        }
예제 #7
0
 public ResourceTreeTypeNodeExt(ResourceViewManager.ResourceNameList list, uint type)
     : base(type, list, "")
 {
     this.type               = type;
     this.ImageIndex         = ResourceViewManager.GetIndexForResourceType(type);
     this.SelectedImageIndex = this.ImageIndex;
     SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(type);
     this.Text = ta.Name + " (" + ta.shortname + ") (" + list.Count + ")";
 }
예제 #8
0
        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);
        }
예제 #9
0
        public ResourceTreeNodeExt(ulong id, ResourceViewManager.ResourceNameList list, string text)
            : base()
        {
            this.id   = id;
            this.list = list;

            this.ImageIndex         = 0;
            this.Text               = text + " (" + list.Count + ")";
            this.SelectedImageIndex = this.ImageIndex;
        }
예제 #10
0
        public static void AddType(ResourceMaps.IntMap map, ResourceTreeNodeExt tn)
        {
            List <ResourceTreeNodeExt> nodelist = new List <ResourceTreeNodeExt>();

            foreach (uint type in map.Keys)
            {
                ResourceViewManager.ResourceNameList list = map[type];
                ResourceTreeNodeExt node = new ResourceTreeTypeNodeExt(list, type);
                nodelist.Add(node);
            }

            nodelist.Sort();
            foreach (ResourceTreeNodeExt node in nodelist)
            {
                tn.Nodes.Add(node);
            }
        }
예제 #11
0
        static void AddSubNodesForGroups(ResourceTreeNodeExt node, ResourceViewManager.ResourceNameList resources)
        {
            ResourceMaps.IntMap map = new ResourceMaps.IntMap();
            foreach (NamedPackedFileDescriptor pfd in resources)
            {
                ResourceViewManager.ResourceNameList list;
                if (!map.ContainsKey(pfd.Descriptor.Group))
                {
                    list = new ResourceViewManager.ResourceNameList();
                    map.Add(pfd.Descriptor.Group, list);
                }
                else
                {
                    list = map[pfd.Descriptor.Group];
                }

                list.Add(pfd);
            }

            ResourceTreeNodesByGroup.AddGroups(map, node, false, false);
        }
예제 #12
0
        public static void AddSubNodesForInstances(ResourceTreeNodeExt node, ResourceViewManager.ResourceNameList resources)
        {
            ResourceMaps.LongMap map = new ResourceMaps.LongMap();
            foreach (NamedPackedFileDescriptor pfd in resources)
            {
                ResourceViewManager.ResourceNameList list;
                if (!map.ContainsKey(pfd.Descriptor.LongInstance))
                {
                    list = new ResourceViewManager.ResourceNameList();
                    map.Add(pfd.Descriptor.LongInstance, list);
                }
                else
                {
                    list = map[pfd.Descriptor.LongInstance];
                }

                list.Add(pfd);
            }

            ResourceTreeNodesByInstance.AddInstances(map, node, false, false);
        }
예제 #13
0
        public static void AddSubNodesForTypes(ResourceTreeNodeExt node, ResourceViewManager.ResourceNameList resources)
        {
            ResourceMaps.IntMap map = new ResourceMaps.IntMap();
            foreach (NamedPackedFileDescriptor pfd in resources)
            {
                ResourceViewManager.ResourceNameList list;
                if (!map.ContainsKey(pfd.Descriptor.Type))
                {
                    list = new ResourceViewManager.ResourceNameList();
                    map.Add(pfd.Descriptor.Type, list);
                }
                else
                {
                    list = map[pfd.Descriptor.Type];
                }

                list.Add(pfd);
            }

            ResourceTreeNodesByType.AddType(map, node);
        }
예제 #14
0
        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);
            }
        }