public MainWindowViewModel() { DisplayMessageCommand = new MessageCommand(DisplayMessage); CloseAppCommand = new CloseAppCommand(ShutdownApp); AddInstructionCommand = new AddInstructionCommand(AddInstruction); VerifyProgramCommand = new VerifyProgramCommand(VerifyProgram); ConsoleInputCommand = new ConsoleInputCommand(ConsoleInput); ArduinoHandler = new ArduinoHandler(); SaveFileCommand = new SaveFileCommand(SaveFile); LoadProgramCommand = new LoadProgramCommand(LoadProgramFile); ibm = new InstructionBlockModel(); }
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; }