Beispiel #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("此操作无法撤销,确定要删除吗", "使用说明", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                MachineConvertInfo convert = lsMain.SelectedItem as MachineConvertInfo;
                int index = lsMain.SelectedIndex;
                if (convert != null)
                {
                    gundamFile.DeleteConvert(convert);

                    loadData();
                    if (lsMain.Items.Count > index)
                    {
                        lsMain.SelectedIndex = index;
                    }
                    else
                    {
                        lsMain.SelectedIndex = -1;

                        cboAction.SelectedValue = "-1";
                        cboFrom.SelectedValue   = "-1";
                        cboTo.SelectedValue     = "-1";
                    }

                    lbState.Text      = "删除成功";
                    lbState.ForeColor = Color.Green;
                }
            }
        }
Beispiel #2
0
        public void DeleteConvert(MachineConvertInfo convert)
        {
            GGCRPkdInnerFile file = this.GetInnerFile("MachineConversionList.cdb");
            int count             = BitConverter.ToInt32(this.Data, file.StartIndex + 8) - 1;

            //修改总数
            byte[] newCount = BitConverter.GetBytes(count);
            this.Write(file.StartIndex + 8, newCount);
            //删除数据

            this.DeleteInnerFile(file, convert.Index, 20);
        }
Beispiel #3
0
        public List <MachineConvertInfo> ListConvert()
        {
            int start = this.GetInnerFile("MachineConversionList.cdb").StartIndex;
            int count = BitConverter.ToInt32(this.Data, start + 8);

            int firstIndex = start + 12;

            List <MachineConvertInfo> list = new List <MachineConvertInfo>();

            for (int i = 0; i < count; i++)
            {
                MachineConvertInfo convert = new MachineConvertInfo(this, firstIndex + i * 20, i);

                list.Add(convert);
            }
            return(list);
        }
Beispiel #4
0
        private void lsMain_SelectedIndexChanged(object sender, EventArgs e)
        {
            MachineConvertInfo convert = lsMain.SelectedItem as MachineConvertInfo;

            if (convert != null)
            {
                cboAction.SelectedValue = convert.Action.ToString();
                cboFrom.SelectedValue   = convert.From;
                cboTo.SelectedValue     = convert.To;

                lbState.Text      = "等待修改";
                lbState.ForeColor = Color.Black;
            }
            else
            {
                cboAction.SelectedValue = "-1";
                cboFrom.SelectedValue   = "-1";
                cboTo.SelectedValue     = "-1";
            }
        }
Beispiel #5
0
        private void lsMain_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.Graphics.FillRectangle(new SolidBrush(e.BackColor), e.Bounds);
            if (e.Index >= 0)
            {
                MachineConvertInfo convert       = ((ListBox)sender).Items[e.Index] as MachineConvertInfo;
                StringFormat       sStringFormat = new StringFormat();
                sStringFormat.LineAlignment = StringAlignment.Center;
                string from = null;
                string to   = null;
                foreach (GundamInfo g in this.gundams)
                {
                    if (convert.From == g.UUID)
                    {
                        from = g.UnitName;
                    }
                    if (convert.To == g.UUID)
                    {
                        to = g.UnitName;
                    }
                    if (from != null && to != null)
                    {
                        break;
                    }
                }

                string action = null;
                foreach (KeyValuePair <string, string> a in actions)
                {
                    if (a.Key == convert.Action.ToString())
                    {
                        action = a.Value;
                        break;
                    }
                }

                e.Graphics.DrawString((from ?? "无") + "  ==" + action + "==>  " + (to ?? "无"), e.Font, new SolidBrush(e.ForeColor), e.Bounds, sStringFormat);
            }
            e.DrawFocusRectangle();
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            MachineConvertInfo convert = lsMain.SelectedItem as MachineConvertInfo;
            int index = lsMain.SelectedIndex;

            if (convert != null && cboFrom.SelectedItem != null && cboTo.SelectedItem as GundamInfo != null)
            {
                convert.From   = (cboFrom.SelectedItem as GundamInfo).UUID;
                convert.To     = (cboTo.SelectedItem as GundamInfo).UUID;
                convert.Action = int.Parse(cboAction.SelectedValue.ToString());

                convert.Save();

                loadData();
                lsMain.SelectedIndex = index;

                lbState.Text      = "保存成功";
                lbState.ForeColor = Color.Green;
            }
            else
            {
                MessageBox.Show("请填写完所有数据", "使用提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }