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

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

                    GundamInfo select = null;
                    foreach (GundamInfo info in gundams)
                    {
                        if (info.UUID == uid)
                        {
                            select = info;
                            break;
                        }
                    }
                    if (select != null)
                    {
                        short nameId = select.UnitNameTblIndex;
                        select.Replace(data);
                        select.UnitNameTblIndex = nameId;
                        select.Save();
                    }
                }

                lsGundam.SelectedItem = null;

                bindAll();

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

            //dialog.RestoreDirectory = true;
            dialog.Filter = "机体数据|*.machine";

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

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

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

                GundamInfo select = null;
                foreach (GundamInfo info in gundams)
                {
                    if (info.UUID == uid)
                    {
                        select = info;
                        break;
                    }
                }
                if (select == null)
                {
                    MessageBox.Show("该机体不存在,无法导入", "导入失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    short nameId = select.UnitNameTblIndex;
                    select.Replace(data);
                    select.UnitNameTblIndex = nameId;
                    lsGundam.SelectedItem   = null;
                    lsGundam.SelectedItem   = select;

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