示例#1
0
        /// <summary>
        /// Opens given IPF file.
        /// </summary>
        /// <param name="filePath"></param>
        private void Open(string filePath)
        {
            // Reset everything
            TreeFolders.Nodes.Clear();
            LstFiles.Items.Clear();
            ResetPreview();

            _folders.Clear();
            _files.Clear();

            LblVersion.Text  = "";
            LblFileName.Text = "";

            // Open IPF
            try
            {
                _openedIpf = new Ipf(filePath);
                _openedIpf.Load();
            }
            catch (IOException)
            {
                _openedIpf = null;
                MessageBox.Show("Failed to open file, it's already in use.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create file list
            var paths = new List <string>();

            foreach (var ipfFile in _openedIpf.Files)
            {
                paths.Add(ipfFile.FullPath);
                _files.Add(ipfFile.FullPath, ipfFile);
            }

            // Create fil tree
            PopulateTreeView(TreeFolders, paths, '/');

            // Status info
            LblVersion.Text  = "Version " + _openedIpf.Footer.NewVersion;
            LblFileName.Text = filePath;

            // Open first node if there only is one
            if (TreeFolders.Nodes.Count == 1)
            {
                TreeFolders.SelectedNode = TreeFolders.Nodes[0];
                TreeFolders.SelectedNode.Toggle();
            }

            // Show lists and enabled pack extract button
            BtnExtractPack.Enabled = true;
            SplMain.Visible        = true;
        }
示例#2
0
        /// <summary>
        /// Opens given IPF file.
        /// </summary>
        /// <param name="filePath"></param>
        private void Open(string filePath)
        {
            if (Path.GetExtension(filePath) == ".ies")
            {
                this.ResetPreview();

                var iesData = File.ReadAllBytes(filePath);
                var iesFile = new IesFile(iesData);

                Invoke((MethodInvoker) delegate
                {
                    GridPreview.SuspendDrawing();

                    foreach (var iesColumn in iesFile.Columns)
                    {
                        GridPreview.Columns.Add(iesColumn.Name, iesColumn.Name);
                    }

                    foreach (var iesRow in iesFile.Rows)
                    {
                        var row = new DataGridViewRow();
                        row.CreateCells(GridPreview);

                        var i = 0;
                        foreach (var iesColumn in iesFile.Columns)
                        {
                            row.Cells[i++].Value = iesRow[iesColumn.Name];
                        }

                        GridPreview.Rows.Add(row);
                    }

                    GridPreview.ResumeDrawing();

                    GridPreview.Visible = true;
                });

                SplMain.Visible = true;

                return;
            }

            // Reset everything
            TreeFolders.Nodes.Clear();
            LstFiles.Items.Clear();
            ResetPreview();

            _folders.Clear();
            _files.Clear();

            LblVersion.Text  = "";
            LblFileName.Text = "";

            // Open IPF
            try
            {
                _openedIpf = new Ipf(filePath);
                _openedIpf.Load();
            }
            catch (IOException)
            {
                _openedIpf = null;
                MessageBox.Show("Failed to open file, it's already in use.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create file list
            var paths = new List <string>();

            foreach (var ipfFile in _openedIpf.Files)
            {
                paths.Add(ipfFile.FullPath);
                _files.Add(ipfFile.FullPath, ipfFile);
            }

            // Create fil tree
            PopulateTreeView(TreeFolders, paths, '/');

            // Status info
            LblVersion.Text  = "Version " + _openedIpf.Footer.NewVersion;
            LblFileName.Text = filePath;

            // Open first node if there only is one
            if (TreeFolders.Nodes.Count == 1)
            {
                TreeFolders.SelectedNode = TreeFolders.Nodes[0];
                TreeFolders.SelectedNode.Toggle();
            }

            // Show lists and enabled pack extract button
            BtnExtractPack.Enabled = true;
            SplMain.Visible        = true;
        }