示例#1
0
        private void NewTab(OpenedArchive CurTab, string name)
        {
            var NewPage = CurTab.Tab;

            OpenedArchives.Controls.Add(NewPage);
            NewPage.Location = new System.Drawing.Point(4, 22);
            // NewPage.Name = name;
            NewPage.Padding  = new System.Windows.Forms.Padding(3);
            NewPage.Size     = new System.Drawing.Size(604, 412);
            NewPage.TabIndex = OpenedArchives.TabCount;
            NewPage.Text     = name;
            NewPage.UseVisualStyleBackColor = true;
            NewPage.Font = OpenedArchives.Font;
            NewPage.Controls.Add(CurTab.tree);
            CurTab.Tab = NewPage;

            NodeStuff.GenTreeNodes(CurTab);
            CurTab.tree.Size      = NewPage.Size;
            CurTab.tree.BackColor = System.Drawing.SystemColors.Control;
            CurTab.tree.Font      = OpenedArchives.Font;

            OpenedArchives.TabIndex = NewPage.TabIndex;
            if (!OpenedArchives.Visible)
            {
                OpenedArchives.Visible = true;
            }
            if (!XafMenuItem.Enabled)
            {
                XafMenuItem.Enabled = true;
            }
        }
示例#2
0
        public static void GenTreeNodes(OpenedArchive openedArchive)
        {
            foreach (var entry in openedArchive.FileEntries)
            {
                string path = entry.Path;

                //split by ~~dot~~ backslashes to get nodes names
                var nodeNames = path.Split('\\');
                //TreeNode to remember node level
                TreeNode lastNode = null;

                //iterate through all node names
                foreach (string nodeName in nodeNames)
                {
                    //values for name and tag (tag is empty string by default)
                    string name     = nodeName;
                    string tagValue = string.Empty;

                    //var used for finding existing node
                    TreeNode existingNode = null;
                    //new node to add to tree
                    TreeNode newNode = new TreeNode(name);
                    newNode.Tag = tagValue;
                    //collection of subnodes to search for node name (to check if node exists)
                    //in first pass, that collection is collection of treeView's nodes (first level)
                    TreeNodeCollection nodesCollection = openedArchive.tree.Nodes;

                    //with first pass, this will be null, but in every other, this will hold last added node.
                    if (lastNode != null)
                    {
                        nodesCollection = lastNode.Nodes;
                    }

                    //look into collection if node is already there (method checks only first level of node collection)
                    existingNode = FindNode(nodesCollection, name);
                    //node is found? In that case, skip it but mark it as last "added"
                    if (existingNode != null)
                    {
                        lastNode = existingNode;
                        continue;
                    }
                    else //not found so add it to collection and mark node as last added.
                    {
                        nodesCollection.Add(newNode);
                        lastNode = newNode;
                    }
                }
            }
        }
示例#3
0
        private void ParseFarArchive(OpenedArchive CurArchive)
        {
            CurArchive.Archive = new FSARArchive();
            Byte[] Header = new Byte[0x20];
            Byte[] FileTable;

            // Read header
            FSARHelper.fastCopyBlock(CurArchive.Data, 0, Header, 0, Header.Length);
            CurArchive.Archive.Header = FSARRead.ParseHeader(Header);

            // Parse the file headers
            FileTable = new Byte[CurArchive.Archive.Header.FileTableEnd];
            FSARHelper.fastCopyBlock(CurArchive.Data, 0x20, FileTable, 0, FileTable.Length);
            CurArchive.FileEntries = FSARRead.GetFileEntries(FileTable, CurArchive.Archive.Header.FileTableObjects);
        }