Esempio n. 1
0
        private void btnImportBatch_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            //dialog.RestoreDirectory = true;
            dialog.Filter      = "人物数据|*.master";
            dialog.Multiselect = true;

            if (dialog.ShowDialog() == DialogResult.OK && dialog.FileNames.Length > 0)
            {
                txtSearch.Text = null;

                foreach (string fileName in dialog.FileNames)
                {
                    byte[] data = File.ReadAllBytes(fileName);

                    byte[] bt = new byte[GGCRStaticConfig.MasterUIDLength];
                    Array.Copy(data, 0, bt, 0, bt.Length);
                    string uid = ByteHelper.ByteArrayToHexString(bt).Trim();

                    MasterInfo select = null;
                    foreach (MasterInfo info in masters)
                    {
                        if (info.UUID == uid)
                        {
                            select = info;
                            break;
                        }
                    }
                    if (select != null)
                    {
                        select.Replace(data);
                        select.Save();
                    }
                }

                lsMasters.SelectedItem = null;

                bindAll();

                MessageBox.Show("导入成功,已自动保存", "操作提示");
                // lsGundam.SelectedIndex = 0;
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            //dialog.RestoreDirectory = true;
            dialog.Filter = "人物数据|*.master";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                txtSearch.Text = null;

                byte[] data = File.ReadAllBytes(dialog.FileName);

                byte[] bt = new byte[GGCRStaticConfig.MasterUIDLength];
                Array.Copy(data, 0, bt, 0, bt.Length);
                string uid = ByteHelper.ByteArrayToHexString(bt).Trim();

                MasterInfo select = null;
                foreach (MasterInfo info in masters)
                {
                    if (info.UUID == uid)
                    {
                        select = info;
                        break;
                    }
                }
                if (select == null)
                {
                    MessageBox.Show("该角色不存在,无法导入", "导入失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    select.Replace(data);
                    lsMasters.SelectedItem = null;
                    lsMasters.SelectedItem = select;

                    tsmiLblState.Text      = "请保存";
                    tsmiLblState.ForeColor = Color.Red;
                }
            }
        }