示例#1
0
        private void btnBatchImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            //dialog.RestoreDirectory = true;
            dialog.Filter      = "武器数据|*.weapon";
            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.WeaponUIDLength];
                    Array.Copy(data, 0, bt, 0, bt.Length);
                    string uid = ByteHelper.ByteArrayToHexString(bt).Trim();

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

                lsGundam.SelectedItem = null;

                bindAll();

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

            //dialog.RestoreDirectory = true;
            dialog.Filter = "武器数据|*.weapon";

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

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

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

                WeaponInfo select = null;
                foreach (WeaponInfo info in weapons)
                {
                    if (info.UUID == uid)
                    {
                        select = info;
                        break;
                    }
                }
                if (select == null)
                {
                    MessageBox.Show("该武器不存在,无法导入", "导入失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    select.Replace(data);
                    lsGundam.SelectedItem = null;
                    lsGundam.SelectedItem = select;

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