private void btnSave_Click(object sender, EventArgs e) { GundamInfo gundam = lsGundam.SelectedItem as GundamInfo; if (gundam != null) { btnSave.Enabled = false; gundam.HP = short.Parse(txtHP.Text); gundam.EN = short.Parse(txtEN.Text); gundam.ACT = short.Parse(txtAct.Text); gundam.DEF = short.Parse(txtDef.Text); gundam.SPD = short.Parse(txtSpd.Text); gundam.Move = byte.Parse(txtMove.Text); gundam.Size = short.Parse(txtSize.Text); gundam.TeamSize = byte.Parse(txtTeamSize.Text); gundam.Skill1 = short.Parse(cboSkill1.SelectedValue.ToString()); gundam.Skill2 = short.Parse(cboSkill2.SelectedValue.ToString()); gundam.Skill3 = short.Parse(cboSkill3.SelectedValue.ToString()); gundam.Skill4 = short.Parse(cboSkill4.SelectedValue.ToString()); gundam.Skill5 = short.Parse(cboSkill5.SelectedValue.ToString()); string shiyin = cboE1.SelectedValue.ToString() + cboE2.SelectedValue.ToString() + cboE3.SelectedValue.ToString() + cboE4.SelectedValue.ToString() + cboE5.SelectedValue.ToString(); gundam.Earch = shiyin; gundamFile.Save(); } }
private void export(GundamInfo gundam, string file) { using (FileStream fis = new FileStream(file, FileMode.Create, FileAccess.Write)) { fis.Write(gundam.Data, 0, gundam.Data.Length); } }
private void search(int index) { txtAddress.Text = null; short hp = short.Parse(txtHP.Text); short en = short.Parse(txtEN.Text); short act = short.Parse(txtAct.Text); short def = short.Parse(txtDef.Text); short spd = short.Parse(txtSpd.Text); byte mov = byte.Parse(txtMove.Text); GundamInfo info = new GundamInfo(gundamFile, 0); for (idx = index; idx < gundamFile.Data.Length - 80; idx++) { info.Index = idx; if (info.HP == hp && info.EN == en && info.ACT == act && info.DEF == def && info.SPD == spd && info.Move == mov) { txtAddress.Text = info.Address; btnSave.Enabled = true; txtName.Enabled = true; txtName.Text = ""; break; } } }
private void LoadData(GundamInfo gundam) { if (gundam != null) { txtName.Text = gundam.GundamName; txtAddress.Text = ByteHelper.ByteArrayToHexString(ByteHelper.Int2Bytes(gundam.Index)); txtHP.Text = gundam.HP.ToString(); txtEN.Text = gundam.EN.ToString(); txtAct.Text = gundam.ACT.ToString(); txtDef.Text = gundam.DEF.ToString(); txtSpd.Text = gundam.SPD.ToString(); txtMove.Text = gundam.Move.ToString(); txtSize.Text = gundam.Size.ToString(); txtTeamSize.Text = gundam.TeamSize.ToString(); string shiyin = gundam.Earch; cboE1.SelectedValue = shiyin[0].ToString(); cboE2.SelectedValue = shiyin[1].ToString(); cboE3.SelectedValue = shiyin[2].ToString(); cboE4.SelectedValue = shiyin[3].ToString(); cboE5.SelectedValue = shiyin[4].ToString(); cboSkill1.SelectedValue = gundam.Skill1.ToString(); cboSkill2.SelectedValue = gundam.Skill2.ToString(); cboSkill3.SelectedValue = gundam.Skill3.ToString(); cboSkill4.SelectedValue = gundam.Skill4.ToString(); cboSkill5.SelectedValue = gundam.Skill5.ToString(); btnSave.Enabled = true; } else { txtName.Text = null; txtAddress.Text = null; txtHP.Text = null; txtEN.Text = null; txtAct.Text = null; txtDef.Text = null; txtSpd.Text = null; txtMove.Text = null; txtSize.Text = null; txtTeamSize.Text = null; cboE1.SelectedValue = "-1"; cboE2.SelectedValue = "-1"; cboE3.SelectedValue = "-1"; cboE4.SelectedValue = "-1"; cboE5.SelectedValue = "-1"; cboSkill1.SelectedValue = "-1"; cboSkill2.SelectedValue = "-1"; cboSkill3.SelectedValue = "-1"; cboSkill4.SelectedValue = "-1"; cboSkill5.SelectedValue = "-1"; btnSave.Enabled = false; } }
public FrmEditWeapon(GundamFile gundanFile, GundamInfo gundamInfo) { InitializeComponent(); tslblFile.Text = gundanFile.FileName; this.gundamFile = gundanFile; this.gundamInfo = gundamInfo; }
private void btnEditWeapon_Click(object sender, EventArgs e) { GundamInfo info = lsGundam.SelectedItem as GundamInfo; if (info != null) { FrmEditWeapon form = new FrmEditWeapon(gundamFile, info); form.ShowDialog(); } }
private void lsGundam_DrawItem(object sender, DrawItemEventArgs e) { e.Graphics.FillRectangle(new SolidBrush(e.BackColor), e.Bounds); if (e.Index >= 0) { GundamInfo master = ((ListBox)sender).Items[e.Index] as GundamInfo; StringFormat sStringFormat = new StringFormat(); sStringFormat.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(master.GroupName + "-" + master.UnitName, e.Font, new SolidBrush(e.ForeColor), e.Bounds, sStringFormat); } e.DrawFocusRectangle(); }
private void lsGundam_SelectedIndexChanged(object sender, EventArgs e) { GundamInfo master = lsGundam.SelectedItem as GundamInfo; if (master != null) { LoadData(master); } else { LoadData(null); } }
private void btnExport_Click(object sender, EventArgs e) { SelectedObjectCollection list = lsGundam.SelectedItems; if (list.Count == 1) { GundamInfo gundam = lsGundam.SelectedItem as GundamInfo; if (gundam != null) { string fileName = gundam.PicName + "-" + gundam.UnitName.Replace(" ", "_") + ".machine"; SaveFileDialog dialog = new SaveFileDialog(); //dialog.RestoreDirectory = true; dialog.Filter = "机体数据|*.machine"; dialog.FileName = fileName; if (dialog.ShowDialog() == DialogResult.OK) { using (FileStream fis = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write)) { fis.Write(gundam.Data, 0, gundam.Data.Length); } tsmiLblState.Text = "导出成功"; tsmiLblState.ForeColor = Color.Green; MessageBox.Show("导出成功", "操作提示"); } } } else if (list.Count > 0) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择导出目录(自动覆盖)"; if (dialog.ShowDialog() == DialogResult.OK) { foreach (Object obj in list) { GundamInfo gundam = obj as GundamInfo; string name = dialog.SelectedPath + "\\" + gundam.PicName + "-" + gundam.UnitName.Replace(" ", "_") + ".machine"; export(gundam, name); } tsmiLblState.Text = "导出成功"; tsmiLblState.ForeColor = Color.Green; MessageBox.Show("导出成功", "操作提示"); } } }
private void lsGundam_SelectedIndexChanged(object sender, EventArgs e) { GundamInfo master = lsGundam.SelectedItem as GundamInfo; if (master != null) { LoadData(master); } else { LoadData(null); } tsmiLblState.Text = "等待修改"; tsmiLblState.ForeColor = Color.Black; }
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; } }
private void btnSave_Click(object sender, EventArgs e) { GundamInfo gundam = lsGundam.SelectedItem as GundamInfo; if (gundam != null) { gundam.HP = int.Parse(txtHP.Text); gundam.EN = short.Parse(txtEN.Text); gundam.ACT = short.Parse(txtAct.Text); gundam.DEF = short.Parse(txtDef.Text); gundam.SPD = short.Parse(txtSpd.Text); gundam.Move = byte.Parse(txtMove.Text); gundam.Size = byte.Parse(cboSize.SelectedValue.ToString()); gundam.EarchSize = short.Parse(cboEarthSize.SelectedValue.ToString()); gundam.Price = int.Parse(txtPrice.Text); gundam.WeaponId = short.Parse(txtWeapon1ID.Text); gundam.WeaponCount = byte.Parse(txtWeaponCount.Text); gundam.WeaponMapID = short.Parse(txtFirstMap.Text); gundam.WeaponMapCount = byte.Parse(txtMapCount.Text); gundam.Skill1 = short.Parse(cboSkill1.SelectedValue.ToString()); gundam.Skill2 = short.Parse(cboSkill2.SelectedValue.ToString()); gundam.Skill3 = short.Parse(cboSkill3.SelectedValue.ToString()); gundam.Skill4 = short.Parse(cboSkill4.SelectedValue.ToString()); gundam.Skill5 = short.Parse(cboSkill5.SelectedValue.ToString()); if (gundam.UnitName != txtName.Text) { gundam.SetUnitName(txtName.Text); } string shiyin = cboE1.SelectedValue.ToString() + cboE2.SelectedValue.ToString() + cboE3.SelectedValue.ToString() + cboE4.SelectedValue.ToString() + cboE5.SelectedValue.ToString(); gundam.Earch = shiyin; gundam.Save(); gundam.Refresh(); LoadData(gundam); tsmiLblState.Text = "保存成功"; tsmiLblState.ForeColor = Color.Green; } }
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; } } }
private void LoadData(GundamInfo gundam) { if (gundam != null) { string name = gundam.PicName; txtPic.Text = name; if (head.ContainsKey(name)) { DDSImage image = new DDSImage(head[name]); pic1.Image = Image.FromHbitmap(image.images[0].GetHbitmap()); } else { if (pic1.Image != null) { pic1.Image.Dispose(); pic1.Image = null; } } txtUUID.Text = gundam.UUID; txtGroup.Text = gundam.GroupName; txtPrice.Text = gundam.Price.ToString(); txtName.Text = gundam.UnitName; txtAddress.Text = gundam.Address; txtHP.Text = gundam.HP.ToString(); txtEN.Text = gundam.EN.ToString(); txtAct.Text = gundam.ACT.ToString(); txtDef.Text = gundam.DEF.ToString(); txtSpd.Text = gundam.SPD.ToString(); txtMove.Text = gundam.Move.ToString(); txtWeapon1ID.Text = gundam.WeaponId.ToString(); txtWeaponCount.Text = gundam.WeaponCount.ToString(); txtFirstMap.Text = gundam.WeaponMapID.ToString(); txtMapCount.Text = gundam.WeaponMapCount.ToString(); cboEarthSize.SelectedValue = gundam.EarchSize.ToString(); if (cboEarthSize.SelectedValue == null) { GGCRUtil.AddEarthSize(gundam.EarchSize, "未知" + gundam.EarchSize.ToString()); bindAll(); LoadData(gundam); return; } cboSize.SelectedValue = gundam.Size.ToString(); if (cboSize.SelectedValue == null) { GGCRUtil.AddGundamSize(gundam.Size, "未知" + gundam.Size); bindAll(); LoadData(gundam); return; } string shiyin = gundam.Earch; cboE1.SelectedValue = shiyin[0].ToString(); if (cboE1.SelectedValue == null) { GGCRUtil.AddGundamSize(short.Parse(shiyin[0].ToString()), "未知" + shiyin[0].ToString()); bindAll(); LoadData(gundam); return; } cboE2.SelectedValue = shiyin[1].ToString(); if (cboE2.SelectedValue == null) { GGCRUtil.AddGundamEarth(short.Parse(shiyin[1].ToString()), "未知" + shiyin[1].ToString()); bindAll(); LoadData(gundam); return; } cboE3.SelectedValue = shiyin[2].ToString(); if (cboE3.SelectedValue == null) { GGCRUtil.AddGundamEarth(short.Parse(shiyin[2].ToString()), "未知" + shiyin[2].ToString()); bindAll(); LoadData(gundam); return; } cboE4.SelectedValue = shiyin[3].ToString(); if (cboE4.SelectedValue == null) { GGCRUtil.AddGundamEarth(short.Parse(shiyin[3].ToString()), "未知" + shiyin[3].ToString()); bindAll(); LoadData(gundam); return; } cboE5.SelectedValue = shiyin[4].ToString(); if (cboE5.SelectedValue == null) { GGCRUtil.AddGundamEarth(short.Parse(shiyin[4].ToString()), "未知" + shiyin[4].ToString()); bindAll(); LoadData(gundam); return; } cboSkill1.SelectedValue = gundam.Skill1.ToString(); if (cboSkill1.SelectedValue == null) { GGCRUtil.AddGundamAbility(gundam.Skill1, "未知" + gundam.Skill1); bindAll(); LoadData(gundam); return; } cboSkill2.SelectedValue = gundam.Skill2.ToString(); if (cboSkill2.SelectedValue == null) { GGCRUtil.AddGundamAbility(gundam.Skill2, "未知" + gundam.Skill2); bindAll(); LoadData(gundam); return; } cboSkill3.SelectedValue = gundam.Skill3.ToString(); if (cboSkill3.SelectedValue == null) { GGCRUtil.AddGundamAbility(gundam.Skill3, "未知" + gundam.Skill3); bindAll(); LoadData(gundam); return; } cboSkill4.SelectedValue = gundam.Skill4.ToString(); if (cboSkill4.SelectedValue == null) { GGCRUtil.AddGundamAbility(gundam.Skill4, "未知" + gundam.Skill4); bindAll(); LoadData(gundam); return; } cboSkill5.SelectedValue = gundam.Skill5.ToString(); if (cboSkill5.SelectedValue == null) { GGCRUtil.AddGundamAbility(gundam.Skill5, "未知" + gundam.Skill5); bindAll(); LoadData(gundam); return; } btnSave.Enabled = true; } else { txtUUID.Text = null; txtPrice.Text = null; txtGroup.Text = null; txtName.Text = null; txtAddress.Text = null; txtHP.Text = null; txtEN.Text = null; txtAct.Text = null; txtDef.Text = null; txtSpd.Text = null; txtMove.Text = null; cboSize.SelectedValue = "-1"; cboEarthSize.SelectedValue = "-1"; cboE1.SelectedValue = "-1"; cboE2.SelectedValue = "-1"; cboE3.SelectedValue = "-1"; cboE4.SelectedValue = "-1"; cboE5.SelectedValue = "-1"; cboSkill1.SelectedValue = "-1"; cboSkill2.SelectedValue = "-1"; cboSkill3.SelectedValue = "-1"; cboSkill4.SelectedValue = "-1"; cboSkill5.SelectedValue = "-1"; txtWeapon1ID.Text = null; txtWeaponCount.Text = null; btnSave.Enabled = false; } }
private void FrmEditGundam_Load(object sender, EventArgs e) { e1 = buildEarth(); e2 = buildEarth(); e3 = buildEarth(); e4 = buildEarth(); e5 = buildEarth(); cboE1.DataSource = e1; cboE1.DisplayMember = "Value"; cboE1.ValueMember = "Key"; cboE2.DataSource = e2; cboE2.DisplayMember = "Value"; cboE2.ValueMember = "Key"; cboE3.DataSource = e3; cboE3.DisplayMember = "Value"; cboE3.ValueMember = "Key"; cboE4.DataSource = e4; cboE4.DisplayMember = "Value"; cboE4.ValueMember = "Key"; cboE5.DataSource = e5; cboE5.DisplayMember = "Value"; cboE5.ValueMember = "Key"; using (StreamReader sr = new StreamReader("机体能力.txt")) { string line = null; while ((line = sr.ReadLine()) != null) { if (line != "") { string[] arr = line.Split(':'); KeyValuePair <string, string> info = new KeyValuePair <string, string>(arr[0], arr[1]); skill1.Add(info); skill2.Add(info); skill3.Add(info); skill4.Add(info); skill5.Add(info); } } } cboSkill1.DataSource = skill1; cboSkill2.DataSource = skill2; cboSkill3.DataSource = skill3; cboSkill4.DataSource = skill4; cboSkill5.DataSource = skill5; cboSkill1.DisplayMember = "Value"; cboSkill2.DisplayMember = "Value"; cboSkill3.DisplayMember = "Value"; cboSkill4.DisplayMember = "Value"; cboSkill5.DisplayMember = "Value"; cboSkill1.ValueMember = "Key"; cboSkill2.ValueMember = "Key"; cboSkill3.ValueMember = "Key"; cboSkill4.ValueMember = "Key"; cboSkill5.ValueMember = "Key"; using (StreamReader sr = new StreamReader("机体数据.txt")) { string line = null; while ((line = sr.ReadLine()) != null) { if (line != "") { string[] arr = line.Split(':'); GundamInfo info = gundamFile.getGundam(arr[1]); info.GundamName = arr[0]; gundams.Add(info); } } } gundams.Sort(); lsGundam.DataSource = gundams; lsGundam.DisplayMember = "GundamName"; lsGundam.ValueMember = "Address"; }
private void loadData() { this.gundamFile = new GundamFile(); stFile.Text = this.gundamFile.FileName; List <MachineConvertInfo> allConverts = gundamFile.ListConvert(); this.actions = GGCRUtil.ListConvertAction(); foreach (MachineConvertInfo c in allConverts) { bool find = false; foreach (KeyValuePair <string, string> kv in actions) { if (kv.Key == c.Action.ToString()) { find = true; break; } } if (!find) { GGCRUtil.AddConvertAction(c.Action, "未知" + c.Action); this.actions = GGCRUtil.ListConvertAction(); } } cboAction.DataSource = actions; cboAction.DisplayMember = "Value"; cboAction.ValueMember = "Key"; this.gundams = gundamFile.ListMachines(); foreach (GundamInfo g in gundams) { if (g.UUID == this.fromUuid) { this.gundam = g; break; } } fromSource.DataSource = this.gundams; toSource.DataSource = this.gundams; cboTo.DataSource = toSource.DataSource; cboTo.ValueMember = "UUID"; cboTo.DisplayMember = "UnitName"; cboFrom.DataSource = fromSource; cboFrom.ValueMember = "UUID"; cboFrom.DisplayMember = "UnitName"; if (this.gundam != null) { this.converts = new List <MachineConvertInfo>(); foreach (MachineConvertInfo c in allConverts) { if (c.From == gundam.UUID || c.To == gundam.UUID) { this.converts.Add(c); } } } else { this.converts = allConverts; } lsMain.DataSource = this.converts; }