コード例 #1
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var            lbi  = (ListBoxItem)value;
            AsmListBoxItem item = (AsmListBoxItem)lbi.Content;

            AddressItem addressItem = item as AddressItem;
            string      operand     = addressItem.Operand ?? "";

            Console.WriteLine(operand);

            int padding;

            operand = int.TryParse(parameter.ToString(), out padding) ? operand.PadRight(padding) : operand;

            AsmLine asmLine = item.AsmLine;

            if (asmLine.HasOperandArgument())
            {
                if (asmLine.OperandArgument.HasLabel())
                {
                    if (!(asmLine.IsJumpOperation() || asmLine.IsBranchOperation() || asmLine.Opcode == "rts"))
                    {
                        string label = asmLine.OperandArgument.Label;
                        operand = operand.Replace(label, "<Run Foreground=\"DarkOrange\">" + label + "</Run>");
                    }
                }
            }


            return(operand.Replace("&", "&amp;"));
        }
コード例 #2
0
        private void listBox_KeyDown(object sender, KeyEventArgs e)
        {
            bool IsShiftKey   = Keyboard.Modifiers.HasFlag(ModifierKeys.Shift);
            bool IsAltKey     = Keyboard.Modifiers.HasFlag(ModifierKeys.Alt);
            bool IsControlKey = Keyboard.Modifiers.HasFlag(ModifierKeys.Control);

            if (IsShiftKey && IsAltKey && IsControlKey)
            {
                AsmListBoxItem item = (AsmListBoxItem)listBox.SelectedItem;
                if (item is AddressItem)
                {
                    AddressItem addressItem = (AddressItem)item;
                    MessageBox.Show(addressItem.Address);
                    int addr = AsmReader.AddressByLabelDictionary()["chooseControls"];
                    ScrollToAddress(addr);
                }
            }
        }
コード例 #3
0
 public void TestToggleEvaluation()
 {
     foreach (AsmListBoxItem item in _items)
     {
         AddressItem addressItem = item as AddressItem;
         if (addressItem != null)
         {
             if (addressItem.IsEvaluated)
             {
                 addressItem.IsEvaluated = false;
             }
             else
             {
                 addressItem.IsEvaluated = true;
                 addressItem.Evaluation  = "ertwert";
             }
         }
     }
     listBox.Refresh();
 }
コード例 #4
0
        public void PopulateListbox()
        {
            int itemIndex = 0;

            foreach (AsmLine asmLine in AsmReader._asmLines)
            {
                AsmListBoxItem newItem = null;

                switch (asmLine.LineType)
                {
                case AsmLineType.CommentLine:
                    newItem = new CommentItem()
                    {
                        CommentLine = asmLine.Comment,
                    };
                    break;

                case AsmLineType.OpcodeLine:
                case AsmLineType.DirectiveLine:
                    newItem = new AddressItem()
                    {
                        Address         = Padded(asmLine.Address, 5),
                        Bytes           = Padded(asmLine.Bytes, 15),
                        Label           = Padded(asmLine.Label, 20),
                        Comment         = Padded(asmLine.Comment, 60),
                        CommentColor    = "Gray",
                        EvaluationColor = "Blue",
                    };
                    break;

                default:
                    continue;
                }
                AddressItem addressItem = newItem as AddressItem;

                switch (asmLine.LineType)
                {
                case AsmLineType.OpcodeLine:
                    addressItem.Instruction      = Padded(asmLine.Opcode, 6);
                    addressItem.Operand          = Padded(asmLine.OperandArgument.Operand, 40, paddedOperand => ColorOpcodeOperand(asmLine, paddedOperand));
                    addressItem.InstructionColor = InstructionColor(asmLine);
                    break;

                case AsmLineType.DirectiveLine:
                    addressItem.Instruction      = Padded(asmLine.Directive, 6);
                    addressItem.Operand          = Padded(asmLine.DirectiveArgument.Operand, 40);
                    addressItem.InstructionColor = "DarkMagenta";
                    break;
                }

                Debug.Assert(newItem != null);

                newItem.AsmLine = asmLine;
                _items.Add(newItem);
                _itemsByAsmLine.Add(asmLine, newItem);

                newItem.ItemIndex = itemIndex;

                if (itemIndex % 20 == 0)
                {
                    newItem.LineStatus = "<Run Foreground=\"Red\">abcd</Run>";
                }

                itemIndex++;
            }
        }