private void OnAddAction(InstructionItem instructionItem) { var action = CreateAction(instructionItem); Script.Add(action); SelectedIndex = Script.Count - 1; }
/// <summary> /// Loads the state. /// </summary> public override async Task LoadState() { await base.LoadState(); SelectedInstructionItem = null; SelectedInstructionItem = InstructionItems.FirstOrDefault(); }
public void ConvertInstructions() { int stepCounter = 2; List <InstructionItem> instructions = new List <InstructionItem>(); InstructionItem newSet = new InstructionItem(); newSet.Step = 1; newSet.Directive = firstEditor.Text; instructions.Add(newSet); if (stackLayout.Children.Count > 3) { for (int i = 2; i < stackLayout.Children.Count - 1; i++) { // Even elements are labels if (i % 2 == 0) { newSet = new InstructionItem(); newSet.Step = stepCounter; stepCounter++; } else { if (((Editor)stackLayout.Children.ElementAt(i)).Text != string.Empty && ((Editor)stackLayout.Children.ElementAt(i)).Text != null) { newSet.Directive = ((Editor)stackLayout.Children.ElementAt(i)).Text; instructions.Add(newSet); } } } } preSavedRecipe = (BindingContext as SingleRecipeData); FirebaseHelper.SaveInstructions(preSavedRecipe, instructions); preSavedRecipe.Instructions = instructions; }
public void Set(Buttons button, string text) { if (!items.TryGetValue(button, out var item)) { item = new InstructionItem(); items[button] = item; } item.Text = text; item.Content = null; item.Visible = true; }
private void OnInsertAction(InstructionItem instructionItem) { if (SelectedIndex < 0) { return; } var action = CreateAction(instructionItem); Script.Insert(SelectedIndex, action); SelectedIndex = SelectedIndex - 1; }
private ScriptedInstructionViewModel CreateAction(InstructionItem instructionItem) { var helper = new InstructionFactory(instructionItem.Type); var instruction = helper.Create(); var viewModel = new ScriptedInstructionViewModel(this) { ScriptedInstruction = instruction }; return(viewModel); }
private static void CreateInstructionClass(StringBuilder sb, InstructionItem instruction, IReadOnlyDictionary <string, bool> knownEnumerands) { sb.AppendLine($"public class {instruction.Name} : Instruction"); sb.AppendLine("{"); sb.AppendLine($"public {instruction.Name} ()"); if (instruction.Operands == null) { sb.AppendLine($" : base (\"{instruction.Name}\")"); } else { sb.AppendLine($" : base (\"{instruction.Name}\", new List<Operand> () {{"); foreach (var operand in instruction.Operands) { string constructorParameter = null; if (knownEnumerands.ContainsKey(operand.Kind)) { constructorParameter = $"new EnumType<{operand.Kind}, {operand.Kind}ParameterFactory> ()"; } else { constructorParameter = $"new {operand.Kind} ()"; } if (operand.Name == null) { sb.AppendLine($"new Operand ({constructorParameter}, null, OperandQuantifier.{operand.Quantifier}),"); } else { sb.AppendLine($"new Operand ({constructorParameter}, \"{operand.Name}\", OperandQuantifier.{operand.Quantifier}),"); } } sb.AppendLine("} )"); } sb.AppendLine("{}"); sb.AppendLine("}"); }
private void OnNavigateToTargetPage(InstructionItem instructionItem) { _navigationFacade.NavigateToCategoriesView(); }
/// <summary> /// Adds the given instruction to the project explorer. /// </summary> /// <param name="instruction">The instruction to add to the project explorer.</param> private void AddInstruction(InstructionItem instruction) { ProjectExplorerViewModel.GetInstance().AddNewProjectItems(addToSelected: false, projectItems: instruction); }
/// <summary> /// Adds the given code trace result to the project explorer. /// </summary> /// <param name="codeTraceResult">The code trace result to add to the project explorer.</param> private void AddCodeTraceResult(CodeTraceResult codeTraceResult) { InstructionItem instructionItem = new InstructionItem(codeTraceResult.Address, "", "nop", new Byte[] { 0x90 }); ProjectExplorerViewModel.GetInstance().AddProjectItems(instructionItem); }
private void InitializeContent(IUserInterfaceRenderContext renderContext, Buttons key, InstructionItem item) { if (item.ButtonContent == null) { item.ButtonContent = renderContext.CreateContentLayout( "{Button " + key + "} ", contentLayoutOptions, performLocalization: false); } if (item.Content == null) { item.Content = renderContext.CreateContentLayout(item.Text, contentLayoutOptions); } }
public InstructionItemView(InstructionItem instructionItem) { this.InstructionItem = instructionItem; }
private void OnNavigateToTargetPage(InstructionItem instructionItem) { _navigationFacade.NavigateToMainPage(); }
/// <summary> /// Adds the given instruction to the project explorer. /// </summary> /// <param name="instruction">The instruction to add to the project explorer.</param> private void AddInstruction(InstructionItem instruction) { ProjectExplorerViewModel.GetInstance().AddProjectItems(instruction); }
private void InitializeContent(IWidgetRenderContext renderContext, Buttons key, InstructionItem item) { if (item.ButtonContent == null) { item.ButtonContent = renderContext.CreateContentLayout( "{Button " + key + "} ", contentLayoutOptions, localizeText: false); } if (item.Content == null) { item.Content = renderContext.CreateContentLayout(item.Text, contentLayoutOptions); } }
private static void ProcessInstructions(Newtonsoft.Json.Linq.JToken instructions, IReadOnlyDictionary <string, bool> knownEnumerands, SyntaxGenerator generator, IList <SyntaxNode> nodes) { var ins = new List <InstructionItem> (); foreach (var instruction in instructions) { var i = new InstructionItem() { Name = instruction.Value <string> ("opname"), Id = instruction.Value <int> ("opcode") }; if (instruction["operands"] != null) { i.Operands = new List <OperandItem> (); foreach (var operand in instruction["operands"]) { var oe = new OperandItem() { Kind = operand.Value <string> ("kind") }; if (operand["quantifier"] != null) { var q = operand.Value <string> ("quantifier"); switch (q) { case "*": oe.Quantifier = "Varying"; break; case "?": oe.Quantifier = "Optional"; break; } } else { oe.Quantifier = "Default"; } if (operand["name"] != null) { var operandName = operand.Value <string> ("name"); if (operandName.StartsWith('\'')) { operandName = operandName.Replace("\'", ""); } operandName = operandName.Replace("\n", ""); oe.Name = operandName; } i.Operands.Add(oe); } } ins.Add(i); } var sb = new StringBuilder(); foreach (var instruction in ins) { CreateInstructionClass(sb, instruction, knownEnumerands); } sb.AppendLine("public static class Instructions {"); sb.Append("private static readonly Dictionary<int, Instruction> instructions_ = new Dictionary<int, Instruction> {"); foreach (var instruction in ins) { sb.AppendLine($"{{ {instruction.Id}, new {instruction.Name}() }},"); } sb.Append(@"}; public static IReadOnlyDictionary<int, Instruction> OpcodeToInstruction { get => instructions_; } }" ); var s = sb.ToString(); var tree = CSharpSyntaxTree.ParseText(s); var tn = tree.GetRoot().ChildNodes(); foreach (var n in tn) { nodes.Add(n.NormalizeWhitespace()); } }