-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelpWindow.axaml.cs
More file actions
71 lines (63 loc) · 2.31 KB
/
Copy pathHelpWindow.axaml.cs
File metadata and controls
71 lines (63 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using System.Collections.ObjectModel;
using Emulator;
using System;
using System.Linq;
using System.Collections.Generic;
namespace Nema
{
public class HelpCommandInfo
{
private string _name;
private string _arguments;
/// <summary>
/// User written note that explains what this command does
/// </summary>
private string _note;
public string Name => _name;
public string Arguments => _arguments;
public string Note => _note;
public HelpCommandInfo(string name, string arguments, string note)
{
_name = name;
_arguments = arguments;
_note = note;
}
}
public partial class HelpWindow : Window
{
private ObservableCollection<HelpCommandInfo> _commands = new ObservableCollection<HelpCommandInfo>();
public ObservableCollection<HelpCommandInfo> Commands => _commands;
public HelpWindow()
{
InitializeComponent();
string infoText = System.IO.File.ReadAllText("./Configuration/CommandInfo.json");
ProcessorCommandsInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject<ProcessorCommandsInfo>(infoText) ?? throw new NullReferenceException("Unable to process configuration");
foreach (var command in info.Commands)
{
string arguments = string.Empty;
foreach (CommandArgumentType arg in command.Value.Arguments)
{
switch (arg)
{
case CommandArgumentType.RegisterName:
arguments += "A-L";
break;
case CommandArgumentType.Int8:
arguments += "D8";
break;
case CommandArgumentType.Int16:
arguments += "Label/D16";
break;
}
arguments += ",";
}
arguments = arguments.TrimEnd(',');
Commands.Add(new HelpCommandInfo(command.Key, arguments, command.Value.Note ?? string.Empty));
}
this.DataContext = this;
}
}
}