示例#1
0
        public static void EditLabel(UInt32 address, AddressType type)
        {
            CodeLabel existingLabel = LabelManager.GetLabel(address, type);
            CodeLabel newLabel      = new CodeLabel()
            {
                Address     = existingLabel?.Address ?? address,
                AddressType = existingLabel?.AddressType ?? type,
                Label       = existingLabel?.Label,
                Comment     = existingLabel?.Comment,
                Length      = existingLabel?.Length ?? 1
            };

            frmEditLabel frm = new frmEditLabel(newLabel, existingLabel);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                bool empty = string.IsNullOrWhiteSpace(newLabel.Label) && string.IsNullOrWhiteSpace(newLabel.Comment);
                if (existingLabel != null)
                {
                    LabelManager.DeleteLabel(existingLabel, empty);
                }
                if (!empty)
                {
                    LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length);
                }
            }
        }
示例#2
0
        public static void EditComment(UInt32 address, AddressType type)
        {
            string    autoName      = "C" + address.ToString("X4");
            CodeLabel existingLabel = LabelManager.GetLabel(address, type);
            CodeLabel newLabel      = new CodeLabel()
            {
                Address     = existingLabel?.Address ?? address,
                AddressType = existingLabel?.AddressType ?? type,
                Label       = existingLabel?.Label,
                Comment     = existingLabel?.Comment,
                Length      = existingLabel?.Length ?? 1
            };

            if (existingLabel == null)
            {
                newLabel.Label = autoName;
            }
            bool isMultiLine = false;

            if (existingLabel != null && existingLabel.Comment.Contains("\r\n"))
            {
                isMultiLine = true;
            }

            if (isMultiLine)
            {
                frmEditLabel frm = new frmEditLabel(newLabel, existingLabel, true);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    bool empty = string.IsNullOrWhiteSpace(newLabel.Comment) && newLabel.Label == autoName;
                    if (existingLabel != null)
                    {
                        LabelManager.DeleteLabel(existingLabel, empty);
                    }
                    if (!empty)
                    {
                        LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length);
                    }
                }
            }
            else
            {
                frmEditComment frm = new frmEditComment(newLabel, existingLabel);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    bool empty = string.IsNullOrWhiteSpace(newLabel.Comment) && newLabel.Label == autoName;
                    if (existingLabel != null)
                    {
                        LabelManager.DeleteLabel(existingLabel, empty);
                    }
                    if (!empty)
                    {
                        LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length);
                    }
                }
            }
        }
示例#3
0
        private void mnuAdd_Click(object sender, EventArgs e)
        {
            CodeLabel newLabel = new CodeLabel()
            {
                Address = 0, AddressType = AddressType.InternalRam, Label = "", Comment = ""
            };

            frmEditLabel frm = new frmEditLabel(newLabel);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length);
            }
        }