private void addItem_btn_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedTab == tabPage2 && basketList_lv.Items.Count <= 120) {
         ListViewItem lvi = new ListViewItem();
         BasketItem bi = new BasketItem();
         lvi.Tag = bi;
         lvi.SubItems.Add(bi.Name);
         lvi.Text = basketList_lv.Items.Count + "";
         basketList_lv.Items.Add(lvi);
         lvi.Selected = true;
     } else if (tabControl1.SelectedTab == tabPage3 && boxList_lv.Items.Count <= 10000) {
         ListViewItem lvi = new ListViewItem();
         BoxItem bi = new BoxItem();
         lvi.Tag = bi;
         lvi.SubItems.Add(bi.Name);
         lvi.Text = boxList_lv.Items.Count + "";
         boxList_lv.Items.Add(lvi);
         lvi.Selected = true;
     }
 }
        private void button3_Click_1(object sender, EventArgs e)
        {
            if (saveDir != null) {

                foreach (KeyValuePair<ushort, string> pair in AtelierAyeshaDataType.ItemList) {
                    if (boxList_lv.Items.Count <= 10000 && pair.Key != 0xFFFF) {
                        ListViewItem lvi = new ListViewItem();
                        BoxItem bi = new BoxItem();
                        bi.Quality = 120;
                        bi.Count = 255;
                        bi.ID = pair.Key;
                        lvi.Tag = bi;
                        lvi.SubItems.Add(bi.Name);
                        lvi.Text = boxList_lv.Items.Count + "";
                        boxList_lv.Items.Add(lvi);
                        lvi.Selected = true;
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // ofd.Filter = "Ps3 Save (USR-DATA)|USR-DATA|All files (*.*)|*.*";
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
                if (saveDir != null) {
                    /////////////////////////
                    // Encrypt
                    /////////////////////////
                    gameID = ((string)SFO.getValue("SAVEDATA_DIRECTORY")).Split('-')[0];
                    Utility.encryptSave(gameID, saveDir);
                    saveDir = null;
                }

                saveDir = folderBrowserDialog1.SelectedPath;
                if (!File.Exists(saveDir + @"\USR-DATA") || !File.Exists(saveDir + @"\ICON0.PNG") || !File.Exists(saveDir + @"\PARAM.SFO")
                    || !File.Exists(saveDir + @"\PIC1.PNG") || !File.Exists(saveDir + @"\PARAM.PFD")) {
                    saveDir = null;
                    MessageBox.Show("錯誤的存檔");
                    return;
                }

                /////////////////////////
                // SFO Block
                /////////////////////////
                SFO = new ParamSFOParser(saveDir + @"\PARAM.SFO");
                // tabPage4.BackgroundImage = Image.FromFile( saveDir + @"\PIC1.PNG" );

                imageLabel.Image = Image.FromFile(saveDir + @"\ICON0.PNG");
                TITLE.Text = (string)SFO.getValue("TITLE");
                SUB_TITLE.Text = (string)SFO.getValue("SUB_TITLE");
                DETAIL.Text = (string)SFO.getValue("DETAIL");

                /////////////////////////
                // Decrypt
                /////////////////////////
                gameID = ((string)SFO.getValue("SAVEDATA_DIRECTORY")).Split('-')[0];

                Utility.decryptSave(gameID, saveDir);
                // Get the output into a string
                // string result = proc.StandardOutput.ReadToEnd();

                // //////////////////////
                // SaveBlock
                /////////////////////////
                boxList_lv.Items.Clear();
                basketList_lv.Items.Clear();
                BigEndianBinaryReader SaveDataFile = new BigEndianBinaryReader(new FileStream(saveDir + @"\USR-DATA", FileMode.Open));
                SaveDataFile.BaseStream.Position = AtelierAyeshaDataType.CollectionBasketOffset;
                BasketItem basketTmp;
                for (int i = 0; i < 120; i++) {
                    basketTmp = new BasketItem(SaveDataFile);
                    if (basketTmp.ID == 0xFFFF) {
                        break;
                    }
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = i + "";
                    lvi.SubItems.Add(basketTmp.Name);
                    lvi.Tag = basketTmp;
                    basketList_lv.Items.Add(lvi);
                }

                BoxItem boxTemp;
                SaveDataFile.BaseStream.Position = AtelierAyeshaDataType.BoxOffset;
                boxList_lv.BeginUpdate();
                for (int i = 0; i < 10000; i++) {
                    boxTemp = new BoxItem(SaveDataFile);
                    if (boxTemp.ID == 0xFFFF || boxTemp.Count == 0) {
                        break;
                    }
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = i + "";
                    lvi.SubItems.Add(boxTemp.Name);
                    lvi.Tag = boxTemp;
                    boxList_lv.Items.Add(lvi);
                }
                boxList_lv.EndUpdate();

                // 錢
                SaveDataFile.BaseStream.Position = AtelierAyeshaDataType.money;
                money_nud.Value = Convert.ToDecimal(SaveDataFile.ReadUInt32());
                // pt1
                SaveDataFile.BaseStream.Position = AtelierAyeshaDataType.pt;
                pt1_nud.Value = Convert.ToDecimal(SaveDataFile.ReadUInt32());
                readExtensionFile(SaveDataFile.BaseStream);

                SaveDataFile.Close();
            }
        }