forked from tergav17/CPU7Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.axaml.cs
More file actions
128 lines (101 loc) · 3.44 KB
/
MainWindow.axaml.cs
File metadata and controls
128 lines (101 loc) · 3.44 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Threading;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using CPU7Plus.Emulation;
using CPU7Plus.ViewModels;
namespace CPU7Plus.Views {
public partial class MainWindow : Window {
// Instances
private EmulationHandler _emulationHandler;
private MemoryViewer _viewer;
private DiagnosticPanel _diagnostic;
private BinaryLoader _loader;
public MainWindow() {
InitializeComponent();
// Initialize views
_viewer = new MemoryViewer() {
DataContext = new MemoryViewerViewModel(),
};
_loader = new BinaryLoader() {
DataContext = new BinaryLoaderViewModel(),
};
_diagnostic = new DiagnosticPanel() {
DataContext = new DiagnosticPanelViewModel(),
};
// Start emulator
_emulationHandler = new EmulationHandler(this, _viewer, _loader, _diagnostic);
}
/**
* On close event
*/
public void OnClose(object? sender, EventArgs e) {
// Terminate handler
_emulationHandler.Terminate();
// Close all additional windows
_viewer.AllowClose();
_viewer.Close();
_loader.AllowClose();
_loader.Close();
_diagnostic.AllowClose();
_diagnostic.Close();
this.Hide();
Thread.Sleep(500);
System.Environment.Exit(0);
}
/**
* Button handler for single stepping
*/
public void OnStepButton(object sender, RoutedEventArgs e) {
_emulationHandler.IssueCommand(new Command(0));
_viewer.UpdateDisplay();
}
/**
* Button handler for running the processor
*/
public void OnRunButton(object sender, RoutedEventArgs e) {
_emulationHandler.StartExecution();
ViewUpdater.DisableInputs(this);
}
/**
* Button handler for stopping the processor
*/
public void OnStopButton(object sender, RoutedEventArgs e) {
_emulationHandler.StopExecution();
ViewUpdater.EnableInputs(this);
_viewer.UpdateDisplay();
}
/**
* Menu button handler for stopping the processor
*/
public void OnExitButton(object sender, RoutedEventArgs e) {
this.Close();
}
/**
* Menu button handler for opening the memory viewer
*/
public void OnMemoryViewerButton(object sender, RoutedEventArgs e) {
_viewer.Show();
}
/**
* Menu button handler for opening the binary loader
*/
private void OnBinaryLoaderButton(object? sender, RoutedEventArgs e) {
_loader.Show();
}
/**
* Menu button handler for opening the diagnostic panel
*/
private void OnDiagnosticPanelButton(object? sender, RoutedEventArgs e) {
_diagnostic.Show();
}
/**
* Restart the processor
*/
private void OnSelect(object? sender, RoutedEventArgs e) {
_emulationHandler.IssueCommand(new Command(4));
}
}
}