Exemple #1
0
 public InstructionBlock()
 {
     InitializeComponent();
     this.DataContext              = this;
     RemoveInstructionCommand      = new RemoveInstructionCommand(RemoveInstruction);
     removeButton.CommandParameter = this;
     dtComboBox.ItemsSource        = Enum.GetValues(typeof(Instruction.DriveType));
 }
Exemple #2
0
        private void InstructionCountUpDown_ValueChanged(object sender, EventArgs e)
        {
            Command Command;

            int OldInstructionCount = this.InstructionLayoutPanel.Controls.Count;
            int NewInstructionCount = (int)this.InstructionCountUpDown.Value;

            if (NewInstructionCount > OldInstructionCount)
            {
                for (int i = OldInstructionCount; i < NewInstructionCount; i++)
                {
                    PBInstructionBox Instruction = new PBInstructionBox();
                    Instruction.ValueChanged += new EventHandler(Instruction_ValueChanged);

                    Command = new AddInstructionCommand(this, Instruction);
                    Command.Execute();
                    History.Push(Command);

                    Future.Clear();
                    RedoEditMenuStripItem.Enabled = false;
                }
            }
            else if (NewInstructionCount < OldInstructionCount)
            {
                for (int i = OldInstructionCount; i > NewInstructionCount; i--)
                {
                    PBInstructionBox Instruction = (PBInstructionBox)InstructionLayoutPanel.Controls[InstructionLayoutPanel.Controls.Count - 1];

                    Command = new RemoveInstructionCommand(this, Instruction);
                    Command.Execute();
                    History.Push(Command);

                    Future.Clear();
                    RedoEditMenuStripItem.Enabled = false;
                }
            }

            this.UndoEditMenuStripItem.Enabled = true;
        }