Ejemplo n.º 1
0
        /// <summary>
        /// Performs the extraction of an ARZ file.
        /// </summary>
        private void DoArzExtraction()
        {
            try
            {
                bool canceled = false;
                foreach (string recordID in arzProv.GetKeyTable(MainForm.ARZFile))
                {
                    if (canceled)
                    {
                        break;
                    }

                    // update label with recordID
                    this.recordIdBeingProcessed = recordID;
                    this.Invoke(new MethodInvoker(this.UpdateLabel));

                    // Write the record
                    var dbc = arzProv.GetRecordNotCached(MainForm.ARZFile, recordID);
                    DBRecordCollectionProvider.Write(dbc, this.BaseFolder);

                    // Update progressbar
                    this.Invoke(new MethodInvoker(this.IncrementProgress));

                    // see if we need to cancel
                    Monitor.Enter(this);
                    canceled = this.cancel;
                    Monitor.Exit(this);
                }

                // notify complete.
                this.Invoke(new MethodInvoker(this.ExtractComplete));
            }
            catch (Exception err)
            {
                // notify failure
                this.exception = err;
                this.Invoke(new MethodInvoker(this.ExtractFailed));
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds the tree view.  Assumes the list is pre-sorted.
        /// </summary>
        private void BuildTreeView()
        {
            // Display a wait cursor while the TreeNodes are being created.
            Cursor.Current = Cursors.WaitCursor;

            this.treeViewTOC.BeginUpdate();
            this.treeViewTOC.Nodes.Clear();

            int      maxPaths = 20;        // Hopefully there are no paths more than 20 deep.
            TreeNode lastNode = null;

            // Hold the nodes from the previous record.
            // We save these so we do not need to search the treeview
            TreeNode[] lastNodes = new TreeNode[maxPaths];
            string     aggSubPath;

            string[] paths     = new string[maxPaths];
            string[] prevPaths = new string[maxPaths];

            string[] dataRecords;
            if (fileType == CompressedFileType.ArzFile)
            {
                dataRecords = arzProv.GetKeyTable(arzFile);
            }
            else if (fileType == CompressedFileType.ArcFile)
            {
                dataRecords = arcProv.GetKeyTable(arcFile);
            }
            else
            {
                return;
            }

            // We failed so return.
            if (dataRecords == null)
            {
                return;
            }

            foreach (string recordID in dataRecords)
            {
                // Holds the aggregate path
                aggSubPath = string.Empty;
                paths.Initialize();
                string[] subPaths = recordID.Split('\\');
                int      count    = 0;

                foreach (string subPath in subPaths)
                {
                    // We only add if not the last item in the path
                    // which should be the dbr.
                    if (count < subPaths.Length - 1)
                    {
                        aggSubPath  += subPath + '\\';
                        paths[count] = aggSubPath;

                        // See if the paths are still the same.
                        if (paths[count] != prevPaths[count])
                        {
                            if (lastNode == null || count == 0)
                            {
                                // The very top of the tree.
                                lastNode = this.treeViewTOC.Nodes.Add(aggSubPath, subPath);
                            }
                            else
                            {
                                // Add a new node to the previous one in the tree.
                                lastNode = lastNode.Nodes.Add(aggSubPath, subPath);
                            }

                            // Save this guy so we do not need to search.
                            lastNodes[count] = lastNode;
                        }
                        else
                        {
                            // Use the previous TreeNode since the strings match.
                            // This saves the expensive lookup.
                            lastNode = lastNodes[count];
                        }
                    }
                    else
                    {
                        // This is the last thing so we just add it.
                        aggSubPath += subPath;

                        // There might not be any sub folders so we add the file to the root
                        if (lastNode == null || count == 0)
                        {
                            // We do not assign last node since we are still at the root.
                            this.treeViewTOC.Nodes.Add(aggSubPath, subPath);
                            lastNode = null;
                        }
                        else
                        {
                            lastNode = lastNode.Nodes.Add(aggSubPath, subPath);
                        }

                        // Clear out and save the previous paths.
                        prevPaths.Initialize();
                        Array.Copy(paths, prevPaths, paths.Length);
                    }

                    count++;
                }
            }

            // Reset the cursor to the default for all controls.
            Cursor.Current = Cursors.Default;

            this.treeViewTOC.EndUpdate();
        }