Esempio n. 1
0
        public override void LaunchEditor(FileSystem fs, File file)
        {
            var data = file.GetData();

            var ms            = new MemoryStream(data);
            var hyperTextFile = new HyperTextFile();

            try
            {
                hyperTextFile.Open(ms);
            }
            finally
            {
                ms.Close();
            }

            if (hyperTextFile.EmbeddedTextureFile != null)
            {
                ShowForm(file, hyperTextFile.EmbeddedTextureFile);
            }
            else
            {
                MessageBox.Show("There are no embedded textures in the selected HyperText file to edit.", "Edit",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 2
0
        public override void LaunchEditor(FileSystem fs, File file)
        {
            var data = file.GetData();

            var ms = new MemoryStream(data);
            var modelFile = new ModelFile();
            try
            {
                modelFile.Open(ms);
            }
            finally
            {
                ms.Close();
            }

            if (modelFile.EmbeddedTextureFile != null)
            {
                ShowForm(file, modelFile.EmbeddedTextureFile);
            }
            else
            {
                MessageBox.Show("There are no embedded textures in the selected model file to edit.", "Edit",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 3
0
        public Control GetView(File file)
        {
            var data = file.GetData();

            TextBox textBox = new TextBox();
            textBox.Font = new Font("Courier New", 10);
            textBox.ReadOnly = true;
            textBox.BackColor = SystemColors.Window;
            textBox.Text = Encoding.ASCII.GetString(data);
            textBox.Multiline = true;
            textBox.ScrollBars = ScrollBars.Both;
            textBox.SelectionStart = 0;
            textBox.SelectionLength = 0;
            textBox.WordWrap = false;
            return textBox;
        }
Esempio n. 4
0
        public virtual void LaunchEditor(FileSystem fs, File file)
        {
            var data = file.GetData();

            var ms = new MemoryStream(data);
            var textureFile = new TextureFile();
            try
            {
                textureFile.Open(ms);
            }
            finally
            {
                ms.Close();
            }

            ShowForm(file, textureFile);
        }
Esempio n. 5
0
        public virtual void LaunchEditor(FileSystem fs, File file)
        {
            var data = file.GetData();

            var ms          = new MemoryStream(data);
            var textureFile = new TextureFile();

            try
            {
                textureFile.Open(ms);
            }
            finally
            {
                ms.Close();
            }

            ShowForm(file, textureFile);
        }
Esempio n. 6
0
        public void LaunchEditor(FileSystem fs, File file)
        {
            if (fs is RealFileSystem)
            {
                // We'll edit RealFileSystems on the spot... no memory caching
                // Some of the files are pretty big...

                DirectoryInfo parent = new DirectoryInfo((fs as RealFileSystem).RealDirectory).Parent;
                string filename = parent == null ? file.FullName : Path.Combine(parent.FullName, file.FullName);

                var info = new ProcessStartInfo(filename);
                info.UseShellExecute = true;

                var p = Process.Start(info);
                if (p != null)
                {
                    p.WaitForExit();
                }
            }
            else
            {
                // Export the file to a temporary file and load it up

                string tempFileName = Path.Combine(Path.GetTempPath(), file.Name);
                System.IO.File.WriteAllBytes(tempFileName, file.GetData());

                var info = new ProcessStartInfo(tempFileName);
                info.UseShellExecute = true;

                var p = Process.Start(info);
                if (p != null)
                {
                    p.WaitForExit();

                    if (p.ExitCode == 0)
                    {
                        var data = System.IO.File.ReadAllBytes(tempFileName);
                        file.SetData(data);
                    }
                }

            }
        }
Esempio n. 7
0
        public void LaunchEditor(FileSystem fs, File file)
        {
            if (fs is RealFileSystem)
            {
                // We'll edit RealFileSystems on the spot... no memory caching
                // Some of the files are pretty big...

                DirectoryInfo parent   = new DirectoryInfo((fs as RealFileSystem).RealDirectory).Parent;
                string        filename = parent == null ? file.FullName : Path.Combine(parent.FullName, file.FullName);

                var info = new ProcessStartInfo(filename);
                info.UseShellExecute = true;

                var p = Process.Start(info);
                if (p != null)
                {
                    p.WaitForExit();
                }
            }
            else
            {
                // Export the file to a temporary file and load it up

                string tempFileName = Path.Combine(Path.GetTempPath(), file.Name);
                System.IO.File.WriteAllBytes(tempFileName, file.GetData());

                var info = new ProcessStartInfo(tempFileName);
                info.UseShellExecute = true;

                var p = Process.Start(info);
                if (p != null)
                {
                    p.WaitForExit();

                    if (p.ExitCode == 0)
                    {
                        var data = System.IO.File.ReadAllBytes(tempFileName);
                        file.SetData(data);
                    }
                }
            }
        }
Esempio n. 8
0
 private void ExtractToPath(Directory dir, string path)
 {
     foreach (var item in dir)
     {
         if (item.IsDirectory)
         {
             try
             {
                 IODirectory.CreateDirectory(path + item.Name);
                 ExtractToPath(item as Directory, path + item.Name + "\\");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             File   file = item as File;
             byte[] data = file.GetData();
             IOFile.WriteAllBytes(Path.Combine(path, file.Name), data);
         }
     }
 }
Esempio n. 9
0
        private void tsbExportSelected_Click(object sender, EventArgs e)
        {
            if (_fs == null)
            {
                return;
            }

            if (lvFiles.SelectedItems.Count == 1)
            {
                File file = lvFiles.SelectedItems[0].Tag as File;

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Title = "Export...";

                if (_lastImportExportPath != null)
                {
                    sfd.InitialDirectory = _lastImportExportPath;
                    sfd.FileName         = Path.Combine(_lastImportExportPath, file.Name);
                }
                else
                {
                    sfd.FileName = file.Name;
                }


                sfd.OverwritePrompt = true;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    _lastImportExportPath = IODirectory.GetParent(sfd.FileName).FullName;

                    using (new WaitCursor(this))
                    {
                        byte[] data = file.GetData();
                        IOFile.WriteAllBytes(sfd.FileName, data);
                    }
                }
            }
            else if (lvFiles.SelectedItems.Count > 1)
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                fbd.Description         = "Export Selected...";
                fbd.ShowNewFolderButton = true;
                fbd.SelectedPath        = _lastImportExportPath;

                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    _lastImportExportPath = fbd.SelectedPath;

                    string path = fbd.SelectedPath;

                    using (new WaitCursor(this))
                    {
                        foreach (ListViewItem item in lvFiles.SelectedItems)
                        {
                            File   file = item.Tag as File;
                            byte[] data = file.GetData();
                            IOFile.WriteAllBytes(Path.Combine(path, file.Name), data);
                        }
                    }

                    MessageBox.Show("All selected files exported.", "Export Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }