private void AddressList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = this.AddressList.SelectedIndex;

            if (index < 0 || index >= this.ChangeDataList.Count)
            {
                return;
            }
            ChangeDataSt code = this.ChangeDataList[index];

            Address.Text = U.ToHexString(code.addr);
        }
        //Ctrl押しながら100件一気にマージ
        private bool AddressList_KeyDownWithCtrl(object sender, KeyEventArgs e)
        {
            if (!e.Control)
            {
                return(false);
            }

            int index = this.AddressList.SelectedIndex;

            if (index < 0 || index >= this.ChangeDataList.Count)
            {
                return(false);
            }

            int  limit     = Math.Min(index + 100, this.ChangeDataList.Count);
            uint startaddr = this.ChangeDataList[index].addr;

            Undo.UndoData undodata = Program.Undo.NewUndoData("marge " + U.To0xHexString(startaddr) + " With Control");

            for (; index < limit; index++)
            {
                ChangeDataSt code = this.ChangeDataList[index];

                byte[] bin;
                if (e.KeyCode == Keys.D1 || e.KeyCode == Keys.NumPad1)
                {
                    bin = U.subrange(this.AData, code.addr, code.addr + code.length);
                    code.SetMargeMethod(MargeMethod.A);
                }
                else if (e.KeyCode == Keys.D2 || e.KeyCode == Keys.NumPad2)
                {
                    bin = U.subrange(this.BData, code.addr, code.addr + code.length);
                    code.SetMargeMethod(MargeMethod.B);
                }
                else if (e.KeyCode == Keys.D3 || e.KeyCode == Keys.NumPad3)
                {
                    bin = U.subrange(this.CData, code.addr, code.addr + code.length);
                    code.SetMargeMethod(MargeMethod.C);
                }
                else if (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0)
                {
                    bin = U.subrange(this.CData, code.addr, code.addr + code.length);
                    code.SetMargeMethod(MargeMethod.NONE);
                }
                else
                {
                    return(false);
                }

                if (Program.ROM.Data.Length < code.addr + bin.Length)
                {
                    Program.ROM.write_resize_data(code.addr + (uint)bin.Length);
                }
                Program.ROM.write_range(code.addr, bin, undodata);
            }


            InputFormRef.ShowWriteNotifyAnimation(this, startaddr);
            Program.Undo.Push(undodata);

            if (!e.Shift)
            {//面倒なので操作を逆にする. Shiftが押されていなければ、次へ移動する.
                if (index < this.AddressList.Items.Count)
                {
                    this.AddressList.SelectedIndex = index;
                }
                else
                {
                    this.AddressList.SelectedIndex = this.AddressList.Items.Count - 1;
                }
            }
            this.AddressList.Invalidate();
            UpdateTitle();
            return(true);
        }
        private Size Draw(ListBox lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw)
        {
            if (index < 0 || index >= this.ChangeDataList.Count)
            {
                return(new Size(listbounds.X, listbounds.Y));
            }
            ChangeDataSt code = this.ChangeDataList[index];

            SolidBrush brush         = new SolidBrush(lb.ForeColor);
            SolidBrush selectedBrush = new SolidBrush(OptionForm.Color_Keyword_ForeColor());
            Font       normalFont    = lb.Font;

            string    text;
            Rectangle bounds = listbounds;

            int lineHeight = (int)lb.Font.Height;
            int maxHeight  = (int)lb.Font.Height;

            if (code.mark)
            {//マークの背景になる部分を描画
                Brush markColorBrush = new SolidBrush(OptionForm.Color_Error_ForeColor());

                Rectangle rc = new Rectangle(listbounds.X, listbounds.Y, listbounds.Width, lineHeight);
                g.FillRectangle(markColorBrush, rc);

                markColorBrush.Dispose();
            }


            uint   addr   = code.addr;
            uint   length = Math.Min(code.length, 32);
            string whatis = WhatIs(addr);

            if (whatis == "")
            {
                whatis = WhatIs(addr + length);
            }

            bounds.X = HeaderLength;
            string writeof = "";

            if (code.method == MargeMethod.A)
            {
                writeof = R._("<<対処法:{0}>>", this.ALabel);
            }
            else if (code.method == MargeMethod.B)
            {
                writeof = R._("<<対処法:{0}>>", this.BLabel);
            }
            else if (code.method == MargeMethod.C)
            {
                writeof = R._("<<対処法:{0}>>", this.CLabel);
            }

            text = R._("{0} 長さ:{1} {2} {3}", U.To0xHexString(addr), code.length, writeof, whatis);
            int labelEnd = U.DrawText(text, g, normalFont, brush, isWithDraw, bounds);

            bounds.Y += lineHeight;

            text = U.HexDumpLiner(this.AData, addr, length);
            if (code.method == MargeMethod.A)
            {
                bounds.X = HeaderLength;
                U.DrawText(this.ALabel, g, normalFont, selectedBrush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, selectedBrush, isWithDraw, bounds);
            }
            else
            {
                bounds.X = HeaderLength;
                U.DrawText(this.ALabel, g, normalFont, brush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, brush, isWithDraw, bounds);
            }
            bounds.Y += lineHeight;

            text = U.HexDumpLiner(this.BData, addr, length);
            if (code.method == MargeMethod.B)
            {
                bounds.X = HeaderLength;
                U.DrawText(this.BLabel, g, normalFont, selectedBrush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, selectedBrush, isWithDraw, bounds);
            }
            else
            {
                bounds.X = HeaderLength;
                U.DrawText(this.BLabel, g, normalFont, brush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, brush, isWithDraw, bounds);
            }
            bounds.Y += lineHeight;

            text = U.HexDumpLiner(this.CData, addr, length);
            if (code.method == MargeMethod.C)
            {
                bounds.X = HeaderLength;
                U.DrawText(this.CLabel, g, normalFont, selectedBrush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, selectedBrush, isWithDraw, bounds);
            }
            else
            {
                bounds.X = HeaderLength;
                U.DrawText(this.CLabel, g, normalFont, brush, isWithDraw, bounds);
                bounds.X = LabelLength;
                U.DrawText(text, g, normalFont, brush, isWithDraw, bounds);
            }
            bounds.Y += lineHeight;
            bounds.Y += lineHeight;

            if (code.method != MargeMethod.NONE)
            {
                Rectangle rc = new Rectangle(listbounds.X, listbounds.Y, HeaderLength, bounds.Y - listbounds.Y);
                g.FillRectangle(selectedBrush, rc);
            }
            if (code.mark)
            {//マークの縦線になる部分を描画
                Brush markColorBrush = new SolidBrush(OptionForm.Color_Error_ForeColor());

                Rectangle rc = new Rectangle(listbounds.Width - HeaderLength, listbounds.Y, listbounds.Width, bounds.Y - listbounds.Y);
                g.FillRectangle(markColorBrush, rc);

                markColorBrush.Dispose();
            }

            brush.Dispose();
            selectedBrush.Dispose();
            return(new Size(bounds.X, bounds.Y));
        }
        private void AddressList_KeyDown(object sender, KeyEventArgs e)
        {
            if (AddressList_KeyDownWithCtrl(sender, e))
            {
                return;
            }

            int index = this.AddressList.SelectedIndex;

            if (index < 0 || index >= this.ChangeDataList.Count)
            {
                return;
            }
            ChangeDataSt code = this.ChangeDataList[index];

            byte[] bin;
            if (e.KeyCode == Keys.D1 || e.KeyCode == Keys.NumPad1)
            {
                bin = U.subrange(this.AData, code.addr, code.addr + code.length);
                code.SetMargeMethod(MargeMethod.A);
            }
            else if (e.KeyCode == Keys.D2 || e.KeyCode == Keys.NumPad2)
            {
                bin = U.subrange(this.BData, code.addr, code.addr + code.length);
                code.SetMargeMethod(MargeMethod.B);
            }
            else if (e.KeyCode == Keys.D3 || e.KeyCode == Keys.NumPad3)
            {
                bin = U.subrange(this.CData, code.addr, code.addr + code.length);
                code.SetMargeMethod(MargeMethod.C);
            }
            else if (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0)
            {
                bin = U.subrange(this.CData, code.addr, code.addr + code.length);
                code.SetMargeMethod(MargeMethod.NONE);
            }
            else if (e.KeyCode == Keys.M)
            {
                code.ToggleMark();
                this.AddressList.InvalidateLine();
                return;
            }
            else if (e.KeyCode == Keys.L)
            {
                MarkListButton_Click(sender, e);
                return;
            }
            else
            {
                return;
            }


            Program.Undo.Push("marge " + U.To0xHexString(code.addr), code.addr, (uint)bin.Length);
            if (Program.ROM.Data.Length < code.addr + bin.Length)
            {
                Program.ROM.write_resize_data(code.addr + (uint)bin.Length);
            }
            Program.ROM.write_range(code.addr, bin);
            InputFormRef.ShowWriteNotifyAnimation(this, code.addr);

            if (!e.Shift)
            {//面倒なので操作を逆にする. Shiftが押されていなければ、次へ移動する.
                if (this.AddressList.SelectedIndex + 1 < this.AddressList.Items.Count)
                {
                    this.AddressList.SelectedIndex++;
                }
                else
                {
                    this.AddressList.SelectedIndex = this.AddressList.Items.Count - 1;
                    this.AddressList.InvalidateLine();
                }
            }
            else
            {
                this.AddressList.InvalidateLine();
            }
            UpdateTitle();
        }