-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonSession.cs
More file actions
62 lines (61 loc) · 1.9 KB
/
Copy pathButtonSession.cs
File metadata and controls
62 lines (61 loc) · 1.9 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
using static SplashKitSDK.SplashKit;
using System;
public class ButtonSession{
private List<Button> _addbuttons = new List<Button>();
private List<Button> _delbuttons = new List<Button>();
public ButtonSession(){
}
public void AddButton(StockItem stock){
//Generate add and delete buttons
AddButton add_button = new AddButton(stock.Name,720,stock.Y+17,"images/add.png",stock);
DeleteButton del_button = new DeleteButton(stock.Name,755,stock.Y+17,"images/delete.png",stock);
_addbuttons.Add(add_button);
_delbuttons.Add(del_button);
}
public void RemoveButton(StockItem stock){
foreach(AddButton button in _addbuttons){
if(button.Item == stock){
_addbuttons.Remove(button);
break;
}
}
}
public StockItem StockAdd(float x, float y){
foreach (AddButton button in _addbuttons)
{
if(button.IsClicked(x,y)){
return button.Item as StockItem;
}
}
return null;
}
public StockItem StockDelete(float x, float y){
foreach (DeleteButton button in _delbuttons)
{
if(button.IsClicked(x,y)){
RemoveButton(button.Item as StockItem);
_delbuttons.Remove(button);
return button.Item as StockItem;
}
}
return null;
}
public void Draw(){
foreach(Button button in _addbuttons){
button.Draw();
}
foreach(Button button in _delbuttons){
button.Draw();
}
}
public void Update(float delta){
for (int i = 0; i < _addbuttons.Count; i++){
_addbuttons[i].Y = _addbuttons[i].Y + delta;
_delbuttons[i].Y = _delbuttons[i].Y + delta;
}
}
public void Clear(){
_addbuttons.Clear();
_delbuttons.Clear();
}
}