Esempio n. 1
0
        private void readSFOToListView(SFOParser sfo, ListView lv)
        {
            lv.Items.Clear();
            AttributeToolStripMenuItem.Enabled = false;
            resolutionToolStripMenuItem.Enabled = false;
            audioToolStripMenuItem.Enabled = false;
            m_attribute_lvi = null;
            m_sound_formate_lvi = null;
            m_resolutin_lvi = null;
            for (int i = 0; i < sfo.Length; i++) {
                ListViewItem lvi = new ListViewItem();
                lvi.Text = sfo.getKey(i);
                lvi.Tag = i;
                switch (sfo.getType(i)) {
                    case 0:
                        // lvi.SubItems.Add(BitConverter.ToString((byte[])sfo.getValue(i), 16));
                        lvi.SubItems.Add(Encoding.UTF8.GetString((byte[])sfo.getValue(i)));
                        break;
                    case 2:
                        lvi.SubItems.Add((string)sfo.getValue(i));
                        break;
                    case 4:
                        lvi.SubItems.Add(sfo.getValue(i) + "");
                        break;
                    default:
                        lvi.SubItems.Add("(unknow *NOT BE SAVED*) " + BitConverter.ToString((byte[])sfo.getValue(i), 16));
                        break;
                }

                if (sfo.getKey(i).Equals("ATTRIBUTE")) {
                    m_attribute_lvi = lvi;
                    AttributeToolStripMenuItem.Enabled = true;
                    int attribute = (int)sfo.getValue(i);
                    if ((attribute & PSP3) == PSP3) {
                        toolStripComboBox1.SelectedIndex = 3;
                    } else if ((attribute & PSP2) == PSP2) {
                        toolStripComboBox1.SelectedIndex = 2;
                    } else if ((attribute & PSP1) == PSP1) {
                        toolStripComboBox1.SelectedIndex = 1;
                    } else {
                        toolStripComboBox1.SelectedIndex = 0;
                    }
                }

                if (sfo.getKey(i).Equals("RESOLUTION")) {
                    m_resolutin_lvi = lvi;
                    resolutionToolStripMenuItem.Enabled = true;
                    int res = (int)sfo.getValue(i);
                    SetResolution(res);
                }
                if (sfo.getKey(i).Equals("SOUND_FORMAT")) {
                    m_sound_formate_lvi = lvi;
                    audioToolStripMenuItem.Enabled = true;
                    int snd = (int)sfo.getValue(i);
                    SetSountFormat(snd);
                }
                lv.Items.Add(lvi);
            }
        }
Esempio n. 2
0
 private void OpenFile(string filename)
 {
     try {
         m_sfo = new SFOParser(filename);
         readSFOToListView(m_sfo, listViewEx1);
         saveToolStripMenuItem.Enabled = true;
     } catch (Exception e) {
         MessageBox.Show(e.Message);
     }
 }