-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseCreation.cs
182 lines (165 loc) · 5.47 KB
/
BaseCreation.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
using Job_Application_Database.Enum;
using System.Windows;
using System.Windows.Input;
namespace Job_Application_Database.Classes
{
/// <summary>
/// Job Board creation window extended from BaseCreation
/// </summary>
public abstract class BaseCreation : BaseWindow
{
/// <summary>
/// Reference To The Base Creation Window
/// </summary>
private BaseCreationWindow BaseCreationWindow
{
get
{
return (BaseCreationWindow)base.Window;
}
}
/// <summary>
/// The Exit Status Of Base Creation Window
/// </summary>
public override ExitStatus Exit
{
get
{
return BaseCreationWindow.Exit;
}
set
{
BaseCreationWindow.Exit = value;
}
}
/// <summary>
/// The Information That Is Being Edited
/// </summary>
public BaseInfo Info { get; }
/// <summary>
/// The Text In The Base Creation Window's Name TextBoxes
/// </summary>
private string Name
{
get
{
return BaseCreationWindow.textboxName.Text;
}
set
{
BaseCreationWindow.textboxName.Text = value;
}
}
/// <summary>
/// The Extra String In The Base Creation's Extra TextBox
/// </summary>
private string Extra
{
get
{
return BaseCreationWindow.textboxExtra.Text;
}
set
{
BaseCreationWindow.textboxExtra.Text = value;
}
}
/// <summary>
/// Constructor To Create A New BaseCreationWindow
/// </summary>
/// <param name="info">The Info To Be Edited</param>
/// <param name="mode">The Editing Mode</param>
/// <param name="title">The Title Of The Window</param>
/// <param name="label">The Label Of The Extra String</param>
public BaseCreation(BaseInfo info, Enum.EditMode mode, string title, string label) : base(new BaseCreationWindow(), "")
{
Info = info;
string _title = string.Empty;
string _button = string.Empty;
if (mode == EditMode.New)
{
_title = "New ";
_button = "Create";
}
else if (mode == EditMode.Edit)
{
_title = "Edit " + info.Name + " ";
_button = "Save";
BaseCreationWindow.textboxName.Text = info.Name;
BaseCreationWindow.textboxExtra.Text = info.Extra;
}
_title += title;
BaseCreationWindow.Title = _title;
BaseCreationWindow.labelExtra.Content = label;
BaseCreationWindow.textboxExtra.Text = label;
BaseCreationWindow.buttonOk.Content = _button;
BaseCreationWindow.Closing += Window_Closing;
BaseCreationWindow.KeyDown += Window_KeyDown;
}
/// <summary>
/// Overrided Window Loaded Event Method
/// </summary>
/// <param name="sender">Object Which Called This Function</param>
/// <param name="e">The Arguments</param>
protected override void Window_Loaded(object sender, RoutedEventArgs e)
{
BaseCreationWindow.buttonCancel.Click += Element_Click;
BaseCreationWindow.buttonOk.Click += Element_Click;
}
/// <summary>
/// Window Closing Event Method
/// Handles Exit Status Flow
/// </summary>
/// <param name="sender">Object Which Called This Function</param>
/// <param name="e">The Arguments</param>
protected override void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (Exit == Enum.ExitStatus.Ok)
{
SaveBaseDetails();
}
}
/// <summary>
/// Window Key Down Event Method
/// Handles Enter And Escape Key Presses
/// </summary>
/// <param name="sender">Object Which Called This Function</param>
/// <param name="e">The Arguments</param>
protected override void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
BaseCreationWindow.Exit = ExitStatus.Cancel;
BaseCreationWindow.Close();
}
else if (e.Key == Key.Enter)
{
SaveBaseDetails();
BaseCreationWindow.Exit = ExitStatus.Ok;
BaseCreationWindow.Close();
}
}
/// <summary>
/// Window Button Click Method
/// Handles Button Presses
/// </summary>
/// <param name="sender">Object Which Called This Function</param>
/// <param name="e">The Arguments</param>
protected override void Element_Click(object sender, RoutedEventArgs e)
{
if (e.Source == BaseCreationWindow.buttonOk)
{
Exit = Enum.ExitStatus.Ok;
}
BaseCreationWindow.Close();
}
/// <summary>
/// Takes Info From Window And Saves To Info
/// </summary>
protected void SaveBaseDetails()
{
Info.Name = Name;
Info.Extra = Extra;
}
}
}