-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainWindow.xaml.cs
102 lines (88 loc) · 3.23 KB
/
MainWindow.xaml.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace JobsScheduler
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public int noOfProcesses = 0;
public string schedulerType = null;
public int? quantumTime;
public MainWindow()
{
InitializeComponent();
}
private void Next_Button_Click(object sender, RoutedEventArgs e)
{
noOfProcesses = 0;
try
{
int NumberOfProcesses = Int32.Parse(ProcessesNo_Input.Text);
if (NumberOfProcesses < 1)
{
errorMessage.Text = "please enter numbers greater than 0";
}
// want to check if the user has chosen something from the combo box
else if (Combo_Value.Text == "")
{
errorMessage.Text = "please choose one from the above Schedulers";
}
else
{
// need to navigate to new window after updating the public variable of no of processes
noOfProcesses = NumberOfProcesses;
schedulerType = Combo_Value.Text;
quantumTime = Int32.Parse(quantumValue.Text);
if(quantumTime < 0)
{
errorMessage.Text = "please make sure quantum time is positive number";
}
else
{
errorMessage.Visibility = Visibility.Hidden;
var newForm = new Details(noOfProcesses, schedulerType, quantumTime); //create your new form.
newForm.Show(); //show the new form.
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
// this to ensure that user can't type any string in the text Box or any number greater than 5
private void ProcessesNo_Input_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
String value = ((sender as ComboBox).SelectedItem as ComboBoxItem).Content as string;
if (value == "Round Robin")
{
quantumBlock.Visibility = Visibility.Visible;
quantumValue.Visibility = Visibility.Visible;
}
else
{
quantumBlock.Visibility = Visibility.Hidden;
quantumValue.Visibility = Visibility.Hidden;
}
}
}
}