/
lootTableCategory.cs
87 lines (72 loc) · 2.87 KB
/
lootTableCategory.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows;
namespace Random_Item_Giver_Updater
{
public class lootTableCategory
{
//Controls
public StackPanel stpCategory = new StackPanel();
public Canvas cvsCategoryHeader = new Canvas();
public TextBlock tblCategoryHeader = new TextBlock();
//Attributes
public string categoryName;
public string categoryPath;
public bool isCollapsed = true;
public List<lootTable> lootTableList = new List<lootTable>();
//-- Constructor --//
public lootTableCategory(string name, string path)
{
//Map variables
categoryName = name;
categoryPath = path;
//Create category canvas
stpCategory.Children.Add(cvsCategoryHeader);
//Create category header canvas
cvsCategoryHeader.Height = 35;
cvsCategoryHeader.MouseDown += new MouseButtonEventHandler(cvsCategoryHeader_MouseDown);
cvsCategoryHeader.Background = new SolidColorBrush(Color.FromArgb(100, 16, 28, 28));
cvsCategoryHeader.Children.Add(tblCategoryHeader);
//Create category header
tblCategoryHeader.Text = string.Format("▼ {0}", categoryName);
tblCategoryHeader.FontSize = 15;
tblCategoryHeader.FontWeight = FontWeights.SemiBold;
tblCategoryHeader.Foreground = new SolidColorBrush(Colors.White);
tblCategoryHeader.Margin = new Thickness(10, 10, 0, 0);
}
//-- Event Handlers --//
private void cvsCategoryHeader_MouseDown(object sender, MouseEventArgs e)
{
if (isCollapsed == true)
{
//Show all the loot tables
foreach (lootTable lootTable in lootTableList)
{
lootTable.cvsLootTable.Visibility = Visibility.Visible;
stpCategory.Children.Add(lootTable.cvsLootTable);
}
//Change the collapse state variable
isCollapsed = false;
//Change the arrow symbol
tblCategoryHeader.Text = string.Format("▲ {0}", categoryName);
}
else if (isCollapsed == false)
{
//Hide the loot tables and collapse the categories
stpCategory.Children.Clear();
//Readd the header
stpCategory.Children.Add(cvsCategoryHeader);
//Change the collapse state variable
isCollapsed = true;
//Change the arrow symbol
tblCategoryHeader.Text = string.Format("▼ {0}", categoryName);
}
}
}
}