private void btnSaveAll_Click(object sender, EventArgs e)
        {
            float curDur = 0;
            float maxDur = 0;

            try
            {
                curDur = float.Parse(txtCurrentDurability.Text);
                maxDur = float.Parse(txtMaxDurability.Text);
            }
            catch
            {
                MessageBox.Show("Invalid Durability Input");
                return;
            }
            if (curDur == 100 || maxDur == 100)
            {
                MessageBox.Show("为了方便列出所有装备 请勿将耐久度设置为100,不予修改");
                return;
            }
            if (curDur > maxDur || curDur > 99999 || curDur < 0 || maxDur <= 0)
            {
                MessageBox.Show("Invalid Durability Input");
                return;
            }
            if (!txtName.ReadOnly)
            {
                if (txtName.Text.Trim() == "")
                {
                    MessageBox.Show("No name entered, will use default Item-name");
                }
                foreach (char c in txtName.Text)
                {
                    if (c < 20 || c > 127)
                    {
                        MessageBox.Show("Name can only contain English charakters");
                        return;
                    }
                }
            }
            if (!txtName.ReadOnly)
            {
                weaponInfo.WeaponName = txtName.Text.Trim();
            }
            weaponInfo.CurrentDurability = curDur;
            weaponInfo.MaxDurability     = maxDur;

            editer.WriteWeaponByte(weaponInfo);
            MessageBox.Show("Modification Successful, please save!");
            isEdit            = true;
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <byte> btList = new List <byte>();

            foreach (string line in txtByte.Lines)
            {
                string[] str = line.Trim().Split(' ');
                foreach (string s in str)
                {
                    if (s.Trim().Length != 2)
                    {
                        MessageBox.Show("输入的代码格式不正确");
                        return;
                    }
                    byte b = byte.Parse(s.Trim(), System.Globalization.NumberStyles.HexNumber);
                    btList.Add(b);
                }
            }
            weapon.WeaponBytes = btList.ToArray();
            editer.WriteWeaponByte(weapon);
            this.DialogResult = DialogResult.Yes;
            btnSave.Enabled   = false;
        }