Esempio n. 1
0
        private void btnUncompress_Click(object sender, EventArgs e)
        {
            System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Load(Application.StartupPath + Path.DirectorySeparatorChar +
                                                                         "Plugins" + Path.DirectorySeparatorChar + "SDATLang.xml");
            xml = xml.Element(pluginHost.Get_Language());
            xml = xml.Element("iSDAT");

            if (btnUncompress.Text == xml.Element("S07").Value)
            {
                #region Unpack SWAR file
                string swar = SaveFile();

                sSWAV[]  archivos = SWAR.ConvertToSWAV(SWAR.Read(swar));
                string[] swav     = new string[archivos.Length];

                Folder carpeta = new Folder();
                carpeta.name  = SearchFile().name;
                carpeta.files = new List <Sound>();

                for (int i = 0; i < archivos.Length; i++)
                {
                    swav[i] = pluginHost.Get_TempFolder() + '\\' + Path.GetRandomFileName();
                    SWAV.Write(archivos[i], swav[i]);

                    Sound newSound = new Sound();
                    newSound.id = lastFileID;
                    lastFileID++;
                    newSound.internalID = newSound.id;
                    newSound.name       = "SWAV_" + i.ToString() + ".swav";
                    newSound.offset     = 0x00;
                    newSound.type       = FormatSound.SWAV;
                    newSound.path       = swav[i];
                    newSound.size       = (uint)new FileInfo(swav[i]).Length;

                    carpeta.files.Add(newSound);
                }

                // Lo añadimos al nodo
                Add_Files(ref carpeta, (int)SearchFile().id);

                TreeNode selected = treeFiles.SelectedNode;
                selected = CarpetaToNodo(carpeta);

                // Agregamos los nodos al árbol
                TreeNode[] nodos = new TreeNode[selected.Nodes.Count];
                selected.Nodes.CopyTo(nodos, 0);
                treeFiles.SelectedNode.Tag = selected.Tag;
                selected.Nodes.Clear();

                treeFiles.SelectedNode.Nodes.AddRange((TreeNode[])nodos);
                treeFiles.SelectedNode.Expand();
                #endregion
                btnUncompress.Text = xml.Element("S12").Value;
            }
            else
            {
                #region Pack SWAR file
                Folder       swar   = SearchFolder(Convert.ToInt32(treeFiles.SelectedNode.Tag), sdat.files.root);
                List <sSWAV> sounds = new List <sSWAV>();

                for (int i = 0; i < swar.files.Count; i++)
                {
                    String tempFile = SaveFile((int)swar.files[i].id);
                    sSWAV  swav     = SWAV.Read(tempFile);
                    sounds.Add(swav);
                    File.Delete(tempFile);
                }

                String fileout = Path.GetTempFileName();
                SWAR.Write(sounds.ToArray(), fileout);
                ChangeFile(Convert.ToInt32(treeFiles.SelectedNode.Tag), fileout);
                #endregion
            }
        }
Esempio n. 2
0
        private void btnInfo_Click(object sender, EventArgs e)
        {
            Dictionary <String, String> info = new Dictionary <string, string>();

            switch (SearchFile().type)
            {
            case FormatSound.STRM:
                info = STRM.Information(STRM.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAV:
                info = SWAV.Information(SWAV.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SWAR:
                info = SWAR.Information(SWAR.Read(SaveFile()), pluginHost.Get_Language());
                break;

            case FormatSound.SSEQ:
                break;

            case FormatSound.SSAR:
                break;

            case FormatSound.SBNK:
                break;

            default:
                break;
            }


            Form ven = new Form();

            ven.Size            = new System.Drawing.Size(260, 440);
            ven.FormBorderStyle = FormBorderStyle.FixedDialog;
            ven.ShowIcon        = false;
            ven.MaximizeBox     = false;
            ven.MinimizeBox     = false;
            ven.Icon            = Icon.FromHandle(Properties.Resources.information.GetHicon());

            ListView     list    = new ListView();
            ColumnHeader column1 = new ColumnHeader();

            column1.Text = columnCampo.Text;
            ColumnHeader column2 = new ColumnHeader();

            column2.Text = columnValor.Text;
            list.Columns.Add(column1);
            list.Columns.Add(column2);

            foreach (String value in info.Keys)
            {
                if (value.StartsWith("/b"))
                {
                    String text = value.Replace("/b", "");
                    list.Items.Add(text, text, 0);
                    list.Items[text].Font = new Font("Microsoft Sans Serif", 9, FontStyle.Bold);
                    list.Items[text].SubItems.Add(info[value]);
                }
                else
                {
                    list.Items.Add(value, value, 0);
                    list.Items[value].SubItems.Add(info[value]);
                }
            }
            list.Size = new System.Drawing.Size(250, 430);
            list.View = View.Details;
            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.Dock = DockStyle.Fill;
            ven.Controls.Add(list);
            ven.Text = btnInfo.Text;
            ven.Show();
        }