private void btnSave_Click(object sender, EventArgs e) { try { InfoArr info = new InfoArr(); foreach (ListViewItem item in lsvBlockSet.Items)//从lsvBlockSet内读取砖块信息,并存入info内 { info.Add(item.SubItems[0].Text, item.SubItems[1].Text); } config.Info = info;//把info赋给config对象的ifno属性 config.DownKey = (Keys)txtDown.Tag; config.DropKey = (Keys)txtDrop.Tag; config.MoveLeftKey = (Keys)txtLeft.Tag; config.MoveRightKey = (Keys)txtRight.Tag; config.DeasilRotateKey = (Keys)txtDeasil.Tag; config.ContraRotateKey = (Keys)txtContra.Tag; config.CoorWidth = int.Parse(txtCoorWidth.Text); config.CoorHeight = int.Parse(txtCoorHeight.Text); config.RectPix = int.Parse(txtRectPix.Text); config.BackColor = lblBackColor.BackColor; config.SaveToXmlFile();//保存成xml文件 MessageBox.Show("保存成功"); } catch { MessageBox.Show("保存失败"); } }
private void FrmConfig_Load(object sender, EventArgs e) { config.LoadFromXmlFile(); InfoArr info = config.Info; //读取砖块样式 ListViewItem myItem = new ListViewItem(); for (int i = 0; i < info.Length; i++) { myItem = lsvBlockSet.Items.Add(info[i].GetIdStr()); myItem.SubItems.Add(info[i].GetColorStr()); } //读快捷键 txtDown.Text = config.DownKey.ToString(); txtDown.Tag = config.DownKey; txtDrop.Text = config.DropKey.ToString(); txtDrop.Tag = config.DropKey; txtLeft.Text = config.MoveLeftKey.ToString(); txtLeft.Tag = config.MoveLeftKey; txtRight.Text = config.MoveRightKey.ToString(); txtRight.Tag = config.MoveRightKey; txtDeasil.Text = config.DeasilRotateKey.ToString(); txtDeasil.Tag = config.DeasilRotateKey; txtContra.Text = config.ContraRotateKey.ToString(); txtContra.Tag = config.ContraRotateKey; //读取环境参数设置 txtCoorWidth.Text = config.CoorWidth.ToString(); txtCoorHeight.Text = config.CoorHeight.ToString(); txtRectPix.Text = config.RectPix.ToString(); lblBackColor.BackColor = config.BackColor; }
public BlockGroup() { Config config = new Config(); config.LoadFromXmlFile(); info = new InfoArr(); info = config.Info; disapperColor = config.BackColor; rectPix = config.RectPix; }