Beispiel #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);
                }
            }
        }
Beispiel #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);
                    }
                }
            }
        }
Beispiel #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);
            }
        }
        private void EditLabel(LocationInfo location)
        {
            if (location.Symbol != null)
            {
                //Don't allow edit label on symbols
                return;
            }

            if (location.Label != null)
            {
                using (frmEditLabel frm = new frmEditLabel(location.Label)) {
                    frm.ShowDialog();
                }
            }
            else if (location.Address >= 0)
            {
                AddressInfo relAddress = new AddressInfo()
                {
                    Address = location.Address,
                    Type    = _manager.RelativeMemoryType
                };

                AddressInfo absAddress = DebugApi.GetAbsoluteAddress(relAddress);
                if (absAddress.Address >= 0)
                {
                    CodeLabel label = LabelManager.GetLabel((uint)absAddress.Address, absAddress.Type);
                    if (label == null)
                    {
                        label = new CodeLabel()
                        {
                            Address    = (uint)absAddress.Address,
                            MemoryType = absAddress.Type
                        };
                    }

                    using (frmEditLabel frm = new frmEditLabel(label)) {
                        frm.ShowDialog();
                    }
                }
            }
        }
Beispiel #5
0
 public static void EditLabel(CodeLabel label)
 {
     using (frmEditLabel frm = new frmEditLabel(label)) {
         frm.ShowDialog();
     }
 }