-
Notifications
You must be signed in to change notification settings - Fork 0
/
TabList.cs
54 lines (47 loc) · 1.13 KB
/
TabList.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
namespace JukaApp
{
public class TabList
{
Queue<Tab> tabs = new();
public int CurrentTab;
public TabList()
{
tabs.Enqueue(new Tab());
CurrentTab = 0;
}
public Queue<Tab> List()
{
return tabs;
}
public void Add(string name = "Untitled.juk",string code="")
{
tabs.Enqueue(new Tab(name,code));
CurrentTab = tabs.Count-1;
}
public void Delete(int id)
{
Console.WriteLine(id);
tabs = new Queue<Tab>(tabs.Where(x => x.Id != id));
if (CurrentTab > 0)
{
CurrentTab--;
}
else if (tabs.Count == 0)
{
CurrentTab = 0;
}
else
{
CurrentTab = -1;
}
}
public void SetCurrentTab(int id)
{
CurrentTab = tabs.ToList().FindIndex(x => x.Id == id);
}
public Tab GetCurrentTab()
{
return tabs.ElementAt(CurrentTab);
}
}
}