public PapyrusInstructionSelectorViewModel(IEnumerable <PapyrusInstruction> instructions, OpCodeArgumentDescription opCodeArgumentDescription) { if (instructions != null) { Instructions = new ObservableCollection <PapyrusInstruction>(instructions); } }
public PapyrusConstantValueViewModel(OpCodeArgumentDescription desc) { this.desc = desc; ValueInputVisibility = Visibility.Visible; ComboBoxItems = new ObservableCollection <FrameworkElement>(CreateComboBoxItems()); SelectedValueType = ComboBoxItems.First() as ComboBoxItem; }
public PapyrusReferenceValueViewModel(List <PapyrusAssemblyDefinition> loadedAssemblies, PapyrusTypeDefinition currentType, PapyrusMethodDefinition currentMethod, OpCodeArgumentDescription desc) { this.loadedAssemblies = loadedAssemblies; this.currentType = currentType; this.currentMethod = currentMethod; this.desc = desc; if (currentMethod != null) { ReferenceCollection = new ObservableCollection <PapyrusMemberReference>(currentMethod.GetVariables()); } ComboBoxItems = new ObservableCollection <FrameworkElement>(CreateComboBoxItems()); SelectedReferenceType = ComboBoxItems.First() as ComboBoxItem; ReferenceSelectionVisible = Visibility.Visible; }
public PapyrusReferenceAndConstantValueViewModel(List <PapyrusAssemblyDefinition> loadedAssemblies, PapyrusTypeDefinition currentType, PapyrusMethodDefinition currentMethod, OpCodeArgumentDescription desc, PapyrusPrimitiveType[] argumentTypes) { this.loadedAssemblies = loadedAssemblies; this.currentType = currentType; this.currentMethod = currentMethod; this.desc = desc; this.argumentTypes = argumentTypes; if (argumentTypes == null) { argumentTypes = new PapyrusPrimitiveType[0]; } // Update the type constraints so we are only able to assign // values of the correct types. if (desc != null && argumentTypes.Length > 0) { UpdateTypeConstraints(argumentTypes); } if (currentMethod != null) { var references = new List <PapyrusMemberReference>(); references.AddRange(currentMethod.Parameters); references.AddRange(currentMethod.GetVariables()); if (currentType != null) { references.AddRange(currentType.Fields); } ReferenceCollection = new ObservableCollection <PapyrusMemberReference>(references); HideValueInputs(); ReferenceValueVisibility = Visibility.Visible; //SelectedValueType = ReferenceCollection.LastOrDefault(); } ComboBoxItems = new ObservableCollection <FrameworkElement>(CreateComboBoxItems()); SelectedValueType = ComboBoxItems.First() as ComboBoxItem; }
public PapyrusMethodSelectorViewModel(List <PapyrusAssemblyDefinition> loadedAssemblies, PapyrusTypeDefinition currentType, OpCodeArgumentDescription opCodeArgumentDescription) { this.loadedAssemblies = loadedAssemblies; if (currentType != null) { Methods = new ObservableCollection <PapyrusViewModel>( currentType.States.SelectMany(s => s.Methods) .OrderBy(m => m.Name?.Value) .Select(j => new PapyrusViewModel { Text = j.Name.Value + GetParameterString(j.Parameters) + " : " + j.ReturnTypeName.Value, Item = j })); } SelectedMethodCommand = new RelayCommand <PapyrusViewModel>(SelectMethod); }
public PapyrusTypeSelectorViewModel(List <PapyrusAssemblyDefinition> loadedAssemblies, OpCodeArgumentDescription opCodeArgumentDescription) { this.loadedAssemblies = loadedAssemblies; this.opCodeArgumentDescription = opCodeArgumentDescription; SelectedTypeCommand = new RelayCommand <PapyrusViewModel>(SelectType); if (loadedAssemblies != null) { var defs = loadedAssemblies.SelectMany(t => t.Types).ToList(); Types = new ObservableCollection <PapyrusViewModel>( defs.Select(i => new PapyrusViewModel { Text = i.Name.Value + (!string.IsNullOrEmpty(i.BaseTypeName.Value) ? " : " + i.BaseTypeName.Value : ""), Item = i }) ); } }
//public object GetOperand() //{ // OperandLookup() // throw new System.NotImplementedException(); //} private void ShowArgumentSelectionDialog(OpCodeArgumentDescription d) { if (d.Ref == OpCodeRef.Instruction) { var dialog = new PapyrusInstructionSelectorViewModel(currentMethod.Body.Instructions.ToArray(), d); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { Arguments[d.Index] = dialog.SelectedInstruction; } } else if (d.Ref == OpCodeRef.Type) { var dialog = new PapyrusTypeSelectorViewModel(loadedAssemblies, d); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { Arguments[d.Index] = dialog.SelectedType; } } else if (d.Ref == OpCodeRef.Method) { var targetType = GetTargetType(currentType); var dialog = new PapyrusMethodSelectorViewModel(loadedAssemblies, targetType, d); var result = dialogService.ShowDialog(dialog); // change currentType to selected type later if (result == DialogResult.OK) { PapyrusMethodDefinition method = null; var selMethod = dialog.SelectedMethod; if (selMethod != null) { method = dialog.SelectedMethod.Item as PapyrusMethodDefinition; } if ((method != null && dialog.SelectedMethodName != null && (method.Name.Value != dialog.SelectedMethodName)) || (method == null && dialog.SelectedMethodName != null)) { Arguments[d.Index] = CreateReferenceFromName(dialog.SelectedMethodName); } else { Arguments[d.Index] = method; } } } else { if (d.ValueType == OpCodeValueTypes.Constant) { var dialog = new PapyrusConstantValueViewModel(d); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { Arguments[d.Index] = dialog.SelectedValue; } } else if (d.ValueType == OpCodeValueTypes.Reference) { var dialog = new PapyrusReferenceValueViewModel(loadedAssemblies, currentType, currentMethod, d); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { if (dialog.SelectedReference == null) { var name = dialog.SelectedReferenceName; Arguments[d.Index] = CreateReferenceFromName(name); } else { Arguments[d.Index] = dialog.SelectedReference; } } } else { UpdateArgumentConstraintTypes(); var dialog = new PapyrusReferenceAndConstantValueViewModel(loadedAssemblies, currentType, currentMethod, d, ArgumentTypes); var result = dialogService.ShowDialog(dialog); if (result == DialogResult.OK) { if (dialog.SelectedConstantValue == null && dialog.SelectedReferenceValue == null && dialog.SelectedReferenceName != null) { var name = dialog.SelectedReferenceName; Arguments[d.Index] = CreateReferenceFromName(name); } else { Arguments[d.Index] = dialog.SelectedItem; } } } } UpdateArguments(); }