Exemple #1
0
        private void OpenFile(string path)
        {
            menuToolsQuickCRC.Enabled = false;
            _filePath = path;
            var fs          = new FileStream(_filePath, FileMode.Open, FileAccess.ReadWrite);//File.OpenWrite(_filePath));
            var type        = ModuleHelper.GetModuleType(_filePath, fs);
            var tempContext = ModuleHelper.CreateByType(type);

            if (tempContext == null)
            {
                MessageBox.Show("This file is unsupported!");
                fs.Close();
                return;
            }
            fs.Seek(0, SeekOrigin.Begin);
            if (!tempContext.Open(fs))
            {
                MessageBox.Show(string.Format("Error: {0}", tempContext.GetErrorMessage()));
                fs.Close();
                return;
            }
            var fileSize = fs.Length;

            fs.Close();

            //Start the open process
            LoadText(_filePath);
            treeView.Nodes.Clear();
            var nodes = tempContext.GetExplorerTopNode();

            treeView.Nodes.Add(nodes);
            treeView.ExpandAll();
            lvFileTree.Nodes.Clear();
            nodes = tempContext.GetFileSystemTopNode();
            if (nodes != null)
            {
                lvFileTree.Nodes.Add(nodes);
            }
            lvFileTree.ExpandAll();

            _currentContext       = tempContext;
            treeView.SelectedNode = treeView.Nodes[0];

            if (type == ModuleType.CCI)
            {
                file_path = path;
                var cciContext = (CCIContext)_currentContext;
                menuCci.Visible = false;
                if (cciContext.NcsdInfo.CCI_File_Status == 1 || cciContext.NcsdInfo.CCI_File_Status == 2) //Enable CCI Size Manipulation by 3DSGuy
                {
                    handleCciMenu(cciContext);
                }
            }
            menuFileSave.Enabled      = _currentContext.CanCreate();
            menuToolsQuickCRC.Enabled = true;
        }