private void EditInstruction() { var loadedAssemblies = pexLoader.GetLoadedAssemblies().ToList(); var dialog = new PapyrusInstructionEditorViewModel(dialogService, loadedAssemblies, main.selectedMethod.DeclaringState?.DeclaringType?.Assembly, main.selectedMethod.DeclaringState?.DeclaringType, main.selectedMethod, SelectedMethodInstruction); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { var inst = SelectedMethodInstruction; //inst.Operand = dialog.Operand; inst.OpCode = dialog.SelectedOpCode; inst.Arguments = dialog.Arguments; inst.OperandArguments = new List <PapyrusVariableReference>(dialog.OperandArguments); main.selectedMethod.Body.Instructions.RecalculateOffsets(); main.selectedMethod.UpdateInstructionOperands(); SelectedMethodInstructions = new ObservableCollection <PapyrusInstruction>(main.selectedMethod.Body.Instructions); main.selectedMethodNode.SetDirty(true); main.RaiseCommandsCanExecute(); } }
private void CreateInstruction() { var loadedAssemblies = pexLoader.GetLoadedAssemblies().ToList(); var dialog = new PapyrusInstructionEditorViewModel(dialogService, loadedAssemblies, main.selectedMethod.DeclaringState?.DeclaringType?.Assembly, main.selectedMethod.DeclaringState?.DeclaringType, main.selectedMethod); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { CreateAndInsertInstructionAt(int.MaxValue, dialog); main.RaiseCommandsCanExecute(); } }
private void CreateAndInsertInstructionAt(int index, PapyrusInstructionEditorViewModel dialog) { var newInstruction = new PapyrusInstruction(); newInstruction.OpCode = dialog.SelectedOpCode; //newInstruction.Operand = dialog.Operand; newInstruction.Arguments = dialog.Arguments; newInstruction.OperandArguments = new List <PapyrusVariableReference>(dialog.OperandArguments); main.selectedMethod.Body.Instructions.Insert(index, newInstruction); main.selectedMethod.Body.Instructions.RecalculateOffsets(); main.selectedMethod.UpdateInstructionOperands(); SelectedMethodInstructions = new ObservableCollection <PapyrusInstruction>(main.selectedMethod.Body.Instructions); main.selectedMethodNode.SetDirty(true); }
private void InsertInstructionBefore() { var loadedAssemblies = pexLoader.GetLoadedAssemblies().ToList(); var dialog = new PapyrusInstructionEditorViewModel(dialogService, loadedAssemblies, main.selectedMethod.DeclaringState?.DeclaringType?.Assembly, main.selectedMethod.DeclaringState?.DeclaringType, main.selectedMethod); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { var inst = SelectedMethodInstruction; var index = SelectedMethodInstructions.IndexOf(inst); if (index < 0) { index = 0; } CreateAndInsertInstructionAt(index, dialog); main.RaiseCommandsCanExecute(); } }