-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChangeMemorySpace.xaml.cs
More file actions
103 lines (94 loc) · 3.51 KB
/
ChangeMemorySpace.xaml.cs
File metadata and controls
103 lines (94 loc) · 3.51 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
using System.Windows;
/*
* Primary namespace for HyperV-DDA application
* It contains the main window and all related methods for the core application
*/
namespace TheFlightSims.HyperVDDA
{
/*
* Change Memory Space Window
*/
public partial class ChangeMemorySpace : Window
{
////////////////////////////////////////////////////////////////
/// Global Properties and Constructors Region
/// This region contains global properties and constructors
/// for the MachineMethods class.
////////////////////////////////////////////////////////////////
/*
* Global properties
* memRange as tuple of low and high memory
*/
protected (ulong lowMem, ulong highMem) memRange;
// Constructor of the Change Memory space window
public ChangeMemorySpace(string vmName)
{
Title += $" for {vmName}";
InitializeComponent();
}
////////////////////////////////////////////////////////////////
/// User Action Methods Region
/// This region contains methods that handle user actions.
/// For example, button clicks, changes in order.
////////////////////////////////////////////////////////////////
/*
* Actions for button "Confirm"
*/
private void Confirm_Button(object sender, RoutedEventArgs e)
{
// Try to parse number in the box
if (ulong.TryParse(LowMemory_TextBox.Text, out ulong lowMemCompare) && ulong.TryParse(HighMemory_TextBox.Text, out ulong highMemCompare))
{
// Check for low MMIO and high MMIO. If valid, return the value
if ((lowMemCompare >= 128 && lowMemCompare <= 3584) && (highMemCompare >= 4096 && highMemCompare <= (ulong.MaxValue - 2)))
{
memRange.lowMem = lowMemCompare;
memRange.highMem = highMemCompare;
DialogResult = true;
}
else
{
// Notify user for invalid valid input
_ = MessageBox.Show(
"Make sure the Low MMIO Gap is in range (128, 3584) and High MMIO is larger than 4096",
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning
);
}
}
else
{
_ = MessageBox.Show(
"Please enter a positive integer in both box.",
"Warning",
MessageBoxButton.OK,
MessageBoxImage.Warning
);
}
}
/*
* Action for button "Cancel"
*/
private void Cancel_Button(object sender, RoutedEventArgs e)
{
Close();
}
////////////////////////////////////////////////////////////////
/// Non-User Action Methods Region
///
/// This region contains methods that do not handle user actions.
///
/// Think about this is the back-end section.
/// It should not be in a seperated class, because it directly interacts with the UI elements.
////////////////////////////////////////////////////////////////
/*
* Return Value
*/
public (ulong, ulong) ReturnValue()
{
_ = ShowDialog();
return memRange;
}
}
}